Download PDF Parts List View on YouTube Download Code

Introduction

Stepper motors are an ideal choice for accurately moving and positioning mechanical devices. Using techniques like microstepping the position of the motor shaft can be controlled with a great deal of precision.

Stepper motors are available in a wide range of sizes. On the small end of the scale are the steppers used within DVD and Blu Ray drives to position the laser head. On the other end of the scale are huge steppers that can control the position of industrial-sized 3D printers and CNC machines.

Using the larger stepper motors with an Arduino is not very different from using smaller ones. The main difference is in the selection of a driver module.

Stepper Motors & Drivers

We have covered stepper motors in detail in an earlier article and video, so if you need a refresher please see the previous material.

Big Stepper Motors With Arduino

In the previous article, we learned that stepper motors are available in two common wiring configurations, Unipolar and Bipolar. Most large stepper motors are bipolar, meaning that they have 4-wires, two per coil assembly.

Bipolar stepper motors can be driven using dedicated modules or with H-Bridges. In the previous article, we used both an A4988 stepper module and an L298N H-Bridge to drive bipolar stepper motors with an Arduino to drive a common NEMA 17 size motor.

To use a larger stepper motor we will need a bigger driver or H-Bridge, one that is capable of handling the current our motor will require.

Motor Specifications

Let’s take a look at the specifications of the stepper motor we are going to be using today. This is a NEMA 23 Bipolar Stepper Motor from Stepperonline.

This motor has the following specifications:

  • Step Angle: 1.8 deg
  • Holding Torque: 3.0Nm(425oz.in)
  • Rated Current/phase: 4.2A
  • Voltage: 3.78V
  • Phase Resistance: 0.9ohms
  • Inductance: 3.8mH ± 20%(1KHz)
  • Frame Size: 57 x 57mm
  • Body Length: 113mm
  • Weight: 1.8kg

As you can see from the size and weight, this is a BIG motor!

Large Stepper Motor

Most of the specifications are pretty self-explanatory. But one of them might seem a bit strange.

The voltage is rated at 3.78 volts. Which, to many people, may seem a bit on the small side!

The voltage rating is NOT the maximum voltage that the stepper motor can handle, nor is it the operating voltage that  the manufacturer recommends you use in your design. The voltage rating is actually just a mathematical calculation:

CURRENT (4.2 Amps) x RESISTANCE (0.9 Ohms) = VOLTAGE (3.78 Volts)

If you were to apply a static DC voltage to the stepper motor coils then you would apply 3.78 volts to get the 4.2 amps of holding current.

In real life, you don’t do that. You send pulses to the motor, pulses that are affected by the motor’s inductance as the pulses increase in frequency. To overcome this effect you apply a higher voltage to achieve the same 4.2 amp current.

When reading the stepper motor specifications the current is the key parameter you need to pay attention to, not the voltage.  You can easily drive this motor with a 36-volt power supply, as long as your motor driver limits the current.

Once you know the current requirements you can select the power supply and a motor driver. Keep in mind that as you will be microstepping the motor you’ll need to double the current requirements, as you will often have two coils engaged simultaneously.

Microstep Drivers

While it is possible to make use of a large H-Bridge to drive our big stepper motor it is more common to use a dedicated driver module, known as a Microstep Driver.

Microstep drivers are available in a range of voltage and current ratings.  They accept logic signals to pulse the motor and control its direction.

Many common microstep drivers are sealed modules with terminals and heat sinks.  They all look relatively the same, and they are hooked up and used in a similar fashion. The difference between them is the voltage and current ratings.

Microstep Drive

You should choose the microstep driver based upon your motor current requirements.  The microstep driver you select will have a range of operating voltages, this will determine the voltage requirements for your power supply.

Note that this common style of microstep drivers is setup using a bank of DIP Switches, located on the side of the unit next to the wiring terminals.  The case of the microstep driver has all of the details you’ll need to set the DIP switches correctly.

There are two main groups of switches:

  • The Current Group. These switches set the maximum current delivered to the stepper motor coils. It is important that you do not exceed your motor ratings.
  • The Microstep Group. These switches determine how many input pulses are required to rotate the motor one turn. Not all stepper motors can be microstepped at extreme settings.

Before you get started with the experiments it would be a good idea to set the current switches to suit your stepper motor.

Microstep Driver DIP Switches

Some microstep driver modules, like the MA860H module I used in the experiments here, can accept both AC and DC voltage for a power supply.  The voltage requirements and ranges for your microstep driver will be printed on its case.

When you are installing a microstep driver on a permanent location make sure to allow for heat dissipation. These driver modules have large heatsinks, mine has a fan on it as well.  You’ll also want to allow for heat dissipation for the stepper motor as well, as they can run very hot when operated under a heavy load.

Arduino Demo

A microcontroller like an Arduino is an ideal way of controlling a stepper motor using a microstep module.  

The microstep module requirements are actually pretty simple. It uses three control signals, all of them are inputs:

  • PUL – This is the Pulse that steps the motor.
  • DIR – This is a logic signal to set the motor Direction.
  • ENA – This is an Enable signal,

In most installations you can ignore the ENA (Enable) connections and let them float, this will result in the module always being enabled. You can use the ENA connection if you want to implement an emergency stop or shutdown system.

Arduino and Stepper Motor Hookup

The hookup of the Arduino to the microstep driver module is illustrated here:

Arduino Stepper Hookup

Note that we are driving the negative inputs of the modules, instead of the positive ones. The positive inputs are all connected to the Arduino 5-volt output.

This might seem strange, it is due to the inputs on the modules actually being balanced inputs that accept 5 to 24 volts (at least that was the spec on my module).  

Balanced inputs are used to allow for long unshielded twisted-pair wires in an industrial environment with a lot of electrical noise. As long as we keep the connections short we can use our Arduino in an unbalanced wiring configuration.

You’ll also notice I add a potentiometer and a push button switch. The potentiometer will control the stepper motor speed while the push button will reverse its direction.

I’m showing a 24-volt power supply in the diagram as it is what I used for my motor tests. You should use a supply that is suitable for your microstep driver, as mentioned before it can also be an AC transformer instead of a DC power supply if your module accepts AC power.

Arduino Sketch

Here is the sketch we will be using to control our stepper motor:

It is a pretty simple sketch and requires no libraries.

We start by defining the pins we will be using for the switch, the connections to the microstep driver and to the potentiometer connected to the analog A0 input.

Next a couple of variables to represent pulse width and direction,

After that, there is a function, which also happens to be an interrupt handler that is triggered whenever the push button is pressed. It’s a simple function that just toggles the value of the setdir variable, which is a boolean representing the motor direction.  The result is that pressing the button reverses the motor.

In the setup, we define our connections to the microstep driver as outputs and then set up our interrupt handler.

In the loop, we read the value of the potentiometer and use it to set the pulse delay value pd variable.  The longer the delay, the slower our motor will spin.

We use the setdir variable to set the value of the DIR output, to set motor direction.

Then we create a pulse manually, by holding the PUL output high for the period defined by the pd variable.  We then hold it low for the same period.

After that the loop repeats.

Testing the Stepper and Microstep Driver

Setup your stepper motor and driver in a safe fashion, as large stepper motors can cause a lot of damage if left unsecured.  I held my motor in my bench vise during testing.

Stepper Motor in Vise

Before powering everything up double-check the position of the DIP switches, make sure that you have the current settings correct.

Set the pulses per rotation to a value of at least 800 to start with, and turn the potentiometer fully counterclockwise so the control is outputting its slowest speed.

Power up the Arduino and then the microstep driver.  Observe the indicators on the microstep driver, generally the green one is power and the red one indicates a fault condition.

The motor should be turning now, if not power everything off and recheck your wiring. Use a multimeter to measure the motor coil resistance if there is any doubt regarding the wiring. Also, make sure that the motor polarity is correct or the coils will be out of phase.

If all is working you should be able to control the motor speed with the potentiometer, and the direction using the push button switch.  As the switch is not debounced you may get erratic operation. Debouncing could be done either in hardware or using code.

Keep in mind that the switch can also serve as a limit switch, you could have two in parallel and use them at each end of the desired travel to reverse the motor direction.

You could achieve better performance using an electronic switch, such as an optical or hall-effect switch.

Demo with AccelStepper

The AccelStepper library is a popular library for using stepper motors with the Arduino. In the previous article about stepper motors I used the AccelStepper in a few examples.

You can also use AccelStepper with the microstep drivers.  Let’s do that now, we will keep the wiring of our demo as it is and just use different code.

Getting AccelStepper

If you have already gone through the demos in the previous article about stepper motors then you likely have the AccelStepper library installed in your Arduino IDE already.  If you haven’t then you’ll need to install it first.

The easiest way of adding the AccelStepper library to your Arduino IDE is to use the built-in Library Manager.

  • Click on the Sketch menu item on the top menu.
  • Click on Include Library. A sub-menu will open
  • Click on Manage Libraries. This will open the Library Manager in its own window.
  • In the Filter box type “AccelStepper”.
  • The AccelStepper library will be listed. Click on the Install button to add this library to your IDE.

AccelStepper Demo Sketches

Once the AccelStepper library is installed in your Arduino IDE you’ll have access to a number of demonstration sketches. You can use these to try out your microstep driver.

You can open the test sketches as follows:

  • Click on the File menu item on the top menu.
  • Click on Examples. A sub-menu will open.
  • Navigate down to the section labeled Examples From Custom Libraries.
  • Select AccelStepper.
  • A sub-menu will open with a number of AccelStepper example sketches.

A good demonstration sketch is the Bounce sketch from the AccelStepper example sketches.

You will need to modify one line in the sketch (and all of the demo sketches) to setup the stepper object correctly.

Modify the AccelStepper line as follows to use it with the hardware that we already wired up:

AccelStepper stepper(1,7,6);

This line sets up AccelStepper in “mode 1”, which is the correct mode for using microstep driver modules.  The “7” and “6” refer to the Arduino pins used for the direction (DIR) and pulse (PUL) connections.

After modifying the Bounce (or another example) sketch send it up to the Arduino and test it out. Try modifying the microstep settings to see the results.

You may use the above technique to modify other sketches based upon the AccelStepper library.

Conclusion

As you can see using large stepper motors with an Arduino is pretty simple, thanks to the microstep driver module.

When you are experimenting with large stepper motors make sure you put safety first!  A motor with this much power can do a lot of damage if it gets out of control, and you could injure yourself if you are not careful.

Stepper Motor Test Setup

Always be sure of your electrical connections before applying power. If you are planning to run the motor for any appreciable period of time make sure that the microstep driver and the motor have adequate ventilation.

By observing some common sense safety procedures you can design some powerful and impressive projects using a large stepper motor, an Arduino and a microstep driver module.

Now step to it!

 

Parts List

Here are some components that you might need to complete the experiments in this article. Please note that some of these links may be affiliate links, and the DroneBot Workshop may receive a commission on your purchases. This does not increase the cost to you and is a method of supporting this ad-free website.

COMING SOON!

 

Resources

Stepper Test Sketch – The sketch I wrote to test the stepper motor with the potentiometer and push button switch.

 

 

 

Using BIG Stepper Motors with Arduino
Summary
Using BIG Stepper Motors with Arduino
Article Name
Using BIG Stepper Motors with Arduino
Description
In this article, you'll learn how to read stepper motor specifications and how to select a microstep driver. We'll then hook it all up to an Arduino and control the stepper motor speed and direction.
Author
Publisher Name
DroneBot Workshop
Publisher Logo
Tagged on:
Subscribe
Notify of

58 Comments
Oldest
Newest
Inline Feedbacks
View all comments
lars
4 years ago

What driver would be a good option if you wanted to drive more high current stepper motors?

saeed
4 years ago

Hello sir
how are you
I am very very impressed with the projects you are working on and follow up on your YouTube page and I learned a lot from you
I want to ask if you are programming (Step Driver- BL/TB6560-v2.0) similar to (Using BIG Stepper Motors) that you are doing .

Michael Mckinney
4 years ago

I have a crazy idea and need some help with my project, I don’t have any skills in programming or working with the Ardruino , but I’m sure I could learn from your videos, my BIG question is, can I use sensors to get the Stepper motor to turn, I want to be able to hold a wireless sensor attached to my head for example, build a motorized turntable that I can stand on and when I turn my head it would turn the stepper motor and rotate the turntable in that direction. 1 is this possible to do with… Read more »

George
4 years ago

Myo arm band

Akshay
4 years ago

Thank you so much for your expertise. I have one question, we are developing 5 dof robotic arm using stepper motor but the problem is, we are trying to rotate all motors at the same time but it won’t run. Can you please share some suggestion for this query.
thank you.

salah
4 years ago
Reply to  Akshay

your exiplanation good I wonder if posible to add sellection swithch to change the direction wright or left

Leonardo Villamonte
3 years ago
Reply to  Akshay

You need to set your motors to work based on a timer interrupt routine and make sure you dont have delays anywhere in your code if you want to share me your code and diagrams i could maybe help. Good luck

Nick
4 years ago

Hello and thank you for all the videos. They have been very helpful. I have the very same stepper motor as in your “big steppers” video. My driver is the DM556T and using the Arduino Atmega 2650, wired the same as your video except i am manually changing the variable “pd” with the code instead of with a potentiometer. Also with the exception of the potentiometer missing from the code, my code is the same as the video. Variable “pd” set with larger numbers are slower than smaller numbers. When pd is set to 100k (100000) it is slower than… Read more »

Klaus Nielsen
4 years ago

I found the youtube video and “got you” that way.
Very good “deep going” article. Even though I have done one project with a stepper motor this article has brought me at lot more understand of stepper motors that I didn’t have before.
Thanks.
Klaus

Toni
4 years ago

Thank you very much for this intro and your video on it! I used it to control my first big stepper motor, and it works!

John
4 years ago

Hi, How would I control the direction and speed of the motor from a distance. I want to use RS485 to control the Arduino from a distance of about 300m.

Thanks
John

Harry Vaughan Sr.
4 years ago

Need Help Can’t get stepper motor with arduino and div265n to rotate 150 times stop delay and reverse 150 times.Can only get it to rotate 10 times at 1/8 micro stepping.

Matthew B Pulliam
4 years ago

Hi, I’m trying to wrap my head around how to match steppers and drivers…

You state that current is key in the motor specs and chose a motor with a Rated Current/phase: 4.2A.
You then state, “Keep in mind that as you will be microstepping the motor you’ll need to double the current requirements”

so this would be 8.5A

Then you have picked a Microstep Motor Driver 2.4-7.2A

So it would seem that this isn’t providing enough current? Please clarify why this is driver is a compatible choice?

Thanks,
Matt

BarryS
3 years ago

The stepper driver has constant-current outputs. That means, it will limit the current to your dip-switch settings… even though using ohm’s law with the motor resistance and power supply voltage, the current would be much, much higher. The driver limits the current to your setting. A coil, like that in the stepper motor, has a lot of inductance. When you apply a voltage to it, the current doesn’t immediately go got the ohm’s law-calculated value. It takes time for the magnetic field to build up, and as it does, the current increases. So, if you want that field to build… Read more »

Jacques
3 years ago

if 4.2A is the required current for your stepper, then you have to select dipswitches of your controller for 4.2A but your Power supply must deliver at times 8.4A when microstepping. hope this clarifies

Ronaldo Franco Martins
4 years ago

Muito Obrigado, Parabens
Ronaldo
SĂŁo Paulo – Brasil

Jacob
4 years ago

How can you control the motor using the arrow keys of the computer and is it also possible to enter a range of numbers and hit the enter key and the motor would go to those numbers??

Luis
4 years ago

Hello. I have a setup with 2 stepper drivers, both are far from my arduino UNO.
Instead of connecting the 5V from the Arduino to a Breadboard and then both drivers to the breadboard, can I connect PUL+ and DIR+ to a different 5V Power Supply? Or it has to be connected to the Arduino?

If PUL+ and DIR+ are compatible with 5V or 24V, can I use any power supply within that range?

BarryS
3 years ago
Reply to  Luis

The outputs of your arduino are only 5V maximum. To connect it to a higher voltage power supply, you would need to add a driver transistor between the arduino output and the input of the stepper driver. Without that dirver transistor, you will fry your arduino’s output and maybe the whole board. The buffer would be a small signal transistor, like a 2N3904, with the emitter grounded, the base connected through a 2-10k resistor to the arduino output pin, and the collector connected to the PUL- pin on the stepper driver. Your additional power supply’s “-” would connect to the… Read more »

Ralph Hulslander
3 years ago

I am having problems, I posted on the Forum there was no response.

Marty
3 years ago

3 years ago

hello sir,
My name is Mohamad Santos From Indonesia
I want to consult with you about making automatic doorstop coding with RFID and ultrasonic sensors. can you help me? thank you

Manaf Zivingy
3 years ago

How much is the value of the resistor connected to the push button? and why didn’t connect the GND of Arduino to the GND of 24 volt power supply?

C IJpelaar
3 years ago

I did this, however the button does nothing.

3 years ago

can you provide sketch for max speed test for nema 34 and 23 114 mm

Gary M. Oosta
3 years ago

Many thanks — again. Your explanation of how to use the T6600 with a NEMA motor is clear and work! DroneBot Workshop is my go to site.

Erroll
3 years ago

it would be lovely if I could transfer the file to the IDE

Neil
3 years ago

Would be great to display some sort of output on a LCD or 7 segment display to be able to set the same speed again after adjusting the pot, any ideas?

jofe
3 years ago

hi! i am starting to learn arduino, and i appreciated the video that you made in youtube, i learned from it, hope you make some video about cnc router carving for arduino. thank you sir,

Joseph Strelczuk
3 years ago

how do you debounce the reverse switch in the program. I have the same program and set up.

Joseph Strelczuk
3 years ago

second question how do you make it so the motor does not start when you turn on the power supply?
I want to make it so the potentiometer can stop the motor and adjust speed. but in the program you have I can only control speed and cant stop the motor when turned down all the way. I have tried many changes in the program but cant figure it out. I would appreciate the insight.

David Santos
3 years ago

can you make sketch for cnc using two stepper motor

Jose Colautti
3 years ago

thanks for the clear explanations. I had some doubts with the way we must consider the current calculation on the driver, but reading the answer to the “posts”, it almost clear to me now!!!

Fernand Gagne
3 years ago

vitesse maximal pour un moteur pas Ă  pas

carter
3 years ago

This motor has the following specifications:Step Angle: 1.8 degHolding Torque: 3.0Nm(425oz.in)Rated Current/phase: 4.2AVoltage: 3.78VPhase Resistance: 0.9ohmsInductance: 3.8mH ± 20%(1KHz)Frame Size: 57 x 57mmBody Length: 113mmWeight: 1.8kg The parameters of this motor are the same as this stepper motor, and motiongoo is a stepper motor manufacturer, so it has better quality and cost performance. And it is recommended to match this stepper motor driver, which is a fully digital stepper driver with good performance, and the maximum motor drive current is 4.2A, which coincides with the 4.2A current of this motor. The manufacturer of this drive is Leadshine, a famous Chinese… Read more »

carter
3 years ago

Very detailed introduction, thanks!

RICARDO MD
3 years ago

I have a problem… I don’t know why but my potentiometer is not working, I move it and it doesn’t make any difference, I even disconected and it’s always the same: the motor moves very slowly. I have checked the connections numerous times and I even change my motor and driver twice. I believe I have an error on the code but I just copy and paste the one from the video so it should have worked…

Could someone please help me, please?

vaios
2 years ago

hello arduino …world i am a new arduino user and i have a problem with my big stepper (nema 24) control, i am using potentiometer same as burrys wonderfull example but i found a problem to get high speed , here the simple code int driverPUL = 6;    // PUL- pin int driverDIR = 7;    // DIR- pin int spd = A0;     // Potentiometer   int pd = 15;       // Pulse Delay period void setup() {     pinMode (driverPUL, OUTPUT);   pinMode (driverDIR, OUTPUT);   }   void loop() {        pd = map((analogRead(spd)),0,1023,2000,50);     digitalWrite(driverDIR,HIGH);     digitalWrite(driverPUL,HIGH);     delayMicroseconds(pd);     digitalWrite(driverPUL,LOW);     delayMicroseconds(pd);   } but when i am trying a simplest version by changing the delay time manually it runs …much higher , i am guessing something wrong with the delay time ?  int driverPUL = 6;    // PUL- pin int driverDIR = 7;    // DIR- pin int spd = A0;     // Potentiometer   int pd = 15;       // Pulse Delay period… Read more »

Nat
2 years ago

Is it possible to use a unipolar stepper motor with 6 wires with one of these micro step drivers?

2 years ago

Thank you for an excellent article and video. I have used the design that you have here to make such a driver for the stepper motor I am using to power my Rose Engine woodturning lathe. I am writing an article for my woodturning club magazine. Please may I include a copy of the circuit diagram and a link to your YouTube video and this page in the article?

bob neff
2 years ago

very helpful tutorial. connected all equipment and download the sketch exactly as per your directions. the potentiometer works fine for speed control. However, i have problem with the REVDIR (pushbutton) control. it doesn’t work. tried switching to input -3 and changing delay to 1000msec, but no effect. the button appear to work per simple OHM test. wiring holes on breadboard seem ok too. any thoughts???

bob neff
2 years ago

update on my prior post. if I change either the LOW or FALLING values to HIGH or RISING, recompile the sketch & upload, the motor will reverse directions. therefore, it appears like the // interrupt handler, setdir = !setdir is not working. signed “still confused”.

bob neff
2 years ago

PROBLEM SOLVED. The STEPPERONLINE driver had a one line comment in manual. “DIR signal should be ahead of PUL signal by 5microsec at least”. so i swapped line positions of the driverPUL, OUTPUT with driverDIR, OUTPUT in the sketch. putting driverDIR ahead of driverPUL. Reversing action now works perfectly!!

Hendrik Bouwer
2 years ago

Good afternnon, im new to arduino programming and setting up stepper motors with micro controllers. I would like to know how to program a forward switch, reverse switch and stop switch, not push bottons. As i am adding push buttons later to bump the motor forward or in reverse.

Warren
2 years ago
Reply to  Hendrik Bouwer

Search for Paul McWhorter’s YouTube channel. He has lots of videos about programming Arduino.

James Brisson
2 years ago

How could I do this with the arduino grbl 1.1v board ? Not sure where the pul and dir wires would go

2 years ago

Hello sir
I’m using NEMA17 with rhino1106 motor everything is working perfectly with the code u have mentioned. But couldn’t print the pot values in serial monitoring even after adding print function need help with that please can you share some suggestion for this. Thank you

2 years ago

Thanks a lot for this article! It was very helpful!

Lappies
1 year ago

Hi There
I am using the code for the big stepper motor with arduino wit POT Speed control and Push button for direction.
Can someone please help me with the debounce code for the button as it does not always work properly?
Many thanks
lappies

Colin (Valkrider)
1 year ago
Reply to  Lappies

Add this to the setup section

Johannes
1 year ago

Hi
on the stepper with potentiometer with push button, I would like to add debounce to the code but I am new in the game.
Can someone please help me with the code with debounce in it for the push button?
Regards
Johannes

Colin (Valkrider)
1 year ago
Reply to  Johannes

Add this to the setup section

zaid
1 year ago

Thank you so much for your expertise.

Rex uchenna allwell
1 year ago
  • Hello sir,thanks so much for your projects especially in your YouTube videos, I’ve learned a lot from you,and am planing to start an arduino base pick and place machine project,but I want to ask sir.,how many stepper motors can you control with arduino mega
Colin (Valkrider)
1 year ago

I have been using this code and wiring for some time without issue. I recently added another motor to my setup and had problems with the stepper motor misbehaving. See this thread in the forum.

What fixed my issue was a suggestion from @davee to make a modification to the code by adding the below to the setup section which resolved my problem.

Robert Bucek
1 year ago

This may be a stupid question, but what’s the best way to power the arduino in this application? If I’m using a 24v 8amp power supply for my motor, once it’s in use I don’t want to power it through the serial port with another separate power supply.

Rahims
7 months ago

Hallo
Does Reference Current of MA860H is the same as phase current of stepper motor?
E.g. If I want to achieve rated torque performance of my stepper motor, do I need to set reference current of MA860H at the same (or closest) value as stepper motor’s rated phase current?
Or I must multiply motors phase current by 2 (because of 2 phases) to get the drivers reference value for rated torque performance?

Best wishes and greetings from Latvia!
Rahims.

Theodore Wilson
7 months ago

I appreciate your work. I am looking to control the stepper motor i have front and back limit switches.
I have a on off on switch to controll direction.

I an willing to add a second momentary switch for the jogg function.

I need two forward speeds, a jog and a cut
The reverse will be at tbe jogg speed.