I have finally started working on my first TRUE model railroading hack and this one is really cool! It uses Arduino, like many of the model railroading hacks I have floating around in my head or on the back of napkins, to control a model railroad turntable. For those who don’t already know, a turntable is a large turning platform with a track on it that a locomotive can drive onto and then be turned around to other tracks or even 360 degrees within the locomotives own length. Click here for a closer look at rail turntables on Wikipedia. What makes this any different than any number of model railroading turntable kits that might exist or why is it better than just sticking a motor onto the turntable with a switch? Well, because this is a micro-controlled turntable that’s why! Other turntables are not often precise and frequently misalign. The hack I am describing here uses the Arduino Duemilanove microcontroller coupled with an Adafruit Servo Motor shield to control a stepper motor and get positional feedback from opto-interrupters positioned to stop the turntable (via a deftly programmed Arduino sketch) precisely at an adjoining track location and be accurate and repeatable. I want the control panel input to the Arduino be nothing more than a rotary switch with each pole telling the Arduino to spin the turntable to a different fixed position for the turntable. Maybe an LED for each position could be used at the control panel as feedback. I want to use a stepper motor with at least a right angle gear box with good reduction so it can be easily located directly under the turntable and have enough oommph to spin large, heavy brass locomotives around. I was thinking about this relatively inexpensive (hey it’s only $16.95!) 3.3V stepper motor with built-in 180 degree gear reduction unit from MPJA, Inc. I have seen this exact motor unit built-into homemade CNC routers as a 4th axis to spin long material and use the router much like a CNC lath – good for carving ornate pool cues, spindles etc… This unit works well, is readily available all over the internet, meets my somewhat arbitrary requirements, and is dirt cheap! Can’t beat that!
[ad#Adsense3]
I want the Arduino to get turntable positional feedback from opto-interrupters. Opto-interrupters are essentially a U-shaped piece of plastic with a narrow gap in the middle and an Infra-red LED positioned on one arm of the U and and an IR phototransistor (sensor) on the other (See picture below).
The IR LED transmits a continuous beam to the phototransistor. When the turntable swings around to one of the predetermined “stop” points (ie. in front of a round house or in alignment with a spur track, etc…), a vane (the little tab on the bottom of the turntable that breaks the beam of opto-interrupters) on the bottom side of the turntable will swing into the gap in the “U” of the opto-interrupter and “interrupt”the continuous beam from the LED to the phototransistor. As the output signal from the phototransistor goes from ON to OFF, that change will be picked up by the Arduino and the firmware sketch will then process it and perform a routine where it stops the turntable. I want this turntable to have realistic slow starts and stops so I am thinking I will put two vanes underneath the turntable. One that aligns the turntable for the final “Stop” position and one that interrupts the next opto-interrupter ahead before the turntable is aligned with the desired stop position to tell the Arduino when to start the “slow” stop routine. Huh? I can hear you asking. Click the thumbnail below to see my ugly diagram about my opto-interrupter scheme. Its also worthy to note that this could be done with a hall sensor or sensors and magnets attached to the turntable. Anyone try anything like that or know the pros and cons of using hall sensors versus opto-interrupters? Please comment. In my case, I don’t want to deal with making sure magnets are aligned and that the magnetic fields don’t interfere with other things etc… and I’m not that familiar with them and have experience using the opto-interrupters so that is what I am going with here.
For the firmware (i.e. Arduino sketch) I will need to include the Adafruit stepper motor shield library to control the stepper motor for the turntable. I need to work out a routine that, based on the position of the rotary switch input, the turntable is checked for current position at power-up and moved to match the rotary switch position if needed. The Arduino needs to know that when the rotary switch position is changed, to move the turntable to that position. I want this turntable to not only be highly accurate but look realistic too so I need a routine that whenever the turntable is starting to move, the Arduino micro-controller slowly (i.e. “in scale”) accelerates the turntable up to speed. This will simulate how a real, relatively small electric motor would spin a giant turntable burdened with a locomotive, weighing tons and tons. Then I need to work out a loop that monitors the opto-interrupters for a break in signal – some models of opto-interrupters have Schmidt Triggers built-in to create an output pulse when the beam is broken which is easy to work with, so maybe I’ll go with one of these. Otherwise I guess I would monitor the interrupters on analog input pins. Since the “slow” tab will always break an interrupter first (assuming clockwise rotation which I forgot to indicate in my diagram), the sketch needs to start the “slow” down routine to decelerate the turntable until it detects the second break of the interrupter and then stops the turntable at that position. then it just sits there….waiting……waiting for someone to turn the rotary switch to a new position and the whole slow start, check opto-interrupters, slow stop routine starts all over again. Easy as pie!……sort of……..not really. Well, I envision writing the sketch to be the hardest part of the whole project really since everything else is just off the shelf components.
Oh, one thing I failed to mention or include in any of my diagrams is that this will need an external 12V power supply to power the stepper motor, opto-interrupters, and the input signal to the rotary switch.
So, that is the rough “back of napkin” explanation of my first, official model railroading hack – an Arduino Controlled Model Railroad Turntable. Let me know what you think and I will get to work on it and update Track Hacker with the progress.
Related articles by Zemanta
- TUTORIAL: Arduino Ethernet+SD + Using the Arduino to browse files on an SD card remotely (adafruit.com)
- Arduino rocket launcher with count-down (electronics-lab.com)
- WiFi controlled Arduino-bot (hackaday.com)









How’s your progress? I love the idea.
[Reply]
Thats a great idea. Thanks for sharing and let us know how it comes out.
[Reply]
I would remind you of the need for the elimination of as much “loose movement” between the driven part and the bridge. The bridge must ALWAYS stop at the same position when approaching from a direction and as small a difference from the other direction. My project starts with the Teton Short Lines design and then some MM Logic to remember it is seeking the next position. This is all discrete logic, converted from TTL to CMOS, but would be a great project for a Micro. My mechanism works with the breadboarded circuit. The opto locating is done with a vane ending up between two IR transistors (2 leads). At that point both IR diodes are seeing the IR. Wayne Rodericks explanation of the circuit is not in depth, so some of it was “build it and see”. You are heading in that direction of using 2 detectors but only one vane is needed to accurately position the tracks.
I did some experimenting with Hall effect and it works with refrigerator strength magnets close by. Each Hall device requires a ground, so “totem pole ” arrangements don’t seem to be useful.
I am currently working on the bridge. BTW. I started with a Walthers 90′ model. Scrapped the drive and built something similar to Teton Short line idea. I can’t get under the layout so easy now, so I have the vanes on top of the drive wheel. where I hope to adjust for the final lineup by removing the pit and mounting the bridge only.Getting the slop minimized is not so easy with a plastic kit as a starting point. That’s my cross to bear.
Lets hear more when you have time.
Bob T
[Reply]