Using Servos on Your Train Layout

By Fred Sotcher, San Jose, CA

Your Personal Online Train Store and Hobby Shop

While I have created a lot of various models, I just started my layout last year, so I am new to the model railroad hobby. I have used servo motors in several projects including a cuckoo clock with some 15 servo motors and my current train layout that uses six servos for carnival rides and traffic gates. On my cuckoo clock I have men performing various woodworking tasks like cutting, planing and nailing wood. On the train set I have carnival rides stopping to allow people on and off and operating at various speeds. It occurred to me that with all the creative people working on model train layouts that there could be a lot more applications for servo motors. I did note that Don Ball did make good use of them in Operating Quadrant Signals (MRM February 2015).

Servos come in two types: They are continuous rotation and limited rotation servos. They are available in a wide range of sizes and output capacities with prices ranging from $6.00 to $300.00. The servos are operated with controller boards that come in four sizes, the smallest operates 6 and the largest up to 24 servos. The initial setup and programing are done by connecting the control board to a computer through a USB port. For my traffic gates project, I selected two of the $6.00 servos and a $20.00 six-channel control board. I will be using two channels to control two traffic gates and two channels for inputs. The supplier I use (Pololu Maestro) offers a very detailed manual, a forum, a blog and very responsive technical support. (www.pololu.com)

 You start out by downloading the free software program then connect your control board with a USB port and a mini-B connector (not included). A 5-12 VDC supply is connected to the board to power the servos. Each of the channels can be programmed as a servo control, an input or an output. The control board stores the program; once programmed the system can operate from the power supply alone. You will want to study the “Pololu Maestro Servo Controller User’s Guide" that is available on-line.

 Once connected a screen appears that allows you to control the speed, the direction and the position of each servo. When using the limited rotation servo, the mouse-operated sliders allow you to establish the limits of rotation. With continuous rotation servos these same sliders control the speed and direction of rotation. Note that speed “1” is the lowest speed, not “0”.

The Status window allows you to set the speed, direction and position of each servo in each frame.The Status window allows you to set the speed, direction and position of each servo in each frame.

Each of the channels can be assigned a name and function.

The Channel Setting menu allows you to name each channel and define its functionThe Channel Setting menu allows you to name each channel and define its function

Once you have established the frames you desire, you can operate your program, go to the sequence menu and establish a time for each frame and then operate them in sequence. You can also establish several sequences if you wish.

On the Sequence menu you set the duration of each frame and establish various sequences if you wish.On the Sequence menu you set the duration of each frame and establish various sequences if you wish.

If you wish to provide input signals, get output pulses or create a far more detailed program, you can copy the sequence you created to script. This is the script I created to operate my two crossing gates:

beginbutton_up if sequence_Gates_Up endif button_down if sequence_Gates_Down endif repeat #these subroutines each return 1 if the corresponding #button is pushed and return 0 otherwise,#channel 0 and 1 are assigned to servos for gates#Channel 3 (UP) and 4 (DOWN) are assigned to buttons or relay #contacts to open and close gatessub button_up3 get_position 125 less_than return


sub button_down

4 get_position 125 less_than return

### Sequence subroutines: ### # Gates Down

sub sequence_Gates_Up

5000 8000 8000 0 0 frame_0..2_5 # Frame 0 return

 

# Gates Up

sub sequence_Gates_Down

5000 3968 3968 0 0 frame_0..2_5 # Frame 0 return

 

sub frame_0..2_5 5 servo

2 servo

1 servo

0 servo delay return

With the script you can provide for inputs and outputs and create special operations.

Note that if you wish to use inputs you will want to connect a 10,000 ohm, ¼ watt pull-up resistors between the input and the + terminal so your input pulls the input terminal to ground. Once you have copied the sequence to script, any changes must be created in the script, not the operating menu. As I have no programming experience, I found creating the program I wanted in the script a challenge, but I got through with the help of the manual and a programming friend. Be sure to download the manual found under the Help menu.

My layout is supported on ¾-inch plywood with a two-inch-thick foam board on top, so I made a small model as shown to allow me to test out the design before mounting it on the layout. I was able to purchase a bunch of used crossing gates on E-Bay and mounted them on some signals that I had. The servos were mounted to holders that I fabricated. I then connected the servos to the gates with connecting rods. Two SPST NO push button switches act as inputs (they will be replaced with control relays).

Model used to test crossing gatesModel used to test crossing gates
Servo mounted on a holder under the gateServo mounted on a holder under the gate
One of the servosOne of the servos
The six-channel servo control board that I used.The six-channel servo control board that I used.

With the crossing gates there are only two frames – “Gate Open” and “Gate Closed” so I created two sequences with inputs for each then copied them to script. I checked the “Run script on startup” option.

The crossing gateThe crossing gate

As I said I am not a programmer but if I can assist someone in using servos, I would be glad to try and help. I can be reached at fsotcher@gmail.com


You might also like these pages:

Back to Home Page



Contact Me | Blog | Photos | References | Supplies | GiftShop | Sitemap | Search | Comment  | Privacy Statement  | Disclosures

Train Logo for Building Your Model Railroad
BYMRR (Building Your Model Railroad) logo

Tracks Newsletter: Sign Up Here!


New Logo for Building Your Model Railroad
Follow BYMRR
Follow Us on Facebook
and Instagram

Link to Building Your Model Railroad Hobby Central Train Station Store

(Disclosures)

√ = ad or sponsored link


What's New on BYMRR.com?

Recent Articles

  1. Model Railroader Crossroads

    Oct 17, 21 06:41 PM

    This page is dedicated to the Model Railroader Crossroads community for the purpose of sharing information about model railroading.

    Read More

  2. Railroad Networks of the World

    Oct 14, 21 07:00 AM

    Railroad Networks of the World If you are looking for a prototypical railroad upon which to base your layout design, you may want to consider using a combination of two resources. The first is to loca…

    Read More

  3. How to Make Water with Toilet Paper

    Oct 12, 21 08:57 AM

    Read More