Jump to content
 

Recommended Posts

Servos for radio control models are surprisingly inexpensive and it's hardly surprising that these are being applied to control the points, signals and many other moving elements on model railways. Many full-featured electronic controllers are available from a large number for suppliers. However, some people have had disappointing results with servos while others are adamant that there are no problems using servos on model railways at all. If you happen to belong to the latter group I suggest you stop reading this topic now.

 

For those who might have experienced problems, here is a possible solution. The circuit diagram is below. An explanation and the validation details follow.

 

post-25691-0-58419000-1490766640.jpg

 

Hopefully the diagram is fairly self-explanatory. It revolves around a 4N25 optocoupler (also known as an optoisolator) and a couple of resistors. I used a 4N25 because I happen to have a lot of them, but there are other types available that might be quite suitable and less expensive. I'm not going to go into a long explanation of why this works. The main points are that the signal connection between the controller and the servo is only by transmitted light and any interference that impinges on the long twisted pair tends to be cancelled out because the current in both sides of the twisted pair is equal and opposite. It's a well-known technique that's been around for ages. (I left the cable untwisted on the diagram for clarity only.)

 

The diagram also indicates that the servo power supply and the controller power supply are completely independent. They need not share a common return (although they can) and they need not even operate on the same voltages. I would not recommend it, but If you wanted to be perverse the servo supply could even be negative relative to the controller supply.

 

I created a pretty nasty to test to prove this works. I drive the servos from a very simple controller based on an Atmel micro-controller. I used a 33 foot extension between my controller and a standard servo and found that I could make the servo twitch significantly every time I started the florescent tube above my work bench. I could also produce twitching by switching on my scope and electric power tools, but the fluorescent light always made the servos twitch.

 

Since I inserted the 4N25 circuit between the controller and the servo I have not been able to produce any servo twitching at all. I've repeated the experiment about ten times and exercised the light-switch several hundred times.

Edited by AndyID
  • Like 7
Link to post
Share on other sites

Andy,

Did you shorten the Servo cable for this?

regards

 

Keith,

No, it passes my test with normal length servo cables, but I would always recommend minimizing the cable length between the optocoupler and the servo if possible, particularly in very noisy environments. Ideally you'd want the optocoupler integrated into the servo itself, but unless someone sees a significant business opportunity associated with that I think it's unlikely to happen.

Rgds,

Andy

Link to post
Share on other sites

The main points are that the signal connection between the controller and the servo is only by transmitted light and any interference that impinges on the long twisted pair tends to be cancelled out because the current in both sides of the twisted pair is equal and opposite. It's a well-known technique that's been around for ages. (I left the cable untwisted on the diagram for clarity only.)

 

Which applies equally well to non-opto isolated connections. Simply twisting a normal servo cable will help.

  • Like 1
Link to post
Share on other sites

Would wrapping the cable around a ferrite core help cure twitching?

It might help in some situations but I don't think it would be sufficient for my needs. I want a solution that completely eliminates twitching and this seems to do the trick. It will require a bit more work and and a small amount of additional expense but I believe it's worth it. I know not everyone will agree with me :)

Link to post
Share on other sites

Which applies equally well to non-opto isolated connections. Simply twisting a normal servo cable will help.

 

You and I both know it helps but can you quantify how much it helps? Will this make servo point motors as reliable as, say, Tortoise point motors?

Link to post
Share on other sites

Twisting the wires without the isolator has a limited effect because the impedance loading the wires is different between the signal wire and the others. It can never be a complete solution.

 

As for ferrites they will only have an effect against induced RF which is only likely to be a problem if you have radio transmitters nearby that are causing interference - most unlikely.

 

The isolator is an excellent idea and attached to the servo with the servo wire neatly bundled it should be completely immune to interference picked up by the wires.

Link to post
Share on other sites

Thanks Suzie.

 

I'm a bit surprised nobody has tried it before. Maybe they have?

 

One slight concern is the current the controller has to sink. I've made it fairly high. It's well within the sink capability of the micro-controller I'm using, but it may be too much for some of the servo controllers on the market. It could be reduced of course, but that might also reduce the noise immunity. It would take a bit more experimentation to find out.

 

Now "all" I need to do is find a way to get the PCBs for a reasonable price. I don't fancy making dozens of these things on Veroboard.

 

Rgds,

Andy

Link to post
Share on other sites

I think that people trying to run servos over long cables on layouts is a new thing - previously servos on layouts were a bit niche and the only people using servos would have been those with a good understanding of the shortcomings of long servo cables, and most servo controllers would only do a handful of servos rather than a whole layout like the Megapoints so it was easy to position the controller near the servos.

 

The PCBs will be quite small. probably need to get a few in a row on a snap-out panel.

Link to post
Share on other sites

I can't see how an isolator brings anything to the party. In fact depending on the sensitity of the opto if could increase the sensitivity of the circuit to interference. Also when the Op is off , depending on the output characteristics of the. Micro , this could actually leave the op floating or via a weak pull-up. On MERGs board a good strong pull up was needed. Note that as this is not a balanced line driver , interference is not injected equally and hence the CMRR is not great.

 

Separating the servo supply from the micro is a recommended idea , but that doesn't need a opto. In the circuit above , it's likely that's there is a common supply somewhere so you need to be careful about ground loops and ground paths for the high current servo pulses

 

The " test " that was performed isn't really any indication of the opto doing anything , what had you there before the opto was added.

Edited by Junctionmad
Link to post
Share on other sites

  • RMweb Gold

Thanks Suzie.

 

I'm a bit surprised nobody has tried it before. Maybe they have?

 

One slight concern is the current the controller has to sink. I've made it fairly high. It's well within the sink capability of the micro-controller I'm using, but it may be too much for some of the servo controllers on the market. It could be reduced of course, but that might also reduce the noise immunity. It would take a bit more experimentation to find out.

 

Now "all" I need to do is find a way to get the PCBs for a reasonable price. I don't fancy making dozens of these things on Veroboard.

 

Rgds,

Andy

Precut vero for DIL chips? http://www.maplin.co.uk/p/veroboard-copper-dil-stripboard-381x2146mm-fl17t

 

Andi

Link to post
Share on other sites

I can't see how an isolator brings anything to the party. In fact depending on the sensitity of the opto if could increase the sensitivity of the circuit to interference. Also when the Op is off , depending on the output characteristics of the. Micro , this could actually leave the op floating or via a weak pull-up. On MERGs board a good strong pull up was needed. Note that as this is not a balanced line driver , interference is not injected equally and hence the CMRR is not great.

 

Separating the servo supply from the micro is a recommended idea , but that doesn't need a opto. In the circuit above , it's likely that's there is a common supply somewhere so you need to be careful about ground loops and ground paths for the high current servo pulses

 

The " test " that was performed isn't really any indication of the opto doing anything , what had you there before the opto was added.

 

The opto does three key things:-

  1. Squares up the pulse because it has gain. This should provide a much cleaner triggering point for the servo preventing small buzzing twitches.
  2. Provides a low impedance load for the controller. Because the loop is low impedance any induced voltage or current has to be significantly higher to create an effect. Current in this loop can be 20mA or more which is a sufficiently large current to be virtually immune to interference - it is very hard to induce a current of 20mA in to a simple wire pair either with high voltage or with high current in an adjacent wire.
  3. Isolates the cable in to two separate sections - a short section between the isolator and the servo which is too short to pick up any appreciable interference, and a long low impedance section between the controller and the isolator that is inherently immune to interference.

All of these things serve to improve performance.

Edited by Suzie
Link to post
Share on other sites

The " test " that was performed isn't really any indication of the opto doing anything , what had you there before the opto was added.

 

Maybe you missed this bit:

"I used a 33 foot extension between my controller and a standard servo and found that I could make the servo twitch significantly every time I started the florescent tube above my work bench."

Link to post
Share on other sites

In the circuit above , it's likely that's there is a common supply somewhere so you need to be careful about ground loops and ground paths for the high current servo pulses

 

 

Even if it runs from a common supply (which is actually the way I'm running the test) there is no current flow in the signal path between the controller and the servo, so I really don't know what you are on about. The "ground" reference on the servo could be bouncing all over the place relative to the controller and it won't make any difference.

Link to post
Share on other sites

Awesome info Andy.  TY for posting.  I have some optoisolators in stock and may also look at driving them from an Arduino local to the servos with Solid state Relays as an option

 

If you are looking for PCB's to be made, I would recommend these people...  https://oshpark.com

 

I have had a number done for me from them for making Arduino based DCC decoders for lighting etc.   (The finished boards come in a very distinctive dark purple colour)

 

2 layer boards are $5 per square inch (with 3 copies of your board included in that price) and ship in under 12 calendar days from ordering with basic international shipping free, although you can request faster shipping for a price.

 

Regards

 

M

Edited by xModellerx
Link to post
Share on other sites

The opto does three key things:-

  1. Squares up the pulse because it has gain. This should provide a much cleaner triggering point for the servo preventing small buzzing twitches.
  2. Provides a low impedance load for the controller. Because the loop is low impedance any induced voltage or current has to be significantly higher to create an effect. Current in this loop can be 20mA or more which is a sufficiently large current to be virtually immune to interference - it is very hard to induce a current of 20mA in to a simple wire pair either with high voltage or with high current in an adjacent wire.
  3. Isolates the cable in to two separate sections - a short section between the isolator and the servo which is too short to pick up any appreciable interference, and a long low impedance section between the controller and the isolator that is inherently immune to interference.

All of these things serve to improve performance.

 

agreed but any line driver would so this and in fact some thing like MAX 3461 RS422 driver would actually even be better , as its a true balanced line driver . when I made the comment , is was specially related to opto isolation, which is reality is bringing nothing to the party here 

 

Agreed re low impedance load, etc this is one of  the main reasons we get servo twitch from interference, yes you are right that a low  input impedance is best 

Also the 820 ohm pulp has a significant effect  on reducing servo twitch by in essence lowering the inout impedance in , This is why MERG boards have a strong pullup when driving servos direct from a PIC IO pin

 

There are three sources of twitch 

 

(A) Inadequate power supplies, causing brownout on the attached processor or the servo , coupled with power ground 

(B) air and power line  interference from passing locos 

© Incorrect sequencing of I/O pins during startup and after pulse width  pulse 

 

There are also issues around maintaining the last pulse width or suspending control signals 

 

In you example , the primary benefit is the low inout impedance circuit into the servo caused by the diode/resistor, this is the  biggest part in achieving the test result you are seeing , wiithout a balanced line , the CMRR will be very low and induced currents will flow asymmetrically in the line 

 

just point this out, If you want a 30 foot line driver , then I suggest a balanced line driver is the way to go. Opto isolation is only really useful , if you have independent floating grounds ( or were deriving the servo power from DCC track signals or something ) 

 

 

 

 

 and a long low impedance section between the controller and the isolator that is inherently immune to interference.

given this is not a balanced line , its far from " inherently immune to interference "

Edited by Junctionmad
Link to post
Share on other sites

Even if it runs from a common supply (which is actually the way I'm running the test) there is no current flow in the signal path between the controller and the servo, so I really don't know what you are on about. The "ground" reference on the servo could be bouncing all over the place relative to the controller and it won't make any difference.

depending on how you  wire this up , if you have a common supply  THEN you have a common ground, incorrect attention will cause  any ground bounce due to the servo being potentially coupled into the digital control  ground.  equally inattention could cause ground loops,  ideally in a common supply ( likely to be the most used approach ) , the servo ground and the micro ground should be a  "star " configuration from a good low impedance ground point , preferably at or near the PSU. 

 

However in many layouts , there is a DC bus and servo loads can be very high especially if there simultaneously movement , and  in  many situations the micro and the servo driver are sitting connected somewhere along the DC bus. 

Maybe you missed this bit:

"I used a 33 foot extension between my controller and a standard servo and found that I could make the servo twitch significantly every time I started the florescent tube above my work bench."

 

 

yes again what was the test , before adding the opto , a 33 foot extension to a standard servo cable ????? , sure I can make that twitch by sneezing at it 

 

Im not  simply commenting to pass the time, but to point out that your design ( by chance or design  ) actually does a significant number of things that eliminate servo twitch, but the opto part isnt actually the reason 

Edited by Junctionmad
Link to post
Share on other sites

Awesome info Andy.  TY for posting.  I have some optoisolators in stock and may also look at driving them from an Arduino local to the servos with Solid state Relays as an option

 

If you are looking for PCB's to be made, I would recommend these people...  https://oshpark.com

 

I have had a number done for me from them for making Arduino based DCC decoders for lighting etc.   (The finished boards come in a very distinctive dark purple colour)

 

2 layer boards are $5 per square inch (with 3 copies of your board included in that price) and ship in under 12 calendar days from ordering with basic international shipping free, although you can request faster shipping for a price.

 

Regards

 

M

 

Thanks for that M. Looks like a good way to go. I'm also considering getting an etching kit so I can make them myself. I used to make a lot of single-sided PCB at the first company I worked for (about 45 years ago!)

Link to post
Share on other sites

  • 7 months later...

Awesome info Andy.  TY for posting.  I have some optoisolators in stock and may also look at driving them from an Arduino local to the servos with Solid state Relays as an option

 

If you are looking for PCB's to be made, I would recommend these people...  https://oshpark.com

 

I have had a number done for me from them for making Arduino based DCC decoders for lighting etc.   (The finished boards come in a very distinctive dark purple colour)

 

2 layer boards are $5 per square inch (with 3 copies of your board included in that price) and ship in under 12 calendar days from ordering with basic international shipping free, although you can request faster shipping for a price.

 

Regards

 

M

 

If your board is small and you want few boards, take a look at OSH Park, they charge $5 per square inch, provide 3 boards, have ENIG (gold) plating, and ship free anywhere in the world.  If you want large boards and low cost or more than just a few boards, this China pcb manufacturer will be your best alternative

Link to post
Share on other sites

  • 1 month later...

 

Im not  simply commenting to pass the time, but to point out that your design ( by chance or design  ) actually does a significant number of things that eliminate servo twitch, but the opto part isnt actually the reason 

 

What is the actual reason?

Link to post
Share on other sites

Having just taken the plunge to use servos to operate three semaphore signals on my new layout I was interested to see this topic. When I first connected the servos, and signals, to the megapoints controller for testing I was a little surprised by the twitching from the servos. They were set up on my kitchen table, under fluorescent lights with a CD player working in the background and my bluetooth enabled phone close by and powered by a supply system recommended by Megapoints Controllers.

As I have never had an interest in electronics I'm afraid I didn't understand many of the concepts being discussed, though I did pick up on the potential for twisting the wires, so please excuse my ignorance and the following question;

Is there anything I can do (as a relative simpleton) to prevent/reduce the twitching?

Thanks for your help.

Cheers,

Ben.

Link to post
Share on other sites

At least two.

 

Isolating the supplies for the logic and servo.

 

The pull up resistor on the control line, although others swear by pull-downs.

 

True, but I think the main reason is because the common mode rejection ratio is extremely good, even during events that produce ridiculous potential differences. The fairly slow response of the opto-coupler probably helps too.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...