Model Railroad Turntable Stepper/Arduino Uno Project

Hello everyone. Took quite a while to finally find something that would work for what I wanted to do. I’m not going to get into the specifics of the project, because the question I have is pertaining to the code I am using. The code I have takes DCC signals and sends them to my stepper motor driver and will cause my turntable to move to the desired position. All of this works GREAT. The problem is that because of the type of stepper/gearbox I’m using, there is some backlash issues which I cannot solve mechanically.

One thing I noticed though is when the turntable only turns in 1 direction, the tracks line up oerfectly all the time. When it goes the opposite direction they do not. I believe this is because all the backlash is taken up when it stays ONLY in 1 direction. The way the program works is that each address has a thrown and a closed position. Thrown is clockwise movement, and closed is counter clockwise. I would like this to ONLY turn clockwise regardless of which button is pushed.

For example when I go to address 200, and select thrown, it turns it 180 degrees and stops. When I hit closed it turns it BACK 180 degrees. I want it to go 180 degrees but in the same direction. All movements from dcc inputs I want to go clockwise.

MYTTableDCC3-20.ino (9.47 KB)

in the clockwise direction, why not go just past the target position and then drive the motor in the clockwise direction

One way to deal with backlash is always to approach the final position in the same direction - for example clockwise. If it is faster to get to a position by going anti-clockwise then overshoot slightly and then return to the position clockwise. The overshoot needs to be enough to allow the backlash to work itself out.

Another option is to figure out how many steps are needed to take up the backlash and add that extra number of steps whenever the motor changes direction. I have done this with the stepper motors (driving lead screws) on a small lathe and it gives very precise results. However if you are using a 28BYJ-48 stepper motor with gearbox I just don't know if the mechanical system is sufficiently well made to give repeatable results with this method.

If neither of those works then I think you will just have to put up with always rotating the turntable in the same direction.


Thank you for the responses. I have experimented with adding a few extra steps in, and it didn't really help. That's why I opted to go in ONLY one direction. However, I'm not sure what changes to make in the program I have to make it only go in one direction.

It looks like all the calculations for figuring out the motor moves are inside the NmraDcc.h library because there is nothing in loop() except a call to that library and a call to run the stepper motor

Is this all code that you wrote yourself?


Nothing to do with your problem but is the below line correct as it does not match the sequence of other positions.


This program was an example included in the nmradcc library. It was a written by Alex shepherd. All I did was change the pin numbers to match mine, and add 27 to the gearbox spot.