Stepper motors are not like simple DC motors and cannot be driven by providing just DC voltage.Driver circuit & a microcontroller are needed to control the speed & direction of a stepper.
With a stepper motor you can “step” exactly a given angle. Further the stepper motor has the advantage of having a holding torque.Steppers are able hold their position when they are not moving.
Stepper motors are available in two varieties : unipolar or bipolar.
Bipolar motors are the strongest type of stepper motor and usually have four leads. They have two sets of electromagnetic coils internally, and stepping is achieved by changing the direction of current within those coils.
Unipolar motors, identifiable by having 5,6 or even 8 wires, also have two coils, but each one has a center tap. Unipolar motors can step without having to reverse the direction of current in the coils, making the electronics simpler. However, because the center tap is used to energize only half of each coil at a time they typically have less torque than bipolar.
Unipolar motors typically have two coils per phase, one for each direction of magnetic field.
Bipolar motors typically have one coil per phase, and current flows in both directions through this coil. Thus, the bipolar motor will be able to produce twice as much torque, since at any given time, the unipolar motor is only using half of its windings
BIPOLAR steppers generally have 4 wires & are best driven by a H BRIDGE IC like L293 (500 ma current) or L298 ( 2 amps).
One thing you’ve to keep in mind is that when using a stepper driver, you are powering the driver, not the motor. The driver will take over powering the motor for you.
To find out the phase of coils in a 6 wire Stepper , we shall make use of a simple Multi meter.
Put one lead of Meter on any of the 6 wires of Stepper & look out for continuity with other 5 wires.You can find 2 sets of 3 wires having continuity .
As seen in above screenshot , keeping one end of meter probe on any of the wires you can identify the continuous wires.The meter will show some resistance value if there is a continuity.
Identify the set of 3 wires & make a knot to separate the 2 set of 3 wires.
Now you can easily identify the center tap of the 3 wires.With respect to the center tap wire the other ends show an equal resistance value.
Here the green wire of one set of 3 wires is the center wire & it shows exactly half the value of total resistance with other 2 wires of the coil .
On the other set of 3 wires , the black wire is the center one.
To use this motor as a Bipolar one , simply leave out the center wires (here it is the green & the black ones).
Now each phase of coil has only 2 wires , which can be easily driven by a H bridge IC L298.
Leave out the 2 center tap wires & then connect the 2 sets of wires to M1,M2 & M3,M4 of the L298 board.M1/M2 is for first coil & M3/M4 for the second coil.
We shall make use of an Arduino UNO board to control the Stepper .
An external power supply of 12v/1Amp is required for the L298 board.If you try to power the L298 from Arduino it will cause damage to your Arduino.
Following is the code to be uploaded on to Arduino. Before uploading , we shall understand the code so that the connections are made accordingly between Arduino & L298 board.
—————————————————
#include <Stepper.h>
int clockwise= 2;
int anticlockwise= 3;
int steps =200;
int enable=8;
Stepper motor(steps, 10,11,12,13);
void setup() {
pinMode(clockwise,INPUT);
pinMode(anticlockwise,INPUT);
pinMode(enable,OUTPUT);
Serial.begin(9600);
}
void loop() {
int Speed = analogRead(A0);
int RPM = map(Speed, 0, 1023, 0, 100);
int forward = digitalRead(clockwise);
int reverse = digitalRead(anticlockwise);
digitalWrite(enable,LOW);
if(forward == 1 && reverse == 0 && RPM > 5){
digitalWrite(enable,HIGH);
motor.step(1);
motor.setSpeed(RPM);
delay(10);
}
if(reverse == 1 && forward == 0 && RPM > 5){
digitalWrite(enable,HIGH);
motor.step(-1);
motor.setSpeed(RPM);
delay(10);
}
delay(5);
Serial.println(“Speed of motor is “);
Serial.println(RPM );
}
————————————————————
Initially we’re including the Stepper library Stepper.h.
An instance called “motor” is initiated for the Stepper class, with Steps = 200 (generally step angle of Stepper is 1.8 deg.For a full rotation of 360 deg we need 200 steps 200 x 1.8 = 360).
Pins 10,11 of Arduino assigned to control coil 1 & connected to IN1,IN2 of L298.
Pins 12,13 of Arduino assigned to control coil 2 & connected to IN3,IN4 of L298 board.
Two push switches are used to control the direction of Stepper.One switch is connected to pin 2 (clockwise) & the other one to pin3 (anticlockwise).The connections are made so that when a switch is pressed , a HIGH (5v) is applied to Arduino pins 2 or 3 accordingly.
The speed of Stepper is controlled by a 10k potentiometer which is connected to A0 of Arduino.The analog value of potentiometer is mapped to a value between 0 and 100 & assigned to a variable RPM.
According to the conditions of Switches (clockwise or Anticlockwise) & RPM set by the potentiometer the Stepper will move accordingly.
Important point to take note:
Pin 8 of Arduino is assigned to ENABLE ,which is connected to both EN1,EN2 of L298 board.While starting the loop Enable is made LOW & it’s made HIGH only when a switch is pressed.This ensures that the Stepper is not enabled at idle conditions.If you’re not controlling the ENABLE pin , the L298 IC will heat up even when the Stepper motor is not running.This will damage the L298 IC and the Stepper motor , as well.
Connection Details
L298 BOARD Arduino Board
EN1 & EN2 —–> 8
IN1 —–> 10
IN2 —–> 11
IN3 —–> 12
IN4 —–> 13
M1/M2 — 2 wires of first coil of stepper.
M3/M4 — 2wires of second coil of stepper.
CW switch —–> 2 , one end of switch connected to +5v, other end grounded through 10k .
CCW switch —–> 3
12V/1A adapter connected to GND/12V of L298
Both GND pins of L298 & Arduino made common
10k Potentiometer – center pin to A0 , top pin to +5v & bottom pin to GND
Watch this support Video :