pierre52

During the construction of my new layout,  http://model-railroad-hobbyist.com/node/25098had to up my game when it came to using servos.  The staging area is in a very inaccessible location so I decided to automate the twenty turnouts using servos, Arduino and JMRI.

I have learnt a great deal during the installation process and thought that it would be useful to share. 

I have been documenting servo information on my build Blog as I went along but I felt it might be better to have all that information in one place.

If you have been reading my other blog, you may still find it useful to have a quick flick through this as I have updated various parts of the original blog as I have learnt more.

Peter

The Redwood Sub

Reply 0
pierre52

Not Just Turnouts

As others have shown, servos can be used to control all sorts of little animations on your layout from opening doors, people moving, railway crossing arms etc etc. The possibilities are only limited by your imagination.

With the right sensor an activity could occur on the layout that is started by the simple act of someone walking past.  With a random generator you could have two or more activities so the person walking past will never know what is going to happen.

At the end of this little tutorial I will publish an Arduino sketch that will control 1 servo with two push buttons and use two LEDs to show the current servo alignment.  The total cost for this will be less than $10.  I will also provide a full parts list and wiring diagram

Using the same board you could add on another two servos with same level of control

Peter

The Redwood Sub

Reply 0
pierre52

Some things you need to know about Servos

First some disclaimers:

  1. All of the following relates to analog rather than digital servos. 
  2. I am not an electronics expert so if I get the magic smoke bits wrong don’t sue me.
  3. All of my recommendations are based on using an HXT 900 or equivalent 0.4oz servo. http://www.hobbyking.com/hobbyking/store/__662__HXT900_Micro_Servo_1_6kg_0_12sec_9g.html

Servos have long been the domain of the radio control world whether it be in boats, cars planes or trains.  Proportional radio control simply means that a servo will move as far and as fast as the transmitter stick controlling it. This relies on a Pulse Width Modulated  (PWM) signal that is constantly telling the servo where it needs to be.

We do not need either the capability or price of digital servos for our purposes.  Unlike radio control gliders achieving world speed records of 513mph

If a servo isn’t moving or under load it draws about 9 mA (less than an LED).  When moving it is about 250 mA.  If the movement is blocked then the servo will stall and draw about 4 amps.

So what?

It means that the wiring requirements for servos are very light and we don’t need huge capacity power supplies unless the servo stalls.   Stalling is bad and to be avoided.   How do we know if an analog servo has stalled?

It hums.  (more on this later)

Servos develop torque and the torque rating varies according to the voltage input.  The higher the volts the greater the torque.  Normally, RC servos are designed to operate from a supply of 4 to 6 volts DC.  For our purposes let’s assume a standard 5 volts DC.  At 6 volts (max rating) our HXT 900 servo will produce a torque figure of 1.6kgf* cm or 22.21 ozf*in

A servo arm has lots of holes in it.  The further away from centre the greater the movement but the lower the torque.  For our purposes using a hole about mid way along the arm for is best.  Please note though if you are using multiple servos try and always use the same hole to avoid introducing unwanted variables.

Servos all come with a three wire lead.  The middle wire is always Red and this is where you apply 5 volts DC.  One of the other wires can be either Black or Brown and this is the ground wire.  The third wire is either White (Futaba) or Orange (JR) or Yellow (Hitec).  Irrespective of the colour this third wire provides the control in the format of a Pulse Width Modulated (PWM) signal.  If you want to know more about how servos work then there is a very good site here:

http://pcbheaven.com/wikipages/How_RC_Servos_Works/

Just be aware that leaving servos powered with no signal lead connected could result in random servo movements in both directions and to differing extremes.

If at all possible don't connect a servo to power unless it is also receiving a valid signal.  This lesson is well known in RC circles where it is often emphasised that the transmitter should always be turned on before the receiver and vice versa.  

Peter

The Redwood Sub

Reply 0
pierre52

Variables

When using servos for turnout control we need to be aware that there are a significant number of variables. If we are to avoid making life difficult for ourselves  then we need to eliminate as many of those variables as we can.  When programming an Arduino sketch we need to know three things for each servo: 

  1. Where we want the servo arm positioned when we apply power
  2. What the anticlockwise extreme of travel is, and
  3. What the clockwise extreme of travel is.

nting(3).JPG 

If you look at the photo above, I have shown that servos can be installed under turnouts in four possible ways.  The arrow in each case indicates clockwise travel of the servo.   However, as the only thing that matters is the way the servo arm moves then we can discount two of the possibilities which leaves mirror image installation as the relevant option.


Variable 1 - Dependent on installation position servos, may move in the opposite direction.  You might like to think that we could eliminate this problem by installing all of our servos facing the same direction.  Nice thought but believe me Mr Murphy has other ideas.

Variable 2 – Different servo brands rotate in different directions.  This variable can be avoided by using the same brand of servo throughout your installation.

Variable 3 -   Left Hand and Right Hand Turnouts have the Closed position on opposite sides.  If we are clever then we can use Variable 1 to our advantage and eliminate this problem.  However, don’t forget Mr Murphy may have different ideas. 

Peter

The Redwood Sub

Reply 0
pierre52

How much servo travel do we need

To answer this question, I set up a turnout/servo combination under lab conditions (Well as lab like as I could manage) with the actuating rod set at 11mm from centre on the servo arm.  

Note that most servos have a possible travel range of 180 degrees.  It would be extremely rare to see the full range of travel used.  Nonetheless it gives us a convenient mid-point of 90 degrees.  In most situations we should endeavour to set up a servo on its mid point.

The results of the lab test are shown in the drawing below.

20Travel.jpg 

To move the points from one side to the other we only need to move the servo arm 10 degrees either side of centre or 20 degrees in total. It is important to note that there is little to no force holding the point against the stock rail at this degree of travel.  If we left it here we could cause derailments.


To provide adequate holding force of the point to the stock rail, we need to double the overall travel to 40 degrees.
If the arm is moved further to 40 degrees past centre then the servo will start to hum.  That therefore gives us a sweet spot of about 20 degrees between locked and humming or stalled.

Extrapolating  those results to Arduino sketches using servos to control turnouts,  we need to determine  a start position, a max left position and a max right position.  Logically, for a turnout, the start position is going to be the same as either max left or max right.

If we take 90 degrees as the mid-point then 70 degrees should be a good starting point for Max Left and 110 degrees  for Max Right.   Just be aware that if you invert (mirror) the drawing then the values for max left and max right will be reversed.  Also note that if you move the actuating rod further away from the servo centre then you would need less travel but you will end up with  less torque applied to the rod.   If you move the rod the other way then the reverse applies more travel required and greater torque applied.

Where you set the start position will determine if the turnout is closed or thrown when the power is first turned on.

Well that was (in the words of Stephen Fry) "Quite Interesting".  Next time I will look at making mounting brackets and installing servos.

Peter

The Redwood Sub

Reply 0
Mnemonic

Class is in session . . .

. . . and I'm eagerly awaiting the next installment! Thanks.

Reply 0
Paul Jacobsen

very helpful

Thanks!

 

age(26).jpeg 

Ranger -- Fort Jacobsen

Scenic Designer FJRR

Track Crew FJRR

my blog

​

Reply 0
tomebe

servo's

Thanks Peter for starting this - I have several Train order signals that I want to control on my layout and I'd like to use servo's. Looking forward to the rest.

Tom Ebert

Reply 0
DBodnar

Servo Tester

Gents - if you are working with servos you should consider investing $1.24 (including shipping to the US) for a pretty capable servo tester - see:

http://www.ebay.com/itm/Multi-Servo-Tester-3CH-ECS-Consistency-Master-Checker-Speed-Controler-CCPM-EA-/281740016082?hash=item41990379d2:g:zqUAAOSwDNdVlpHS

I got a few of them and they allow you to exercise and do simple tests on servos - I suppose you could even use a group of them to control turnouts operating with servos - recommended!

dave

Reply 0
pierre52

Good idea but...

Dave the servo tester is a great idea but a couple of cautions.  If you use these for controlling turnouts on your layout remember that we only need 20 degrees of servo travel either side of centre to change the turnout from closed to thrown.  Using one of these you can easily get more than 45 degrees of travel (possibly 90 degrees) either side of centre. If you apply too much servo travel the actuating wire can twist itself out of the turnout throw bar and prevent the turnout operating.  Ask me how I know 

If you use Arduino to control your turnout you need to know how much servo travel to apply each way.  One of these testers will give you a very good idea but it will be a calibrated eyeball guess of how many degrees it has moved.

On the other hand, one of these is perfect for ensuring that your servo is centred during installation.

Peter

The Redwood Sub

Reply 0
pierre52

Making Servo Mounts


In this post I want to describe how I go about making my own servo mounts.  This is not intended to be prescriptive as methods for this are as numerous as you want them to be.  Suffice to say this is how I go about it. 

This first photo show a completed servo and mounting block ready for installation.

%20Servo.JPG 

I have since modified this slightly as I find that servo leads and chocolate block connectors  are not a good combination if you need to unplug the servo to change anything.   I now make up little plug in connectors as shown below.

o%20Plug.JPG 

 

 

 

Peter

The Redwood Sub

Reply 0
pierre52

Parts Required

Labelled.JPG 

Servo:   Practically any servo can be used so long as it has a torque value of at least .5kg.  For the best price/reliability/size, my preference and very strong reccommendation is to use HXT 900 servos from here http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idproduct=662  These have a Torque figure of 1.6kg and cost US $2.69 a pop. 

Whatever you use,  if you need more than one make sure you use the same type.  Why?  Because different brand can operate in different directions and that can cause all sorts of problems.

Mounting Block:  Nominal size 2”(50mm) x 9/8”(30mm).  Each block can be cut from scraps of 3/4” finished thickness softwood.  ¾” is a good match for the HXT 900. If you use different size servos you will need to adjust the thickness accordingly.

Control Wire:  I use K&S music wire .025” (.6mm) diameter. K&S stock number 500.  This is quite critical as the size has to have the right flex plus it need to fit the holes in the servo arm

Base Plate:  Nominal size 2”(50mm)  x 1.5” (40mm) x 1/16” (1.5mm).Material is somewhat critical as the control wire needs to be able to flex back and forth through a .04 hole drilled in the plate. My preference and very strong recommendation is 1/16” thick aluminium. I have also used 1/16” Formica but over time the operating hole will start to enlarge and may cause operating problems. 

You should be able to source that thickness aluminium from any big box hardware store.  At a pinch you can also use an oven cooking tray. Just check with SWMBO (She who must be obeyed) before pinching it.

Peter

The Redwood Sub

Reply 0
pierre52

Mounting Block cut outs

Two notches need to be cut into the timber block.  The first is to accommodate the length and depth of the servo body.  The more precise you can make this the better as a tight fit prevents the servo trying to rotate as it is operated.  I use a scroll saw to cut the notch but you could also use a hand saw for the two cross grain cuts and a chisel for the along grain cut

The second notch is needed to accommodate the servo lead.

t%20outs.JPG 

 

Peter

The Redwood Sub

Reply 0
pierre52

Assembly

I drill 2 x 40 thou holes in the base plate and then attach it to the mounting block with polyurethane glue and 2 panel pins. Once dry I drill two 5/32” holes through the block and base plate in the positions shown in the photo below. These holes are for mounting the servo to the baseboard using 2 x 6ga x 1.25” screws.%20Holes.JPG 

I then drill 2 x 1mm holes and screw the servo in place with the provided screws.  The servo arm can then be fitted but making sure that the arm is at 90 degrees to the servo when the servo is at mid travel. (The servo can be gently rotated with the servo arm in place).


Drop a piece of music wire through the servo arm and mark the position for a 1mm hole in the base plate.  The next two photos show how to bend the wire to hold it in place in the servo arm.  The tips of modeller's needle nose pliers are about the perfect width of the U (about 1/16”). 

0Bending.JPG 

Once the u has been fitted through the arm, the U can be closed up to hold the wire in place

ding%202.JPG 

At this point the servo is ready to be installed on the layout.  I will go through the installation procedure in a later post.

Please note that the preceding parts and mounting instructions are optimised for controlling turnouts.  This is by no way the only means and using servos for different applications will probably require an entirely different approach.

There are also plenty of commercial options out there such as Tam Valley (MRH sponsor).  You might also convince Bill Brillinger to come up with a Laser cut design.

Peter

The Redwood Sub

Reply 0
baggetta

great topic

This is a great series.  I'm looking forward to learning more about servos for use on my layout.

 Thank you

 

 

Reply 0
Ironhand_13

Great job Peter

Very thorough, nice pictures too.  

I've converted most of my Blue Point turnout controllers to servos, but I do have a 'back-burner' project to open a set of engine house doors with a single servo...if I can think it through.  Bell cranks maybe?

-Steve in Iowa City
Reply 0
pierre52

@Ironhand_13

Opening your engine house doors would be a perfect application.  By using a cheap Arduino board not only can you easily control how far they will open but also at what speed. 

I am presuming that you have a pair of doors that need to open at the same time.

A mechanical arrangement of Bell cranks would do it but let me open up another option for you called The Rotary Driver System (RADS) designed by an amazing guy called Harley Michaelis.  It was designed to drive ailerons in RC Gliders. Not only did it it give a huge mechanical torque advantage but the system could be concealed entirely within the wing saving on drag.

http://www.charlesriverrc.org/articles/construction/harleymichaelisrads.htm

We don't need the full RAD system here, just the couplers which provide direct axial drive from the servo.  With that all you would need is a brass rod connected to the bottom of the door, running down through the baseboard in a brass tube to the servo.

Harley has provided some home brew couplers here:

http://www.charlesriverrc.org/articles/construction/harveymichaelis_couplerideas.htm

or you can buy ready made ones here:

http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=LXNN07

 

If it were me I would use two servos with RAD couplers connected with a Y lead.

Hope that helps

Peter

The Redwood Sub

Reply 0
pierre52

Installing Servos

When I first started using servos on my previous layout, I wasn’t that careful about how I went about it and ended up paying the price later.  I also went through the fun of having to install the servos on bench work that was already fixed in place.  Anyone who has mounted Tortoise point motors while lying on their back underneath a railroad will know what I mean by “fun”.  It was very much a two person job and my wife became very adept at directing  piano wire through ridiculously small holes.

Because I didn’t pay too much attention to accuracy, I had problems when it came time to adjusting the servos to operate reliably and without humming.

Suffice to say I have learnt a bit and developed methods that do make things a bit easier.  First though a bit more theory.

Start position, end points and rate of travel.  For our situation there are three things that we need to be concerned about. What we want to do is move our turnout throw from securely closed to securely thrown in a linear motion and then back again.  The end points never change but it would also be quite neat if we could control the speed at which the points moved.   When we turn the power on it would also be nice to think that all of our turnouts are going to move to a pre-determined start point either thrown or closed.  Without going into the science can we accept that servos will have a normal start point at one end of their possible travel and can then move through a maximum of 180 degrees to the other end point.   Using magic smoke, we can change that start point to the other limit of travel.  We can also change the end points and reduce the amount of travel in either direction.

Arduino normally moves servos by stepping them one degree of travel at a time with a short pause between each step.  We are talking milliseconds here so at normal speeds that step process isn’t really visible.  The pause time is defined in the programme and can be adjusted to anything you want. That adjustment therefore determines the speed of travel.

Think about these three things as we go through the installation process

Peter

The Redwood Sub

Reply 0
pierre52

Step 1. Draw some lines

Before we actually lay any track it will make life a lot easier if we can determine exactly where our turnouts need to go and then mark the exact point where the throw bar hole crosses the track centre line.

ting%201.JPG 

 

Peter

The Redwood Sub

Reply 0
pierre52

Step 3: Drill a bigger hole

Now that we know exactly where the servo needs to be mounted, we can drill a bigger hole to allow the wire to travel from end point to end point.  I have seen people drill 3/8” or larger holes but if you are careful with alignment then a ¼” diameter hole should be more than enough.  If you really want to be fussy then you could cut a slot rather than drill a hole.

%203%20b.JPG 

When you fix the servo back in position the wire should be centred perfectly in the hole. 

ting%203.JPG 

If we move the servo one way it should move to the opposite side of the hole but still be on centreline and if we move it back the other way we should still be on the centre line

Note that we don’t have to move the servo arm very far (less than 45 degrees) before the wire touches the edge of the hole.  If we move it further (see below) then the wire starts to bend, the servo will be stalled and we will start drawing lots of amps = BAD


Once the wire has been trimmed to the correct length(not yet though), if we use any more travel than 45 degrees then we risk twisting the wire right out of the turnout’s throw bar = REALLY REALLY BAD

ting%204.JPG 

Peter

The Redwood Sub

Reply 0
pierre52

How much servo travel do we need

ting%206.JPG 

If the alignment is good then we only need about 20 degrees of servo travel to get the wire to move the points snug into place. Take note of the extra wire above the turnout.  Having the wire this long makes fitting the turnout a lot easier.  It can be trimmed to the right length once you are sure that everything is working correctly.

Peter

The Redwood Sub

Reply 0
pierre52

Fitting the turnout

When it comes time to fit the turnout, make sure that the servo is centred and fit two scraps of 1/16” styrene either side of the points to hold the points in a central position.  Make sure you take those bits of styrene out before you attempt to operate the servo

ting%207.JPG 

Manually move the servo arm a few times and make sure the turnout is operating correctly.

Now is a good time to connect everything up and check that your automated control also works correctly.  Does the turnout go to the correct position when power is applied?  When you throw the turnout does it go to the correct position?   Are the points secure against the stock rail in both closed and thrown positions?  Does the servo stay in either position without humming?  Remove and apply power several times and cycle the servo several times each time. 

Once you are happy that everything is working as it should, fit the second screw to the mounting block and trim the wire to length (about 1mm above the throw bar – anymore and it may snag couplers or trucks).  

Job done

Next time I will look at using a Tam Valley Quad Pic to control your servo.  Not sure when that will be as I have some other stuff to deal with over the next week or so.

Peter

The Redwood Sub

Reply 0
Virginian and Lake Erie

Peter, you are becoming the

Peter, you are becoming the master of the servo. I would add that in addition to couplers one needs to look at locomotive gear boxes in trucks of diesels and in some steam locomotives as they protrude below the rails. I have had derailment issues from switch wires that cleared couplers but not gear boxes. If you do not operate any of these models that is fine but I tend to get the wire very close to the ties. That may be your millimeter I can't think in metric.

Reply 0
Greg Williams GregW66

Advantages

I am intrigued by the use of servos for turnouts. As I am planning, I am wondering what the advantages are over a tortoise machine? Is it mainly cost or are there other advantages?

Greg Williams
Superintendent - Eastern Canada Division - NMRA
Reply 0
Jim at BSME

Under table mount and arduino control comment

I am sure there are many sources for under table mounts if you don't want to buy build your own.  I'm going to mention one I've used from a MRH sponsor. It is the under table mount from Berrett Hill Trains, you can see it here:  http://www.berretthillshop.com/store/products/servo-ut-mount/. They also offer an above table mount, but I have not used it and it does require quite a large hole (1-5/8" / 41.275 mm)  http://www.berretthillshop.com/store/products/servo-cradle/

From reading Geoff Bunza's blog, he has found for his applications that power can be removed from the servo in the Arduino code to reduce power consumption.  You detach the servo after moving it to the desired position and there is enough mechanical resistance in the drive to hold things in position.

EDIT: Just in the interest in full disclosure Kevin the proprietor of Berrett Hill Trains is a friend of mine, but I have no financial involvement in his company other than as a small time customer.

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: Facebook, Instagram
Reply 0
Reply