Using Planetary Stepper Motors to control Turnouts.

Started by elwoodblues, November 08, 2026, 10:57:02 PM

Previous topic - Next topic

elwoodblues

A couple of years ago I came up with a way to control 4 turnouts using an Arduino Nano to control the turnouts on the small switching layout I was building when I worked on the road.  I figured out that I could control 4 turnouts with one Arduino Nano using 1 push button for throwing the turnout and 2 LED's to indicate the turnout direction.  If you are interested here is my YouTube video showing the prototype.

https://www.youtube.com/watch?v=7sN1HnTmX8U&pp=0gcJCUEMAYcqIYzv

Once I had it all figured out I made PC boards for this.

Now comes the "However"  ;D  On my recently built staging yard some of the turnouts are too close to the benchwork to under mount the servos so I needed an above mount system to remotely throw the turnouts.  A few months ago while at an ON30 meet a fellow member (who likes to pick my brain with anything to do with Arduino's) gave me a small motor with a gearbox and asked me if I thought if they could be used to control a turnout.  I said "I don't see why not" and said I would look into it when I has some free time.  Well the time is now.


PlanetaryStepperMotor001.jpg
Here are the two types of the planetary stepper motors with built in gearbox and linear screw I picked up from Aliexpress.  They are also available on Amazon and other places.

The goal is to use them to control the turnouts on my staging yard using a push button to control them and LED's to indicate direction, just like I did on my servo project.

Will I'm still in the design process I thought I would start now so you can see my trials and tribulations.

Next up, did I bite off more that I can chew? :o

Thanks for looking in.
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

deemery

Could you shoot a little video showing how those work?  It's not quite clear to me what actually gets moved by the motor, particularly on the right side unit.

dave
Modeling the Northeast in the 1890s - because the little voices told me to

Rick

Ron, thanks for starting this thread.
I'm sure you'll be able to figure out how to get them to work.

Bernd

Those look like the drives used on disk drives to position the reading head or laser on an optical disk drive.

Bernd
New York, Vermont & Northern Rwy. - Route of the Black Diamonds

elwoodblues

Quote from: deemery on November 09, 2026, 08:13:17 AMCould you shoot a little video showing how those work?  It's not quite clear to me what actually gets moved by the motor, particularly on the right side unit.

dave
Dave,

I can shoot a short video on how they work, I need to move them to the center anyway, give me a couple of days.  ;D
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

elwoodblues

Quote from: Rick on November 09, 2026, 08:25:37 AMRon, thanks for starting this thread.
I'm sure you'll be able to figure out how to get them to work.
Thanks Rick,  I think I have it figured out, just need to test it.  ;D
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

elwoodblues

#6
Quote from: Bernd on November 09, 2026, 08:54:39 AMThose look like the drives used on disk drives to position the reading head or laser on an optical disk drive.

Bernd
Bernd, they are Kind of.  The ones used in disk drives usually have a longer screw


images.jpg
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

elwoodblues

Planetary stepper motors useful for this application usually consists of 3 parts
                1 – stepper motor
                2 – gearbox (the planetary part)
                3 – linear screw
 
Most planetary stepper motors are bipolar and require some sort of motor drivers to organize the phases so that it can move clockwise or counterclockwise.  Some suitable motor drivers are as follows.
          ·         ULN2003 driver board
          ·         A4988
          ·         DRV8833
          ·         L298N Dual Chanel H bridge
          ·         SN754410NE
There are others that can be used.
 
Bipolar stepper motors work by passing current through 2 coil windings (phase A and phase B) and actively reversing the polarity (direction) to turn a magnetized rotor in precise incremental steps.  Because of this there are 4 wires, 2 for each phase normally shown as A+, A-, B+ and B-.  Because there is no center tap the driver is required to push and pull the electrical current in opposite directions through its windings to rotate (this is probably more that you wanted/needed to know).
 
I spent a lot of time trying to figure out how to home the stepper motors.  At first I thought that because the screw limits the movements in either direction that there should be a way to home the motor without any additional items required.  I suppose there is by using the torque of the motor, but I have a feeling that will burn out the motor.  After some research I decided to treat this like any other stepper motor and will use a limit switch to home the motor.
 
The goal of this exercise is to control turnouts using a planetary stepper motor controlled by a pushbutton and use 2 LEDs to indicate direction.  My plan, like my servo motor project, is to use components that can be used on a PCB board.  This is to make everything neat and to save space.
 
So what will be needed for this project?
                1 – Planetary Stepper Motor (to drive the turnout)
                1 – Arduino Nano (provides processing power)
                1 – SN754410NE motor driver (this is an IC that will be mounted on a PCB board)
                1 – Limit switch (normally open – used to home the stepper motor)
                1 – Pushbutton (normally open – used to operate the stepper motor)
                2 – LEDs (1 green and 1 red to indicate turnout direction)
 
Next up – Wiring diagrams

Thanks for looking in.
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

deemery

#8
Ron, that was a great post explaining how these particular steppers work, and what you need to control them.  Thanks!

Question:  What's the throw distance on those two steppers?

dave
Modeling the Northeast in the 1890s - because the little voices told me to

elwoodblues

Quote from: deemery on November 10, 2026, 10:47:55 AMRon, that was a great post explaining how these particular steppers work, and what you need to control them.  Thanks!

Question:  What's the throw distance on those two steppers?

dave
Thanks Dave, I was trying to make it simple and understandable.

The throw distances are as follows.
     The silver one has a throw of 0.410"
     The black one has a throw of 0.335"
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

elwoodblues

Next up, covering the physical components setup


Part 1 - Overview

The circuit described below controls one 5v bipolar planetary stepper motor with a linear screw, using an Arduino Nano, 1 - SN754410NE motor driver, 1 pushbutton, 1 home limit switch and 2 LEDs to indicate turnout position.
 

Part 2 – Operating Sequence

1 – Power ON
          -          Stepper motor moves counterclockwise towards limit switch (both LEDs are off)
2 – Limit switch activated
          -          establishes position 0 (both LEDs are off
3 – Automatic startup
          -          Stepper motor stops (both LEDs are off)
4 – First push button Press
          -          Stepper motor moves 600 steps to position 700 (both LEDs off during travel)
5 – Stepper motor arrives at position 700
          -          Stepper motor stops (LED 700 turns on)
6 – Second push button Press
          -     Stepper motor moves 600 steps to position 100 (both LEDs off during travel)
7 – Stepper motor arrives at position 100
          -     Stepper motor stops (LED 100 turns on)
 
Each subsequent pushbutton press alternates between position 100 and position 700.
 
 
Part 3 – Pin Assignments
 
Arduino Nano pin assignments
 
D2 – DN754410 input 1A (driver pin 2)
D2 – DN754410 input 2A (driver pin 7)
D2 – DN754410 input 3A (driver pin 10)
D2 – DN754410 input 4A (driver pin 15)
D9 – Home Limit Switch
D10 - Pushbutton
D12 – Position 100 LED
D13 – Position 700 LED
5V – driver logic supply and enables on motor driver
GND – common ground
 
Note: The home switch and pushbutton are normally open, each connected between its input pin and ground.
 
 
SN754410NE Pin assignments
 
Pin 1 (Enable 1) – Nano 5V
Pin 2 (Input 1A) – Nano Pin D2
Pin 3 (Output 1Y) – Stepper motor winding (A+)
Pin 4, 5 (Ground) – Common ground
Pin 6 (Output 2Y) – Stepper motor winding (A-)
Pin 7 (Input 2A) – Nano Pin D3
Pin 8 (VCC2) – External motor supply (+5v)
Pin 9 (Enable 2) – Nano 5V
Pin 10 (Input 3A) – Nano Pin D4
Pin 11 (Output 3Y) – Stepper motor winding (B+)
Pin 12, 13 (Ground) – Common ground
Pin 14 (Output 4Y) – Stepper motor winding (B-)
Pin 15 (Input 4A) – Nano Pin D5
Pin 16 (VCC1) – Nano 5V
 
 
Input and output assignments
 
Nano Pin D9 à Home limit switch (NO) à Common ground
Nano Pin D10 à Pushbutton (NO) à Common ground
Nano Pin D12à 330Ω Resister à Position 100 LED à Common Ground
Nano Pin D13à 330Ω Resister à Position 700 LED à Common Ground
 
Note: The internal pull-up resisters in the Arduino Nano eliminate the need for external pull-up resisters for the limit switch and push button.
 
 
Part 4 – Power Supply Information
 
Although the stepper motor is rated for 5V and you are supplying a external 5v power supply the SN754410 has voltages losses in its output stages so the stepper motor windings will receive less than the stepper motor supply voltage.
 
The SN754410 also does not regulate motor current.  Before applying power, confirm the motor's winding current or winding resistance to ensure the driver is suitable. Use a separate regulated motor supply, not the Nano's 5V pin, and connect all the grounds together.
 
A 0.1 µF ceramic capacitor between driver pin 16 and GND, another between pin 8 and GND, and a suitable bulk capacitor across the motor supply to smooth out the voltage.
 
Next up, wiring everything up.
 
At this point I am all caught up with the research I have done to date so things will slow down a bit as I figure the next steps out.  I need to complete the wiring diagram and make a sketch to move the lever to the middle position of the throw so the throw bar can be homed when I do the final sketch.
 
Thanks for looking in
 
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca


deemery

#12
Ron, when I did my Arduino ball signal/crossing power controller, one thing I spent time learning was 'button debounce' code. 

From a design perspective, I did a simple state chart.  https://statecharts.dev  Drawing the picture and labeling the transitions was worth the time to make sure I had thought everything through.  Don't forget "no power" is the first state and "power turned on" is the first transition, but you've already started to capture power-up in your outline above.   (I actually did 2 of these.  One was the overall controller, and the second was for the button debounce logic.)

dave
Modeling the Northeast in the 1890s - because the little voices told me to

elwoodblues

Quote from: deemery on November 11, 2026, 11:16:10 AMRon, when I did my Arduino ball signal/crossing power controller, one thing I spent time learning was 'button debounce' code. 

From a design perspective, I did a simple state chart.  https://statecharts.dev  Drawing the picture and labeling the transitions was worth the time to make sure I had thought everything through.  Don't forget "no power" is the first state and "power turned on" is the first transition, but you've already started to capture power-up in your outline above.  (I actually did 2 of these.  One was the overall controller, and the second was for the button debounce logic.)

dave
Dave, I kind of did that with the operation sequence that stated the most obvious steps.  The above is a project in progress, It's how I tend to approach programming.  Start out with the general idea and then refine it as I go.  ;D  I've used the "denounce" code before but didn't think of that yet for this design, thanks for the reminder.
Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

elwoodblues

Ron Newby
General Manager
Clearwater Valley Railroad Co.
www.cvry.ca

Powered by EzPortal