Introduction: Bipolar Stepper Motor

About: Electrical Engineer

I had some stepper motors from broken  HP printers ,hard drive and other electronic devices  ,So I thought that it would be a good idea to make them work.
in the beginning I started with uni-polar stepper motor (5,6 wires) with ATMEGA8 MCU and ULN2003 driver  and it simply works  but for Bipolar stepper motor(4-wires),  it was real challenge to me to make it rotate because the polarity should be reveres in each steps  ,so after some web searching I found the solution with  L298 IC  which is 4 Amp. dual H-bridge driver.

Step 1: Materials

For H-Bridge Materials:
1- PCB (single side printed circuit board).
2- L298 Dual H-bridge driver.
3- 100 uF capacitor.
4- 0.01 uF ceramic capacitor.
5- 7805 voltage regulator.
6- N4001 diode (Qty. 8 diode).
7- 1/2 W 1 Ohm resistors (Qty. 2 resistors).
8- Sockets and wires.
9- Heat sink for L298.
10-Bipolar Stepper Motor.

For Controller Circuit :
1- Atmega16 plus IC holder.
2- 100 uF capacitor.
3- 0.01 uF ceramic capacitor.
4- Socket for ISP.
5- 7805 voltage regulator.

Note that you need only one 7805 regulator but I used two because I made both circuit individually for test purpose.

Step 2: Circuit Digram

For the Circuit diagram
M1 connected to Coil A for stepper motor.
M2 connected to Coil B for stepper motor.
R1 & R2 1 Ohm resistors for current limiting.

I recommended to test  L298 circuit before connecting micro controller to avoid any damage for the Atmega16 chip.
To Test the circuit ,connect  two 12 volt DC motor one to M1 and the other to M2.
 Connect +5 volt  to ENA ,ENB & IN1 (Now M1 should rotate in specific direction ,M2 off).   
 Connect +5 volt  to ENA ,ENB & IN2 (Now M1 should rotate in reverse direction ,M2 off).
 Connect +5 volt  to ENA ,ENB & IN3 (Now M2 should rotate in specific direction ,M1 off).
 Connect +5 volt  to ENA ,ENB & IN4 (Now M2 should rotate in reverse direction ,M1 off).
if the test passed successfully you can now connect L298 to ATmega16 circuit as below:
PA0 --- IN1
PA1 --- IN2
PA2 --- IN3
PA3 --- IN4
PA4 ---ENA
PA5 ---ENB

Also find the attached datasheet for L298 for more information.

Step 3: PCB Work

I use proteus software to draw PCB diagram ,I attached all needed files below to any one want to use or modify on this circuit.

PCB work steps:
1-Print the diagram on Photo paper on over head paper using laser printer (don't use inkjet printer ,it wont work).
2-Wash PCB and dry it well.
3-Stick the circuit on the PCB .
4-Set the Iron on maximum temperature and push strongly on PCB for about 15 minutes till the toner stick to PCB.
5-Remove the paper using you fingers and water.
6- Put the PCB in ferric Acid taking in consideration all safety precaution.
7- after Etching clean the PCB from ACID and use Acetone to remove the toner.
8-drill the holes and start to set the components and solder them.

Step 4: Controller Circuit

Any Micro controller will work for this circuit it depend on what you have in your area market and the price ,in my case I made simple Atmega16 development circuit as shown in the picture.
Note that crystal shown in the diagram not connected .

for programming Atmega16 I use AVR MKII ISP (In system programmer device ).

Step 5: C Code

Copy below code and Paste it in AVR studio or use the attached file.
Also the attached pictures showing all the steps you need to export code to MCU using AVR studio4 .

#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
int i;
while (1) //loop forever
// Rotate Anti-Clockwise
for (i=1;i<50;i++)    //Loop from 1 till 50
PORTA =0b00110001;   //ENA,ENB & IN1=1 othere=0
_delay_ms(15);       // wait
PORTA= 0b00110100;   //ENA ENB & IN3=1 Others=0
_delay_ms(15);       //Wait
PORTA= 0b00110010;   //ENA ,ENB &IN2=1
_delay_ms(15);       //Wait
PORTA =0b00111000;   //ENA,ENAB &IN4=1
_delay_ms(15);       //Wait
// Rotate Anti-Clockwise
for (i=1;i<50;i++)   //Loop from 1 till 50
PORTA =0b00111000;   //ENA,ENB & IN4=1 othere=0
_delay_ms(15);       // wait
PORTA= 0b00110010;   //ENA,ENB & IN2=1 othere=0
_delay_ms(15);       //Wait
PORTA= 0b00110100;   //ENA,ENB & IN3=1 othere=0
_delay_ms(15);       //wait
PORTA =0b00110001;   //ENA,ENB & IN1=1 othere=0

Hurricane Lasers Contest

Participated in the
Hurricane Lasers Contest