This post is about the design and construction of a touchscreen and DCC controlled turntable for a temporary layout. There's mechanical design, electrical stuff, software development, scratch building, and 3D printing in it, so hopefully there's a little something for everyone here.
I had some time this weekend (don't we all these days?), so I put together a little teaser video that I thought might be a fun way to get started.
Or check out the 1080p version here to maximize the experience.
I've always wanted a turntable for my layout, but figured it just wouldn't be feasible for a temporary layout like what I set up each year. For starters, I needed something portable and easy to set up, and compatible with my 1/2" 'roadbed'. I also wanted a design that was readily expandable, so that it could evolve with future layouts. And of course, it had to be DCC controlled and stone-axe reliable. Those factors kept it in the back of my mind for a while, but I had an idea this past fall, during a ride on the Cumbres and Toltec RR in Colorado, that got me thinking it might be possible after all.
As I started in on the concept, here are the top-level requirements that I came up with:
- 30" trestle to handle my longest locomotive (no Big Boys in my roster!)
- Structure and motor designed for a 15 lb locomotive
- Continuous, unlimited rotation in either direction
- Realistic motion with smooth starts and stops
- DCC controlled via accessory and signal commands
- Touchscreen controlled for setup and local use
- Portable and readily serviceable
- Flexible calibration/indexing to accommodate different siding configurations
- Automated via DCC macros and JMRI
- And all in 0.5" of roadbed!
Once I had the overall objectives nailed down, it was on to the details…
Mechanically, the turntable is made up of three main assemblies - the baseplate, the siding assembly, and the trestle.
The baseplate provides the overall structure for the turntable, locates the siding spurs and trestle with respect to each other, and provides the supporting surface for the trestle truck wheels. It houses the main gear, the hall sensor, and the wiring harness to the controller. Mounting hardware is all countersunk, and the harnessing is all routed in 1/16" channels on the underside so the baseplate sits flat on the floor.
The siding assembly provides the 'roadbed' for the siding spurs. They are spaced nominally in 10 degree increments, so the complete turntable could support up to 36 sidings. The actual spacing is calibrated in software after setup, so the exact positioning of the spurs is not critical. Each spur gets power from a pair of wires in a groove routed in the underside of the roadbed. The spurs also power the attached sidings when installed, so no additional wiring is needed for the sidings themselves.
The trestle serves to support and rotate the track itself. It is made up of bonded aluminum plate and channel with cosmetic trestle sides. A scratch-built operator's shanty sits to one side and encloses the stepper motor and connectors. The stepper is attached to the trestle with a 3D printed actuator plate that rotates the trestle and locates the stepper and pinion gear with respect to the main gear. A main ball bearing assembly supports and locates the trestle at the center and houses the slip ring. 3D printed trucks with ball bearings support the trestle at each end. The rotation axis of the truck bearings is aligned through the main bearing axis of the trestle, so they naturally rotate about the center of the turntable. One of the trucks also houses the magnet for the hall sensor. The track is retained at each end by fasteners to the trucks, and is powered via the slip ring.
All three assemblies are readily separated to add siding spurs, if needed for future layouts, or for storage when not in use. Assembly into the layout is done without the trestle, for ease of installation and hooking up the spur tracks. The trestle is also easily removed from the turntable once installed, if needed.
Figure 1 Turntable Assembly
Figure 2 Trestle and Truck Detail
Stepper Motor and Gearing
The stepper motor and geartrain are the heart of the whole thing, so a lot of effort was aimed at developing and optimizing this part of the design. The key trades for the motor were size, powered and unpowered torque, and power requirements. The gear design was driven by positioning resolution, backlash, and output torque requirements. Requirements for the combined motor and geartrain include:
- Position the end of the track within +/- 0.030" of the siding spur, including backlash, in either direction
- Have sufficient torque to rotate the combined inertia of the trestle and a 15 lb, 30" locomotive
- Have enough steps between sidings to allow for smooth acceleration and deceleration
- Be compatible with the overall mechanical and packaging requirements of the concept
After a lot of design, analysis, and searching for suitable commercially available components, I settled on an off-the-shelf NEMA14 size stepper, a stock 12 tooth pinion, and a custom designed, 3d printed 216 tooth main gear.
The stepper is a standard 2-phase hybrid stepper in a NEMA14 size, with 200 steps per revolution. With the 18:1 gear ratio, that works out to 0.1 degree rotation per step for the trestle, with a positioning accuracy of 0.013". When operating, the stepper is driven in 16 step microstep mode, with each step corresponding to 0.0016” motion at the end of the trestle, allowing for very smooth starts and stops.
Nothing remotely resembling the required main gear was to be found in commercial offerings, however, so I had to design this. I was concerned about the feasibility of 3D printing an accurate gear and tooth profile - the 0.8 module gearing selected would require tip to tip spacing of the teeth of just 2.5 mm, so the tooth profile itself would require an accuracy much better than that. Similarly, the diametric accuracy of the gear had to be very good, in order to keep backlash to a minimum throughout a full rotation of the trestle. After discussing with an engineer at Shapeways, he recommended (although he couldn't guarantee anything!) printing the gear using their MJF material. Skipping over a couple weeks anxiety waiting for the parts, this turned out to work extremely well. The dimensional accuracy of the gear is very good, both in terms of the tooth profile as well as the overall diameter.
Figure 3 Main Gear, Actuator Plate, and Stepper (underside)
Main Bearing and Slip Ring
The main bearing and slip ring are housed in a 3D printed shaft and collar assembly at the center of the trestle. The slip ring is an 8 conductor unit, 8mm in diameter and about 12mm long, located at the center of the main shaft. It provides continuity from the base to the trestle for the motor, LED, and track power, and allows unlimited rotation in either direction. The trestle structure, bearing, and slip ring are all retained in position by a collar at the top of the shaft assembly.
The main gear provides an integral housing for the bearing outer race. This ensures that the main gear, bearing, trestle, and stepper mounting plate are all coaxial.
Figure 4 Cross Section of Main Bearing, Slip Ring, and Geartrain
On the baseplate, circuits going to the trestle (motor power, LED, and track power) are run through a channel routed in the baseplate to the connector assembly at the edge of the turntable. The hall sensor, mounted to the baseplate, is also routed to that connector, along with track power wiring from the siding assembly. On the trestle, wiring is routed under the track, through a passthrough in the trestle wall, and inside the operator’s shanty. From there, the individual harnesses go to the stepper, LED, and back to the track.
The entire assembly requires only two external connections - one from the dcc booster for track power, siding power, and dcc commanding, and one for the 9V power supply for the stepper motor and controller. Track power for the trestle, siding spurs, and all connected sidings is provided with no additional wiring.
The controller consists of an Adafruit Metro M0 Express, an Adafruit MotorShield, and their touchscreen TFT display, all wrapped up in a custom designed 3d printed enclosure. The Metro M0 is an Arduino Zero compatible with the ARM processor, 256K flash storage, and 32K ram. The touchscreen display and user interface that I developed for it drove the move to the more powerful Arduino architecture, vs the Mega328 used in my DCC Turnout design. The enclosure also houses one of the PCBs that I fabricated for the turnout project, adapted for this project to provide the DCC interface hardware for the Arduino. A standard pin header connector provides the connection to the turntable wiring harness. An opening in the side of the enclosure allows easy access to the USB port on the M0 for software updates.
Figure 5 Exploded View of Controller
The software for this project is based on the software I developed for the DCC Turnout project. For this project, I needed to add the stepper control, the hall sensor, the graphic display, the touchscreen, calibration, auto homing, and of course the overall logic for tying everything together.
Steppers have been done plenty on Arduinos, so there are some good libraries for that. No sense reinventing that wheel. Libraries I developed for the turnout project that I was able to reuse for this project included primarily the DCC bitstream and decoder libs, as well the LED and hall sensor management. The display and touchscreen, although supported by basic libraries from Adafruit, required development of two new libraries to manage the user interface in the way I wanted. Code for calibrating the siding positions, auto homing the stepper motor, operational logic, and managing the DCC and touchscreen commanding was new as well.
One thing I underestimated was the difficulty in porting standard AVR Arduino code to the ARM architecture. The two are compatible for simple projects, but like they say, read the fine print... In my case, the major differences were in non-volatile storage (the AVR has EEPROM, the ARM has flash), timer/counter setup, and interrupt systems. Those differences drove some significant changes in my existing code for storing and retrieving settings, and in the low-level interrupt handling in the DCC bitstream library. In some cases, even libraries that were stated as compatible with both architectures needed special accommodation to work properly on one vs. the other.
All told, the code for the turntable project consists of roughly 3500 lines of original code. The code can be built with touchscreen support, DCC support, or both. If built without the touchscreen, it will also build and run on the Mega328 architecture with plenty of room to spare. This was useful during development for troubleshooting differences in the interrupt handling of the two platforms.
Baseplate and Siding Assembly
The baseplate was fabricated from a 1/8" thick, 36"x36" sheet of PVC. I routed 1/16" channels in the underside to provide for the wiring. A center cutout and slot facilitate installation of the trestle to the main gear. The main gear as delivered from Shapeways took very little post-processing - I basically just smoothed the top side of the gear with a random orbital sander, since the trestle actuator slides on it, and tapped threads in the screw holes.
The hall sensor is an industrial mount unit, and is mounted near the perimeter of the turntable circle. The repeatability of the hall sensor is quite good - I tested it and found it consistent within a few ten-thousandths of an inch.
The siding assembly is made of 3/8" Baltic birch plywood and provides the 'roadbed' for the siding spurs. The siding spurs are each a 3" piece of Gargraves track. I did the main cutout with a jigsaw, and did the wiring slots on the underside with a router set to 1/8” depth. I applied three or four coats of flat black paint, with sanding in between, which ended up giving a finish that almost perfectly matches the black foamcore that I use for the roadbed on the rest of the layout.
Figure 6 Underside of Roadbed After Cutting and Routing
Figure 7 Completed Baseplate, Main Gear, and Siding Assembly
The trestle base was fabricated from 1/16" thick 6061 aluminum. It is stiffened along the edges by 1/2" angle channel, also aluminum, bonded to the base. The trestle sides from Scenic Express were the perfect length. They are bonded to the outsides of the angle channel, but are purely cosmetic and carry no load. The entire trestle assembly is painted with Valejo Model Air gunmetal color, which gave it a look that I really liked.
The track is a 30" piece of Gargraves, with a few ties removed to accommodate the slip ring, shaft collar, and wiring. The track is retained in position at each end by screws with adjustable plates, so the track can be centered longitudinally and laterally on the trestle. The siding spurs are adjusted for a 0.025" clearance to the trestle track.
Figure 8 Trestle Components
Figure 9 Trestle Assembly
That actuator plate and main bearing shaft components are 3D printed MJF from Shapeways. Prep for most of these parts consisted of simple deburring, smoothing, and tapping. The main bearing is located horizontally at the bottom of the shaft assembly, and locates the trestle with respect to the main gear. The slip ring is a commercial part from Senring. After installing connectors on the rotor and stator leads, the slip ring is installed in the center of the main shaft. A collar at the top of the shaft assembly retains the bearing, slip ring, and trestle base together.
The stepper motor is attached to the actuator plate with a mounting block of MJF. The actuator plate has countersunk slots for the motor mount fasteners to allow adjustment of the gear backlash. Wiring from the slip ring is routed to a connector located on top of the stepper, from which connections are made to the stepper, trestle track, and LED.
Figure 10 Trestle and Main Bearing Components
The trestle trucks are MJF as well, and as with the other parts, required only minor deburring and tapping of the threaded holes. The bearings that serve as wheels for the trucks are centered between the truck rails with shims, and retained in place with shoulder bolts. The magnet for the hall sensor is a 1/16" thick, 3/8" OD neodymium magnet bonded with CA glue in a recess on the underside of the truck.
Figure 11 Trestle Truck
The operator’s shanty was constructed from Evergreen clapboard and v-groove stock, and framed with ¼” angle stock between the walls and roof. The stove chimney, which currently doubles as the warning LED lamppost, is ¼” diameter stock bonded to the back side of the shanty. I used styrene cement for most of the construction, which was really quick and easy to use. The windows details are balsa, and bonded in with CA glue. As with the other components, paint was Valejo Model Air.
Figure 12 Operator's Shanty
The controller assembly consists primarily of the enclosure and the three Arduino boards. The top and bottom halves of the controller enclosure were 3D printed using Shapeway’s Versatile Plastic in black. Accuracy of the parts was, as usual, quite good. 3.0 x 0.5mm threads are tapped in the top half for mating the two enclosure parts, and in the bottom half for securing the Arduino stack. The slot in the bottom half provides a snug fit for the DCC interface PCB, which is retained in place by a matching boss on the top half.
The design of the Arduino stack places all the wiring entirely on the MotorShield board, and is thus quite modular. The Metro M0 board and the display board are completely unmodified and readily interchanged, either with a Mega328 mainboard vs the M0 if desired, or for replacement of either part if needed. The wiring includes power, DCC input, stepper, LED, hall sensor, and speaker signals, and incorporates a modified version of my original Arduino turnout PCB for the DCC interface. The external connector is a standard 0.1” header pin connector. A custom 3’ harness plugs into the controller and connects it to the turntable base.
Figure 13 Controller Components
Setup and operation of the turntable is intended to be as simple and flexible as possible. In the normal operating mode, the turntable can be controlled locally with the touchscreen, via DCC remote, or with JMRI on PC or iPad. Siding selection is a simple matter of pressing a button on the touchscreen or sending a command with the remote. To minimize travel time, logic in the code is such that the shortest rotational distance to the siding is used by default. If a particular orientation of the locomotive is desired, the Reverse button can be used to force the trestle to go the ‘long way around’. Presently, two pages of siding numbers on the touchscreen can accommodate up to 18 sidings, although this is readily extended for future growth. An emergency stop button provides the ability to immediately stop the trestle motion if needed.
Calibration of the siding locations on the turntable is done using the Setup page. The first step is to seek the home position of the trestle using the hall sensor, by pressing the Home button. The trestle will rotate continuously until the zero position is detected. Once the home position is found, the individual siding calibrations can be set. Buttons are provided for manually moving the trestle in large fixed increments or in small continuous movements. Once the trestle is in position for a given siding, pressing the Set button stores the location in flash memory. Calibration is only needed after the initial construction of the turntable, or if sidings are added or changed. The current siding is stored at all times in flash, so the turntable is ready to go immediately on power up - homing the trestle after the initial setup is only needed in the event it gets moved manually with the stepper power off.
Figure 14 Controller Run and Setup Pages
Results and Future Work
Since entering service on my ‘Potomac and Southern Railroad’, the turntable has had an exemplary service record – no downtime, no derailments, and no ‘hand of god’ maneuvers. It has quickly become a centerpiece for the layout. Guests love being able to just pick up an iPad, choose an engine, and drive it out. In fact, engines frequently get swapped out on trains just for an excuse to run the turntable! To say I am satisfied with the results would be an understatement.
There are still some things I’d like to implement in the future. If I can find a lamppost girder structure that I like, I’ll move the LED from the shanty stovepipe to that. I have planned for a speaker as well, for warning tones or other effects. Wiring is provided in the harness already, so that is easy to add down the road. And of course, as with any software project of this scope, there are a number of ‘todo’s in the code that I’ll tidy up at some point. Next year, perhaps…
Why “A Tale of Two Turntables”?
Because building just one for myself wasn’t challenging enough, I built a second one for my dad as well.