Ever removed removing stepper motors from old printers. Well, most of the stepper tors you find in the old printers are bipolar stepper motors. Bipolar stepper motors have a permanent magnet rotor and two coils in a stator at 90 degrees to each other.
Simple bipolar stepper |
Full step sequence of a bipolar stepper motor |
Enough on the details, let's get onto the driving one. The motor I used was one with full step of 7.5 degree step angle. A voltage of 9v were applied to the motor while it drew a current of about 100mA during operation. I used Arduino mega 2560 which was interfaced with L298N motor controller circuit for the purpose
L298N motor driver ciruit |
The next step was to program the arduino. The following code was written to drive the motor continuously in one direction
//defining connections to L298N
int input1 = 22;
int input2 = 23;
int input3 = 28;
int input4 = 29;
void setup()
{
pinMode(input1,OUTPUT);
pinMode(input2,OUTPUT);
pinMode(input3,OUTPUT);
pinMode(input4,OUTPUT);
}
void loop()
{
//1st step
digitalWrite(input1,HIGH);
digitalWrite(input2,LOW);
digitalWrite(input3,LOW);
digitalWrite(input4,HIGH);
delay(10); //small delay between each step of 10ms
//2nd step
digitalWrite(input1,LOW);
digitalWrite(input2,HIGH);
digitalWrite(input3,LOW);
digitalWrite(input4,HIGH);
delay(10);
//3rd step
digitalWrite(input1,LOW);
digitalWrite(input2,HIGH);
digitalWrite(input3,HIGH);
digitalWrite(input4,LOW);
delay(10);
//4th step
digitalWrite(input1,HIGH);
digitalWrite(input2,LOW);
digitalWrite(input3,HIGH);
digitalWrite(input4,LOW);
delay(10);
}
Arduino was given 9v and the circuit was powered up. Ta - Dah. Here you go. Your application may vary from driving the motor continuously in one direction. Now, its all up to you to make-break this code to tune into your application. Cheers :)