Bipolar stepper motor control with PIC16F877A microcontroller

Cd-Rom bipolar stepper motor control using PIC16F877A microcontroller and CCS PIC C compiler

Most of cd-rom or dvd-rom drives has a bipolar stepper motor, this motor has two windings and each winding has 2 inputs which means that this type of motor has 4 wires.
 Bipolar stepper motor windings

This topic shows circuit schematic and C code for controlling the bipolar stepper motor speed and direction using PIC16F877A microcontroller.
The stepper motor can be controlled in full step mode or half step mode. The full step mode is a little bit easier than the half step control mode. In this topic the full step control mode is used.
To control the bipolar stepper motor we need two H-bridge circuits and for that L293D motor driver chip is used, this cheap chip can work as a dual H-bridge drivers.
In the full step control mode always both windings are energized according to the following two tables where table1 shows the driving sequence for rotation direction 1:
Bipolar stepper motor direction 1

And the following table shows driving sequence for the other rotation direction:
Bipolar stepper motor direction 2

Interfacing PIC16F877A with bipolar stepper motor circuit:
The following image shows circuit schematic diagram of this project where two pushbuttons are used to choose motor rotation direction and a potentiometer to control motor speed. PortB internal pull-ups are enabled in the C code.
PIC16F877A bipolar stepper motor interface circuit
The PIC16F877A needs +5V supply on its VDD and VSS pins.

Interfacing PIC16F877A with bipolar stepper motor CCS C code:
A pot connected to AN0 is used to control the speed of the stepper motor. The microcontroller reads the analog data from AN0 and uses the digital value to change the delay between motor driving phases and when the delay increases the motor speed decreases and vise versa.
The two pushbuttons which are connected to RB0 and RB1 are used to choose motor rotation direction and when RB0 button pressed the driving sequence follows the first table above and when RB1 button is pressed the driving sequence follows the second table.
8-bit ADC resolution is used.

Interfacing PIC16F877A with bipolar stepper motor video:
The following video shows the project in hardware circuit.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.