With the building of my new Free-mo module set “The Boat Yard“, I have had to change some of my usual “go to” items. I have always used Tortoise turnout motors in the past. These have been great performers that took little time to set up and they had built it frog polarity circuits. The issue with using them in the Boat Yard was purely financial. I needed over 20 of them to complete the project, and at $15-$20 each, it was really hurting the budget.
I decided to take a look at RC Servos. I quickly discovered that the servos themselves were not very expensive. I purchased 10 for $18.00 (less than $2 each) but I still lacked a way to operate them. Servos require a “controller” of some type to generate a signal that tells the servo which way to turn and how much to turn.
For those without knowledge of how a servo works here is a very quick and dirty “How It Works”:
Servos have three wires, Positive, negative and Control. They are controlled by sending an electrical pulse of variable width, or pulse width modulation (PWM), through the control wire. There is a minimum pulse, a maximum pulse, and a repetition rate. A servo motor can usually only turn 90 degrees in either direction for a total of 180 degree movement. The motor’s neutral position is defined as the position where the servo has the same amount of potential rotation in the both the clockwise or counter-clockwise direction (that was a lot of geek speak to say “center”). The PWM sent to the motor determines position of the shaft, and based on the duration of the pulse sent via the control wire; the rotor will turn to the desired position. The servo motor expects to see a pulse every 20 milliseconds (ms) and the length of the pulse will determine how far the motor turns. For example, a 1.5ms pulse will make the motor turn to the 90-degree position. Shorter than 1.5ms moves it to 0 degrees, and any longer than 1.5ms will turn the servo to 180 degrees.
A servo cannot operate by just adding power like a motor. It requires a controller circuit to send the PWM signal to tell it what to do. In turn you have to tell the controller circuit what you want with a switch or other electrical signal.
There are a few makers of servo controllers for the model train market including Tam Valley, MegaPoints and a servo driving kit from the Model Electric Railway Group (MERG). Each has its benefits and liabilities. By searching a little deeper I found a series of servo controller boards from Pololu called the Mini Maestro which had a very low price and afforded the flexibility I required. They come in 6, 12, 18 and 24 channel versions, allowing you to buy only as much controller as you need.
The Mini Maestros have a USB interface so they can attach to a computer/laptop. Servos can be run either directly from the downloaded Pololu software or a script can be loaded into the Maestro for automation. This allows me to adjust the characteristics of the board or tweak the program at any time.
The Maestro can be configured for automation of servo control, with inputs, outputs or both. The Boat Yard contains a double crossover and an interchange that should have an interlock. With the Mini Maestro I can program the actions of the interlock directly into the board and control it with a couple toggle switches on the fascia.
The last issue was how to mount the servos. After much deliberation I was able to determine that the module design I was using allowed me to use the plywood top as a fulcrum for the servos. The distance from the turnout to the plywood was just right. See my other article on free-mo module Design. With this knowledge I acquired a piece of 3/4 inch angle aluminum and cut it into 1.5″ in lengths.
After carefully measuring a servo, I created a template in Adobe illustrator to locate the holes required to mount the servo.
The template is affixed to the aluminum angle with spray glue and the holes drilled out. The servo then mounts with two small screws and uses the same piano wire that would have been used on a Tortoise. The end must be bent into an “S” configuration to hold position in the servo arm.
Sample Wiring and Code
The following wiring and code uses Channel 0 on the Maestro as an input and Channel 1 as a servo. These need to be configured in the Pololu Maestro Control Center BEFORE using the wiring diagram and the sample code provided or damage may occur.
Free-mo requires that all turnouts have controls on each side of the layout. I typically do this with toggle switches on each side. The wiring for this with a Tortoise is well documented. With the Maestro however you need to do things a little different. You could setup two inputs on the Maestro and create code to react when ever either input changes state. this might seem the way to go but I would tie up a lot of channels with this method. Instead I used a hybrid of the Tortoise wiring. Only the negative signal needs to be carried so I use a DPDT toggle for one side of the module and a SPDT on the other (or half of a DPDT). The following diagram shows how this works. You will need to set Channel 0 as an input and upload the appropriate code.
The following is the code to make the Maestro operate a single turnout in conjunction with the diagram above. Before using the code the correct values for the servo positions must be obtained. You can do this by connecting the Maestro to your computer and running using the Pololu Maestro Control Center to manually operate the servo. Note the values for each position. The value entered in the code is 4X the value shown in the status tab.
# When the script is not doing anything else,
# this loop will listen for switch position change.
# When a switch is thrown it runs the corresponding sequence.
input_0 if sequence_a else sequence_b endif
# These subroutines each return 1 if the corresponding
# switch is thrown, and return 0 otherwise.
# Currently switch input is assigned to channel 0,
# This channel must be configured as Input in the
# Channel Settings tab.
0 get_position 500 less_than
# These subroutines each perform a servo movement.
# You should change these to fit your application.
# Value used is 4X the value shown in the status tab
4000 1 servo
8000 1 servo
Next time I will review how I powered the frogs. Currently the plan is to use inexpensive low voltage relays but if that fails a SPDT micro switch may be required.