https://dronebotworkshop.com/big-stepper-motors/
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.
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!
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.
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.
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:
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:
/*
Stepper Motor Test
stepper-test01.ino
Uses MA860H or similar Stepper Driver Unit
Has speed control & reverse switch
DroneBot Workshop 2019
https://dronebotworkshop.com
*/
// Defin pins
int reverseSwitch = 2; // Push button for reverse
int driverPUL = 7; // PUL- pin
int driverDIR = 6; // DIR- pin
int spd = A0; // Potentiometer
// Variables
int pd = 500; // Pulse Delay period
boolean setdir = LOW; // Set Direction
// Interrupt Handler
void revmotor (){
setdir = !setdir;
}
void setup() {
pinMode (driverPUL, OUTPUT);
pinMode (driverDIR, OUTPUT);
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
}
void loop() {
pd = map((analogRead(spd)),0,1023,2000,50);
digitalWrite(driverDIR,setdir);
digitalWrite(driverPUL,HIGH);
delayMicroseconds(pd);
digitalWrite(driverPUL,LOW);
delayMicroseconds(pd);
}
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.
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.
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!
Resources
Stepper Test Sketch – The sketch I wrote to test the stepper motor with the potentiometer and push button switch.
'사물인터넷' 카테고리의 다른 글
Using Rotary Encoders with Arduino (0) | 2021.07.04 |
---|---|
Build a Digital Level with MPU-6050 and Arduino (0) | 2021.07.04 |
Stepper Motor with Hall Effect Limit & Homing Switches (0) | 2021.07.04 |
I2C Between Arduino & Raspberry Pi (0) | 2021.07.04 |
EEPROM with Arduino – Internal & External (0) | 2021.07.04 |