Jump to content
 

Servo control on the cheap


eldavo

Recommended Posts

There is quite a lot of discussion on the Arduino forum about servos twitching at startup and no bullet proof solution. From my own experience it seems that some servos will move to their end position if powered up without a position signal and others just stay where they are. I don't think it has anything to do with the price of the servo. The answer seems to be to generate the position signal before powering up the servos. This could be done by using a relay to control the power to the servos - simple with an Arduino but I don't know if it's possible with the MERG system.

 

There is also, of course, the problem that the initial position might not be the same as the position the servo was in when last used. Perhaps there should be a formal shut down procedure.

 

I would (will) connect the servos to the point with a wire with a loop in it to dissipate extra movement without putting too much force on the point. 

 

...R

Link to post
Share on other sites

  • RMweb Premium

If this is aimed at me, may I point out that there were no pictures in your first post :)

 

 

 

This is certainly a very useful feature, and I have used it, but it isn't strictly an alternative because (as far as I know) if you have the Atmega 328 in the Uno board you can't use the board to conduct a serial "conversation" with another board.

 

...R

Now that sounds familiar...but I have definitely used a Uno to program both Atmega and Attiny chips without prising the 328 from the Uno board.

 

I think the method that requires the 328 to be removed uses the USB to serial part of the Uno to program an external chip the same way as the 328 which is normally on the board (i.e. via the Arduino boot-loader).

 

Now I think about it (it was a while ago I did this), the method I used was to run a program which turned the Uno into a programmer by connecting output pins to the serial pins (I think) of the device being programmed. For this method not only do you not have to remove the 328 from the Arduino, you can't, or you'd have nothing to run the program on!

 

Another advantage of this method is that the chip being programmed doesn't require the Arduino bootloader, which means you can use chips like the Attiny which I think don't have the memory for the bootloader. You can also use this method to put a bootloader onto Atmegas rather than having to buy ones somebody has already put a bootloader on.

 

I hope this makes sense - I haven't thought about all this for a while (too busy trying to put a layout together...)

Link to post
Share on other sites

Sorry if I have not been clear enough.

 

You are correct to say that you keep the Atmega328 chip in the Arduino Uno when using it to program another chip including, as you say, chips that don't or can't have a bootloader installed - or for initial installation of a bootloader.

 

But if you just want a USB-serial communication to an already programmed chip on another board (as an alternative to using an FTDI cable) you need to remove the Atmega328 chip from the Uno so that the communication takes place with the other board. If you leave the -328 in the Uno board you would have the PC trying to talk to two chips at the same time over the same wires which won't work.

 

And, as you say, the removal of the -328 is also necessary if the Uno USB connection is to be used to upload a program to another chip that already has the bootloader installed. Once the bootloader is installed on a chip the subsequent "programming" is just a regular serial data transfer that is intercepted by the bootloader.

 

...R

Link to post
Share on other sites

  • RMweb Premium

Sorry if I have not been clear enough.

 

You are correct to say that you keep the Atmega328 chip in the Arduino Uno when using it to program another chip including, as you say, chips that don't or can't have a bootloader installed - or for initial installation of a bootloader.

 

But if you just want a USB-serial communication to an already programmed chip on another board (as an alternative to using an FTDI cable) you need to remove the Atmega328 chip from the Uno so that the communication takes place with the other board. If you leave the -328 in the Uno board you would have the PC trying to talk to two chips at the same time over the same wires which won't work.

 

And, as you say, the removal of the -328 is also necessary if the Uno USB connection is to be used to upload a program to another chip that already has the bootloader installed. Once the bootloader is installed on a chip the subsequent "programming" is just a regular serial data transfer that is intercepted by the bootloader.

 

...R

 

That's what I was trying to say...

 

However, are you saying that once the bootloader is installed on a chip you can no longer program it without using the bootloader? I didn't think that was the case, but I forget now if I ever tried it.

 

The other thing to note, perhaps, is that some Unos have an SMD -328, in which case removing it isn't terribly practical. I know they were doing this a couple of years ago because there were supply problems with getting DIP -328's. Maybe that problem has gone away for now (though at the time there were suggestions that this was the start of Atmel's move to stop using the DIP format because only hobbyists use it these days).

Link to post
Share on other sites

There is quite a lot of discussion on the Arduino forum about servos twitching at startup and no bullet proof solution. From my own experience it seems that some servos will move to their end position if powered up without a position signal and others just stay where they are. I don't think it has anything to do with the price of the servo. The answer seems to be to generate the position signal before powering up the servos. This could be done by using a relay to control the power to the servos - simple with an Arduino but I don't know if it's possible with the MERG system.

 

There is also, of course, the problem that the initial position might not be the same as the position the servo was in when last used. Perhaps there should be a formal shut down procedure.

 

I would (will) connect the servos to the point with a wire with a loop in it to dissipate extra movement without putting too much force on the point. 

A partial solution is to include either pull-up or pull-down resistors on the servo control lines so that they are held in a defined state while the microcontroller performs its internal power up reset before it starts producing pulses.

At least one version of code for the MERG Servo4 board stores the last received switch input settings in EEPROM so that it is less likely to see an immediate change next time power is applied. If a change is detected, the servo is commanded to move to the new setting at the speed defined for that servo.

Link to post
Share on other sites

I have a friend that tried the MERG system. His first problem was he couldn't get the programmer to work. He was able set the servos up using a PC and the MERG software. All seemed to be working fine until he found that when running certain locos the points would change at random, not good on an exhibition layout. Another issue I had was the motors twitching when the system was switched on. I thought this could potentially cause damage to hand made track or signals.

If he's a member of MERG, then he should be aware that there has been a lot of discusion about this on the MERG forum. There are firmware updates and hardware fixes for the twitching and some discusion of the isues of cross talk from noisy locos.

 

The simple hardware fix is a 4k7 pull-up or pull-down resistor on the control line (-up or -down seems to depend on the servo).

 

Also ensure servo wiring is kept well away from DCC bus wiring. If they have to run in parallel keep them as far apart as posible. If they need to cross over, then cross at right angles. For any layout keep the bus wires close , preferrably twisted together.

 

Servos should have a separate 5V supply to that used for the electronics as they can take quite a bit of current when moving.

 

Andrew

Link to post
Share on other sites

 

 



That's what I was trying to say...

However, are you saying that once the bootloader is installed on a chip you can no longer program it without using the bootloader? I didn't think that was the case, but I forget now if I ever tried it.

The other thing to note, perhaps, is that some Unos have an SMD -328, in which case removing it isn't terribly practical. I know they were doing this a couple of years ago because there were supply problems with getting DIP -328's. Maybe that problem has gone away for now (though at the time there were suggestions that this was the start of Atmel's move to stop using the DIP format because only hobbyists use it these days).


If there is a bootloader installed you can, of course, program the chip without using the bootloader. I think the process would be the same as reinstalling the bootloader - but I haven't actually tried it so I don't know the details. The purpose of the bootloader is to simplify programming at the expense of a slight delay when the chip reboots and needs to figure out whether a PC is trying to send code to the bootloader.

I know that many of the Arduino designs use SMD chips but as far as I know all the Unos use DIP 328s.

 



A partial solution is to include either pull-up or pull-down resistors on the servo control lines so that they are held in a defined state while the microcontroller performs its internal power up reset before it starts producing pulses.

I must try this idea with my Arduino. I don't recall reading about it in the Arduino forum. It's wonderfully simple.

...R
Link to post
Share on other sites

I know that this is slightly off subject but has anyone seen/tried the new Peco PLS 100 servo system?  Any observations.  I am about to embark on a new project ( O, Scale Seven) and I have used all sorts of point control in previous layouts - manual lever frame, Seep solenoids, Fulgurex slow action motors, Tortoise and Cobalt motors and so I guess that servos may be the way to progress.  Any observations?

Link to post
Share on other sites

I've seen it advertised in Railway Modeller. The idea looks very good but they seem afraid to mention the price.

 

I've just ordered 10 cheap servos from HobbyKing. I think the total price including postage was about £25.

 

It only takes a few minutes to make a bracket from aluminium or plastic angle.

 

I guess the controllers may be attractive to someone who doesn't want to be bothered programming an Arduino. But Arduino programming isn't difficult and it would be far more versatile. Mine will be used for train detection as well as moving points.

 

...R

Link to post
Share on other sites

The whole set up for 4 x servos, bracket, switches the 4 way controller and the programmer board comes to £52 from Rails of Sheffield.  you can but the servos and further controller boards but they cost more than buying a four-pack.  I'm not familiar with these ARDUINO boards or how to program them and so they may be a little beyond my ability.  Other servo boards seem to be aimed at DCC control and whilst I have DCC locos with sound, I don't want to have DCC controlled points.

Link to post
Share on other sites

...I guess the controllers may be attractive to someone who doesn't want to be bothered programming an Arduino. But Arduino programming isn't difficult and it would be far more versatile. Mine will be used for train detection as well as moving points.

 

I think it is more the other way around. The Peco controllers, as with others such as the MERG Servo4, will be more attractive to those who don't feel the need to learn any form of computer programming just to get their signals or turnouts to move. The Arduino approach might be more attractive to those who want to fiddle with Arduinos.  Yes, they are simple to program, but not needing any programming is even simpler.

 

...Other servo boards seem to be aimed at DCC control and whilst I have DCC locos with sound, I don't want to have DCC controlled points.

That's a popular misunderstanding with controllers such as the MERG type, and probably most others. They can be controlled by switches just as easily as using the outputs on a DCC accessory decoder.

 

Nick

 

ps. just to clarify a potential misunderstanding, the "programming" involved with an Arduino is the process of writing simple computer programs. It is a wholly different thing from the mere setting of travel limits using pre-existing software or hardware devices which is often referred to as "programming" a MERG or Peco type of controller..

Link to post
Share on other sites

Hi all,

another way of using servos the cheapy way would be the following (perhaps not so advisable for large layouts):

I butcher two servos by disconnecting the internal control circuit:

 

post-12822-0-59972200-1390325924.jpg

 

post-12822-0-72242200-1390325960.jpg

 

…and connect the two motors directly (grey wires above). Then I have one motor (formerly “servo”) to throw the points in the usual way and the other one to provide the necessary power.

 

The latter then is situated at the control panel, where its crank protrudes through the panel and makes the handle:

 

post-12822-0-82368700-1390325996.jpg.

 

 

I just give it a brave push, the motor acts as dynamo, delivers current to the other motor and – that’s it! Point switched.

 

The beauty is that there is no need of a controlling circuit (or micro computer). Also no separate power source (trafo, battery…) required; so also just two wires between generator and motor, nothing more. In addition there is no danger of stalling current burning the points motor. Last but not least, the crank indicates the setting of the point (if properly mounted / wired).

 

No more than two mutilated “servos” and two wires. Works well with smaller layouts.

 

Enjoy!

  Armin

 

 

 

PS: With the above construction I met only one problem: whereas I can use those cheapo far-eastern servos at the points end, they are not so suited as generators. Reason: their gearings are (mostly) so weak that they break easily (remember: one has to apply some hefty push in order to produce sufficient current).

Therefore at the panel end servos of reliable quality are advisable.

 

 

Link to post
Share on other sites

It only takes a few minutes to make a bracket from aluminium or plastic angle.

...R

 

 

For instance lookin like that (for clarity: baseboard replaced by perspex):

 

post-12822-0-87191400-1390326617.jpg

 

 

And if we talk about enhancements of servos – here a simple switch to polarize the frog:

 

post-12822-0-89828300-1390326699.jpg

 

 

  Armin

Link to post
Share on other sites

Will they be strong enough to  switch my points?

Yes, but you need to have a leverage system so that the servo turns close to 90 degrees when moving the point so that the servo can hold the points closed just with the gear ratio.

This is simply arranged with a pivotted spring wire.

Regards

Keith

Link to post
Share on other sites

I've played with an Arduino Uno & servos to operate signals, and been very happy with the results, but obviously, the price of the Arduino has to be added to the price of the servos to make a comparison with other systems. An Uno is about £20 and has 14 digital I-O pins. The bigger one is about £36 and has 54, and both will allow interlocking to be programmed, should you want this - you can allow one pin for the servo drive, one pin for the switch, and a third for a red led to indicate that a "lever" is "locked". I haven't worked out a good way of doing FPLs yet, but they can, at last theoretically, be integrated too.

 

This seems to me to be a reasonable approach to permit a prototypical operation of a frame, though 18 levers would not constitute a big frame. I understand that through the serial ports, multiple Arduinos could be daisy-chained to provide more levers, although I have not tried this yet.

 

I have just paid my MERG subs, and will purchase a servo4 kit to experiment with, when they send me my membership details. These, as I understand, have a single input pin per servo, and so any locking logic would have to be external. The £3 Arduino might well be a cheaper approach than the MERG solution, but I haven't tried this yet, either.

 

All the above offer the choice to have either a switch, or with some external bits, a DCC input. I'm not intending to use the DCC option on the main layout, but it might offer an opportunity to automate a fiddle yard... Imagine the computer sending you the bellcode, and when you respond appropriately, it sends the train, complete with "entering section" bells. And, assuming there is a free road, it accepts a train and parks it safely, all governed by bell codes. Could be very satisfying, and damn handy for the running days when you're short-handed!

 

The alternatives of "pithed" servos do not appeal to me, although if the current is suitably limited, they would appear to be a cheap (and compact) Tortoise alternative, so if it suits, I couldn't argue with the logic (even if the "servo" nomenclature is suspect).

 

I'm looking forward to my MERG kit. Will report in due course.

 

Best

SD

Link to post
Share on other sites

A partial solution is to include either pull-up or pull-down resistors on the servo control lines so that they are held in a defined state while the microcontroller performs its internal power up reset before it starts producing pulses.

.

Thanks for this tip. It completely stops my servo moving until the Arduino instructs it. I have put a 4k7 resistor between the signal pin and ground.

 

...R

Link to post
Share on other sites

  • RMweb Premium

I've played with an Arduino Uno & servos to operate signals, and been very happy with the results, but obviously, the price of the Arduino has to be added to the price of the servos to make a comparison with other systems. An Uno is about £20 and has 14 digital I-O pins. The bigger one is about £36 and has 54, and both will allow interlocking to be programmed, should you want this - you can allow one pin for the servo drive, one pin for the switch, and a third for a red led to indicate that a "lever" is "locked". I haven't worked out a good way of doing FPLs yet, but they can, at last theoretically, be integrated too.

 

This seems to me to be a reasonable approach to permit a prototypical operation of a frame, though 18 levers would not constitute a big frame. I understand that through the serial ports, multiple Arduinos could be daisy-chained to provide more levers, although I have not tried this yet.

 

SD

 

As an alternative to buying more expensive Arduino's than the Uno, or daisy chaining them, it is possible with a few extra (cheap) chips to add a large number of additional I/O pins to a Uno. They can't be read/written simultaneously, but by switching between them extremely quickly the effect is just about the same.

Link to post
Share on other sites

As an alternative to buying more expensive Arduino's than the Uno, or daisy chaining them, it is possible with a few extra (cheap) chips to add a large number of additional I/O pins to a Uno. They can't be read/written simultaneously, but by switching between them extremely quickly the effect is just about the same.

Have you tried doing this? I wouldn't have thought you could switch the outputs quick enough to keep the servos stable. You may be able to do some PCM or psuedo-PWM on a few outputs on a shift register but then you are going to start to struggle with timing. If you use some fancier IC's with some more processing power onboard then you might as well use the Arduino Nano/Pro.

Link to post
Share on other sites

For tasks like moving signals or points the servos only need to be powered up when they are actually required to do something - the internal friction should be enough to hold position. So one way to control lots of servos with an Arduino is to connect the signal connection to all of the servos at the same time and use other Arduino pins (including with shift registers if necessary) to switch on the power to the servo you want to move. Just remember that the Arduino pins can't power a servo - use a cheap transistor to control the servo current.

 

...R

Link to post
Share on other sites

  • RMweb Premium

Have you tried doing this? I wouldn't have thought you could switch the outputs quick enough to keep the servos stable. You may be able to do some PCM or psuedo-PWM on a few outputs on a shift register but then you are going to start to struggle with timing. If you use some fancier IC's with some more processing power onboard then you might as well use the Arduino Nano/Pro.

 

No I haven't!

 

I must admit I was thinking more of reading switches/controlling LEDs. I take my suggestion back.

 

And I agree that if you're going to look at fancier IC's to do the switching you might as well use several Arduino pro's given the prices at the moment.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...