Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Using servos and Arduino to control turnouts?

11232 views
11 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    December 2014
  • 18 posts
Using servos and Arduino to control turnouts?
Posted by joecatch on Monday, March 6, 2017 1:44 PM

Thinking about building an HO layout and I would like to use my knowlegde of the Arduino to control the switch machines for the turn outs using servos. Servos are cheap and can be programmed very easily with the Arduino with them mounted under the table. Will this work? I am thinking that the servo uses a circular motion and a switch machine uses linear so I am not sure if this would work.

 

JC

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Monday, March 6, 2017 3:22 PM

greg - Philadelphia & Reading / Reading

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, March 6, 2017 4:15 PM

One of my many projects is to cut over to servo switch machines.  I bought SG90 servos of eBay at $1.41 each in bulk.  I have one operational on my work bench, silent and powerful.
 
I’ll be using an Arduino MEGA to drive 21 turnouts.  My layout is HO and the majority of my turnouts are Atlas Custom Line with #65 switch machines mounted under my layout, the servos will also be installed under the layout.
 
I have a few Pico curved turnouts that use Pico PL10s and at this time I’m not planning to change them out to servos, they are only a few years old and working very good.
 
My main reason for swapping out the Atlas switch machines is that they are over 25 years old and beginning to show their age.
 
The Arduino works very good and I can tweak each turnout individually.  I do not plan on using the Arduino as a position indicator, I’m going to use DPDT switches to control the Arduino and the turnout indicators.  I’m keeping is simple.
 
 
EDIT:
 
I use aircraft type bellcranks between the servos and the turnout for positioning the throw rod and to gain a little more torque.  I use 6 x 32 x ” long nylon screws as a throw rod holder.  I drill a #61 hole lengthwise through the screw to hold the throw rod.  I use .040” music wire for the throw rod, it fits snug in the screw, no glue needed.   I tap the hole in the end of the bellcrank for the 6 x 32 nylon screw, the tapped nylon hole remains slightly smaller than a tapped metal hole and grips the nylon screw tight enough that it doesn’t need any adhesive.
 
The picture doesn’t really show the bellcrank screw very well but it’s the only picture I have of my contraption.  The bellcranks do work very good.
 
 
 
 
This is my only Tortoise switch machine and it is powering four Atlas Custom Line #6 turnouts in myHome Brew Double Crossover.  I am going to replace it with a servo down the road.
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Monday, March 6, 2017 8:30 PM

 That's some complex linkage. You don;t really need anything nearly that complex. There are several mounts, or you can make one with 2 small blocks of wood, to screw the servo to, and drill a small hole for the wire to pass through. Then you drill a larger hole (like for a Tortoise) under the throwbar and stick the servo with the wire going up the hole into the throwbar. The servo turning with the wire goign through the small hole will make the wire wiggle back adn forth just like a Tortoise.

 Or you cna go even simpler - drill hole, use Gorillar glue to glue servo on it's side with the horn (the plastic piece that goes on top of the servo's shaft) lines up with the throwbar, piece of wire through the throwbar and onto the horn.

 I use to get mine on ebay but I've now seen servos at that price point on Amazon with Prime shipping, so no waiting. It's insane how cheap they are, and driving them with an Arduino is incredibly easy. There's a lot of examples you can copy and just use, no need to learn to code, just hook up the wires like shown in pictures and off you go.

                              --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, March 6, 2017 9:36 PM

Randy
 
I started out using .020” rod and it didn’t cut the mustard as a long push rod.  .030” rod was still flaky so I ended up using .040” rod.
 
I had gone out on a limb building my own double crossover and decided to continue going overboard by building a ¼” Acrylic sub base to keep everything in alignment.  I had several large pieces of ¼” clear Acrylic sheet on hand.
 
I built everything up on my workbench and when I had it working perfect installed it on my layout.  It has worked flawlessly for about 7 years.
 
I got onto using bellcranks about 10 years ago when I started having problems with the old Atlas under the table switch machines.  I went with DuBro bellcranks early on and they have worked out so good I stayed with them.
 
I rarely under engineer anything, I’ve always gone overboard . . . . no such thing as too much power on my layout.
 
I’d tried a box full of manufactured double crossovers (code 83) over about 15 years and none of them would pass my Rivarossi Cab Forwards without problems (Pre RP-25).  The last one I tried was a Fast Tracks and when it wouldn’t work that was the last straw.  All of my Cab Forwards would clear the Atlas Custom Line turnouts without any problems so I built my own from Custom Line #6s.
 
The cheapo servos (SG90) are marginal operating two turnouts so if I do swap out the Tortoise I’m going to use a large scale Airtronics servo for my double crossover.  The Tortoise is working fine and because it isn’t the easiest thing to get to I may leave it in.
 
You’re correct about the Arduino, mine worked first shot without any problems.  I’m planning on using IR detection to prevent hitting an open turnout, the MEGA has plenty of capacity to handle automation.
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Tuesday, March 7, 2017 6:27 AM

 My mounts are the old resin ones made by Motrak but they are functionally identical to the wood SwitchWrite brackets that Tam Valley sells:

http://www.tamvalleydepot.com/products/servosaccessories.html

These worked fine for me with .032 wire (I had to buy my own though, the supplied piece was too short) through my previous layout which was 1/4" plywood with 2 sheets of 2" foam on top - for 4 1/4" plus cork roadbed to the throwbar. Solid springing of the points against the stock rail even with just .032 wire. The way the brackets work witht he servo is you don;t even have to set end limits, you just go fully end to end, and the wire is pushed somewhat over center so even if you turn the servo off, force on the wire won't move it.

 SG90 servos are so cheap - for crossovers I just hooked 2 of them to the same output. No sense engineering all sorts of linkage plus using a more expensive servo. There is practically no power consumtion on the signal line, so one controller output can easily drive 2 or 4 servos, the power all comes via the power pins on the servo connector. The Arduino-based controller I am designing has 2 different power connections, one feeds the electronics and the other feeds only the servo plugs.

 I'm using Peco turnouts this time, and I have one I've been using to test my circuit, I have the servo stuck to the bottom of the turnout with double sided tape, about where the Peco solenoid would clip on, but still in the Motrak mount. There's only the thickness of the resin to act as a lever pivot yet it still moves plenty far to fully engage the points with a strong holding force, and my code just runs the servo from 5 degrees to 175 (since response to the pulse train can vary a bit, I left a little headroom at each end). This is not really practical for layout use unless I want to carve out big pits under each turnout, but it does serve as a bit of proof of concept - the spring is still installed in the Peco turnout, yet the .032 wire moves it just fine.

                            --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Tuesday, March 7, 2017 9:35 AM

rrinker

 

 SG90 servos are so cheap - for crossovers I just hooked 2 of them to the same output. No sense engineering all sorts of linkage plus using a more expensive servo. There is practically no power consumtion on the signal line, so one controller output can easily drive 2 or 4 servos, the power all comes via the power pins on the servo connector. The Arduino-based controller I am designing has 2 different power connections, one feeds the electronics and the other feeds only the servo plugs.

 

                            --Randy

 

 

Thanks for the info about paralleling servos, I didn’t even give that a thought.  That really simplifies crossovers as well as save ports on the MEGA.
 
As a matter of interest do you power your Arduinos from 5 volts or the 7 to 12 volt connector?  I’m using the 7 to 12 volt connector for Arduino power and a separate power source for accessories.
 
I don’t trust operating the Arduinos without their internal current protection.
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Tuesday, March 7, 2017 11:08 AM

 I run them on 5V. At the bench I just connect to my bench power supply. The power supply connect to my breadboard and I just jumper the power rails to the +5 and gnd pins on the Arduino. That way there is no chance I am trying to power the servo with the Arduino's regulator - it can't handle it. With just one servo, I set my meter on peak hold and got almost .6 amp if I restrained the servo. That would just melt the Arduino's regulator. When I deploy this Iwill probably have a 12V bus on my layout and use some cheap buck converters to regulate down to 5V, the ones I found and am trying out are good for up to 2 amps, so should easily handle 2-4 servos, and to keep noise out of the Arduino I will have a second one, or maybe just use a 7805 voltage regulator, to get 5V for the Arduin and support chips.

                          --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Tuesday, March 7, 2017 12:52 PM

rrinker

 When I deploy this Iwill probably have a 12V bus on my layout and use some cheap buck converters to regulate down to 5V, the ones I found and am trying out are good for up to 2 amps, so should easily handle 2-4 servos, and to keep noise out of the Arduino I will have a second one, or maybe just use a 7805 voltage regulator, to get 5V for the Arduin and support chips.

                          --Randy

 

 

I’ve experimented with the DC to DC converters for a couple of years.  The early converters didn’t do well at regulation.  I finally found some high power (8amp) that work extremely good with great regulation (± .05 V).
 
 
I now have three mounted and in service working perfect off a 12 volt switching power supply.  1) set to 1.45 volts for all of my 1 volt micro bulbs, 2) set to 5 volts, 3) set to 9 volts for structure lighting.  My structures have been around awhile, all use 12 volt GOWs.
 
 
 
  
 
The convertors work very well with hardly any heat dissipation even at high current.  I was using regulators but at high current they get very warm.
 
My Arduino card shelf is working out very well.
  
 
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Tuesday, March 7, 2017 1:09 PM

 I have some of these little guys

http://www.ebay.com/itm/201465740515?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I don't think they can do 3 amps, not without a heat sink, but 1-2 shoud be fine. The output hold steady ove a wide variation on the input voltage. I need to hook one to my scope and see if they are noisy.

                      --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    August 2015
  • 371 posts
Posted by fieryturbo on Thursday, March 16, 2017 3:09 PM

You want this article to get started:

http://thenscaler.com/?page_id=174

I'm doing the same thing.  Ten for the price of one Tortoise, you can't beat it.

Julian

Modeling Pre-WP merger UP (1974-81)

  • Member since
    December 2014
  • 18 posts
Posted by joecatch on Thursday, March 16, 2017 3:17 PM

Excellent, that is a great article on the Arduino. Everyone here has been so very helpful!

JC

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!