For precisely moving and positioning mechanical items, stepper motors are the best option. The position of the motor shaft can be precisely adjusted by using techniques like microstepping.
There are numerous sizes of stepper motors available. The steppers that DVD and Blu-Ray drives employ to position the laser head are at the low end of the scale. On the other end of the spectrum are big steppers that can regulate the positioning of CNC and 3D printers that are industrial in size.
The big stepper motors can be used with an Arduino in a manner similar to the smaller ones. The choice of a driver module is where the primary differences lie.
What is a Stepper Motor?
A stepper motor is a synchronous, brushless electric motor that transforms digital pulses into mechanical shaft rotations. A stepper motor’s rotation is broken down into a specified number of steps, often as many as 200 steps. For each step, a different pulse needs to be supplied to the stepper motor. Only one pulse can be received by the stepper motor at a time, and each step must be the same length. You can precisely control the position of the stepper motor without a feedback device since each pulse causes the motor to rotate at a precise angle, typically 1.8 degrees. The stepping movement transforms into a continuous rotation with a rotational speed that is directly proportional to the frequency of the control pulses as the digital pulses from the controller increase in frequency. Due to their incredible accuracy, stepper motors are utilized in devices like 3D printers, CNC machines, laser engravers, and others.
The printer is more capable of accuracy the smaller the available step. Because the stepper motor on certain machines has a full step of 0.04 mm, it is recommended that you select a layer height that is divisible by 0.04. But thanks to a feature known as microstepping, 3D printers have other options besides taking single, complete steps.
Microstepping
Microstepping is the splitting up of a large step into several smaller ones. These more minute steps, sometimes known as “microsteps,” are frequently expressed as fractions with a denominator that is a multiple of 2, including 1/16, 1/32, or 1/64. As we previously noted, microstepping enables the motor to spin over a smaller distance than a full step.
The stepper motor winding is energized by microstepping in a way that splits the number of positions between the poles even more. A full step (1.8 degrees) can be divided into 256 microsteps by some microstepping controllers. One rotation (.007 deg/step) would have 51,200 steps. Microstepping is typically used in situations where precise positioning and more fluid motion over a wide speed range are necessary. Microstepping, like half-step mode, reduces torque by around 30% in comparison to full-step mode.
In this tutorial, we will see how to program the NEMA stepper motor with Arduino.
Hardware Required
- NEMA Stepper Motor
- Microstep Driver
- Power Supply 12VDC
- Arduino Mega / Arduino Uno
- Jumper Wires
Software – Arduino IDE
Wiring Diagram
Follow the wiring diagram for your connection with Arduino and the stepper motor.
The micro step driver has differential inputs for their step and direction inputs, usually called “PUL+” and “PUL-” (for”pulse” or “step”) and “DIR+” and “DIR-” (for “direction”).
The DIR+ and PUL+ are connected to the digital pins 2 and 3 of the Arduino. The negatives are grounded.
The stepper motor is connected to the A and B pins.
The stepper motor is hooked up to a 12VDC power supply.
Code (1)
Open your Arduino IDE, and paste the following code. The great news is, you don’t require any external libraries to control the motors.
#define dirPin 2
#define stepPin 3
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
// Set the spinning direction CW/CCW:
digitalWrite(dirPin, HIGH);
}
void loop() {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
- You start the code by defining the pins for the DIR and the PUL – setting the direction and pulse of the motor.
- Then declare the output pins as the step pin and the dir pin.
- In the void loop, which is the main part of the code, set HIGH for the stepPin which is the pulse of the motor for a period of time, and then set them to LOW. Repeat this to make a number of rotations.
- Give some delay, the longer the delay, the lesser the speed of the motor.
Similar Article – Using Stepper motors with Arduino