Does anyone have any experience with using an Arduino to control servo motors to move the points on model railroad turnouts (specifically in HO scale)?
I have built a small switching layout with seven (7) turnouts. In addition to moving the points, I also want to change polarity of the frogs and show the position of the points with LED's on the control panel, at the same time.
I have an ATX power supply from a PC computer that I can use to provide 3.3v and/or 5v power for this project.
I have been doing a lot of reading about Arduino, but have no experience at all. I love electronics and am extremely interested in learning how to use the Arduino platform for other projects, too.
Any thoughts on how to get started would be appreciated. I am on a limited budget, so an expensive Starter Kit that contains components that I would never use would probably not be my best option.
It has been quite a few years since I had a model railroad, 40 turnouts with 500+ pieces of rolling stock and 32 engines with about 1500+ feet of track. The turnouts I used were actuated by energizing a coil. Using a capacitor with a resistor to charge the capacitor then a switch or relay to fire the coil to keep from burning up the coil.
I could see using servos with spring loading for your turnouts so that you don't have a crash from opposing travel. Using servos is simply programming a PWM (pulse width modulation) to control the position of the servo. Relays work with digital outputs.
The Arduino Mega has 54 digital outputs or inputs, 15 of which can be configured for PWM to run servos.
The most common relays to use with the arduino like 8 relay board on EBay are a little strange to use at first as they are reverse in your thinking of normally open and normally closed because they go active when the output pin is taken to ground. Befor a pin is defined as an input or output it is in a high impedance state so it doesn't matter. If you set the pin to the state you want before you define it as an output it is no problem. The relay board also has a jumper that can be detached that supplies the coil voltage to the relay. it is better to do this and apply a separate power to supply the coils. The inputs to actuate the relays are with an opto-isolator and if you try and power too many relays from the Mega you will overload the 5 volt regulator if you don't remove the jumper as I stated.
It's easy enough to drive LEDs to give you status. You could also use IR LEDs and sensors to detect a train at various locations to actuate road crossing gates and such.
The relays are single pole double throw. If you need double pole, you can tie two relay input together but I would advise you to start the arduino before you power the rails.
The power requirement for the Mega is from 6 to 20 VDC but recommended 7 to 12 VDC. The output of the pins are 5VDC. Don't forget a resistor in line with your LEDs.
Using an ATX power supply might be a problem. I recall that they needed a power good signal to be fully functional.The Arduino doesn't require that much power. It can be power from a USB connection.
You could use a PC or Terminal to get information from your program as well.
My saying is "If you can dream it, we can build it, imagination is the only limit."
If you use the search function in the top right handside of this page with railroad turnouts
It will give you a list of the threads that have been about using servo for points(sorry GWR fan) control.
There is quite a bit on different methods.
Hope it helps. Tom....
(GWR Gods Wonderful Railway)
Controlling servos with an Arduino is very easy with the standard Servo library. Have a look at the servo sweep example that comes with the Arduino IDE.
I think the easiest way to switch polarity would be to use the servo arm to push a microswitch. An Arduino cannot directly control the voltages and currents required by model trains so, not matter how to organise it you will need some extra stuff between the Arduino and the track power - transistors or relays, for example.
You could power the relays and the Arduino from your 5v power supply but do NOT power the relays THROUGH the Arduino.
Another nice feature with an Arduino system is the possibility of reducing inter-baseboard wirirng. With an Arduino on each board you could control everything with only 3 wires (Rx Tx and GND) between the control position and the other Arduinos. I know a large layout built in the days of relays for interlocking which has dozens of inter-connect wires. None of them would be needed if the system was being designed now.
Robin2:
I think the easiest way to switch polarity would be to use the servo arm to push a microswitch. An Arduino cannot directly control the voltages and currents required by model trains so, not matter how to organise it you will need some extra stuff between the Arduino and the track power - transistors or relays, for example.
I agree, using relays for the frog polarity would work, but a simple microswitch driven by the servo arm would be much cheaper.
I have seven turnouts on my small layout. Which Arduino would be best to use to drive all these servos. What about a Nano with an extension shield? I think that would be cheaper than a Mega.
Also, what do you think about the Chinese boards and servos? Are they junk? They sure are cheap.
golfmjc:
I agree, using relays for the frog polarity would work, but a simple microswitch driven by the servo arm would be much cheaper.
I did recommend microswitches
I have seven turnouts on my small layout. Which Arduino would be best to use to drive all these servos. What about a Nano with an extension shield? I think that would be cheaper than a Mega.
A Nano could easily control 7 servos and should have enough I/O pins also to have an on/off switch for each one. In some situations a single servo can move a pair of turnouts.
Are all the turnouts on the same baseboard? If they are all on one baseboard you may find that a Mega offers useful extra functionality.
I have a couple of SparkFun Pro-Micros which I bought because they have a spare HardwareSerial port to make communication between them easier.
Also, what do you think about the Chinese boards and servos? Are they junk? They sure are cheap.
I have no experience of Chinese Arduino boards. I have several cheap HobbyKing servos that probably came from China and I have had no problem with them. I might think twice about putting them in an expensive airplane.