User Tools

Site Tools


mgv84-en

MGV84 Quad Servo driver

ContentHardwareMGV


By Peter Giling

Latest news..............

If you ever plan to copy and build this interface, please have some patience.

Expected somewhere medium April a new board will be announced, replacing MGV81,MGV84 and MGV84s.

The new interface will be available as factory made printed circuit.

Next news is that also for MGV84, new software (freeware) will be available shortly, making it possible to adjust left an right angle of the servo, the running speed, and relay choice.

This is all done while the MGV84 remains connected as usual to MGV50.

No extra connection or anything is to be made. Only new fromware needs to be programmed in PIC chip.

Adjustment pots and jumper will be without function after installing the new firmware.

Implementation of this possibility in Rocrail is scheduled.

Preview

Changing turnout positions in model railroad systems, is usually expensive or not quite reliable.

The MGV84 unit provides a way to control 4 cheap servo motors, achieving a reliable and affordable way in this matter.

The MGV84 has 4 isolated inputs, which will each be activated by supplying 5V dc. (Higher voltage optional)

MGV84 is also provided with 4 relays, to change polarity of the turnout frogs.

MGV84 provides isolated outputs for feedback. Feedback is activated after servomotor is finished.

This makes it possible for Rocrail to determine if a very slow changing turnout has reached its position.

This board is a D.I.Y. project. No boards available.

If changing of polarity of turnout frog is not needed, simple leave away the four relays. It will cut the price of the board by almost 50%.

Version V1-2 is provided with two automatic fuses and leds to signal wrong direction of relays.

This picture shows how MGV84(right) is connected to MGV50(left)
For use of flatcable, refer to
http://wiki.rocrail.net/doku.php?id=mgv-overview-en#connection_cable_mgv50_interface

Schematic description of the circuit

The power supply for the board, connected to J5, can be anything between 8 to 18V ac and 10 to 18V dc, including the use of digital rail power.

A running servo draws high current spikes from the power supply.

For that reason a second 5V regulator is used for the Microprocessor.

Transistor TR1 will switch power to servo's after the power system has settled.

This will take care for must of the 'spastic' movements of servo's while starting up.

Via J6 (pin 3 to 6) a command is coming from MGV50 or any other signal.

A 5 volt to one of these pins activates the according opto-coupler in U1, and makes the input in U4, an I2C expander, (pin 9 to 12) 0 Volt.

This chip is constantly read out by the microprocessor U2. This will activate the servo, running ant-clockwise. The program is set to run the servo in an angle between 45 and 135 degrees.

These 90 degrees are normally the maximum angle for linear movements.

Changing the numbers 100 and 200 in the program to minimum 50 and maximum 250 will make a full 180 degrees.

When the servo has come to the middle position, the position of the relay K1, K2, K3 or K4 will change, to invert the polarity of the turnout frog.

After the servo has reached the final position, the feed-back will be given through U4 to opto-coupler U3.

Feed-back output will be 0 at clockwise-end position and high at anti-clockwise end position.

Settings for movement angle and runtime of servo, and the polarity of according relay, as descripted in =making adjustments=

Since the power supply can only handle one servo, only one servo will be activated.

With a run time of several seconds, it can be a considerable long time before all servo's have changed, when a command is given to do that.

In a shadow station, this could cause trains running of the track.

Therefore Rocrail and this MGV84 include the feed-back situation. With that option, a train will only start running after all turnouts in the claimed route have reached there position.

Functions

For each turnout there are three individual settings to be made:

  • Speed of the motor.
  • The total angle, adjustable between 10 and 180 degrees.
  • The position of the relay. (normal or reverse)

Features

  • Relay for each turnout frog
  • Relays are bistabile, to reduce power consumption
  • Feedbacks for each servo
  • Isolated input and feedback, to avoid ground loops.

Programming the Pic Chip

The PIC16F873(A) chip needs a program. Due to my low skill of programming, I simply use a nice and really fast Basic compiler for that.

For the functions on this board there is no need at all for fast programs, like in communication or real time solutions.

The compiler I use is called Pic Simulator IDE and can be downloaded from www.oshonsoft.com.

* MGV84.bas

The following .hex file can be programmed directly in the chip.

* MGV84.hex

Making adjustments

To set these parameters follow the next steps:

1 - Make all necessary connections to MGV84.
2 - Shut off power to MGV84.
3 - Shut off all 4 inputs (if already on)
4 - Connect servomotors to MGV84
5 - Set jumper **jp1**
6 - Power up MGV84.
7 - MGV84 is now in adjust mode.
8 - Activate 1 of the 4 inputs.
9 - The corresponding servo will now run up and down.
10 - The speed of motor can be changed by **P1**. NOTE: changing the speed will only occur after the motor has been in the left limit position.
11 - The angle of the motor can be adjusted by **P2**. NOTE: changing the angle will only occur after the motor has been in the left limit position.
12 - The relay for the turnout frog will change position, when the servomotor passes the middle position.This relay-position can be reversed by setting/removing the jumper **jp1**
13 - When motor runs to satisfaction and relay position has proven to be correct, inactivate input.
14 - The parameters will be stored and the motor will stop in left limit position.
15 - Proceed, if necessary, with the other servo motors, starting at **item 8**.
16 - Before activating an other input, and before powering off, wait until previusly adjusted servo has come to rest.

After all servo motors are set, shut off power, and remove (if set) jumper jp1. Then turnon MGV84 power.

MGV84 is now ready for use.

MGV84 PCB files

mgv84_v1-2_sch.pdf The schematic design
mgv84_v1-2_pcb.pdf The pcb design + parts placement
mgv84-dwg.pdf Connections diagram

SVN

Bill of materials MGV84

Part nr Description
R1,R2,R3,R4,R7,R25 1K
R5,R6,R23,R24 3K3
R8,R10 resistor 10K
R11,R13,R15,R17 4K7
R12,R14,R16,R18 220E or 270E
R19,R20,R21,R22 560E
RP1 array 8 x 3K3
P1,P2 Trimmer pot 10K
C1 Elco 1000 uF 35V radial
C2,C3 Elco 10 uF 35V radial
C4,C7,C8 capacitor 100nF
C5,C6 capacitor 15pF
D1..D10 Diode 1N4148
Led1..Led3 Led 3mm
TR1 Transistor BD678 TO-126
U1,U3 LTV847
U2 PIC16F873(A)
U4 PCF8574
X1 Crystal 20MHz
GR1 B80C1500 www.reichelt.de B80C1500 RUND
F1 fuse 0,9A www.reichelt.de PFRA 090
VR1,VR2 7805
K1..K4 Relay RALD5W-K Conrad 502880-8A
JP1 two pin jumper
J1..J4 three pin header www.reichelt.de PSS254/3G
J5 2 pole screw conn. www.reichelt.de AKL012/02
J6 10- pin header www.reichelt.de PSS254/10G
J7 6 pole screw conn. www.reichelt.de 2 x AKL012/03

Cable to MGV50

refer to: connection_cable_mgv50_interface

The PSK cable or flatcable can be connected to J5 or J6 on MGV50. Depending on that choice, the MGV50 should programmed as follows:

Connector MGV50 I/O # In or OUT function
J5 1 Switch address Command Servo 1
J5 2 Switch address Command Servo 2
J5 3 Switch address Command Servo 3
J5 4 Switch address Command Servo 4
J5 5 Input address Feed-back Servo 1
J5 6 Input address Feed-back Servo 2
J5 7 Input address Feed-back Servo 3
J5 8 Input address Feed-back Servo 4
J6 9 Switch address Command Servo 1
J6 10 Switch address Command Servo 2
J6 11 Switch address Command Servo 3
J6 12 Switch address Command Servo 4
J6 13 Input address Feed-back Servo 1
J6 14 Input address Feed-back Servo 2
J6 15 Input address Feed-back Servo 3
J6 16 Input address Feed-back Servo 4

The Switch and Input address should be numbered according your own plans.

EXAMPLE:

Suppose MGV84 is connected to MGV50(J6).

Servo3 connected here should be activated with Portnumber 52.

The feed-back of turnout position with servo3 should have number 121.

This means that on MGV50 I/O #11 must be programmed as switch with number 52.

And MGV50 I/O # 15 should be prgrammed as input with number 121.

mgv84-en.txt · Last modified: 2018/11/12 08:56 (external edit)