Bipolar stepper motor drive with PIC18F4550 and CCS C

Stepper motor interfacing with PIC18F4550 microcontroller

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 PIC18F4550 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 PIC18F4550 with bipolar stepper motor circuit:
The following image shows circuit schematic diagram of this project a potentiometer connected to AN0 channel is used to control the speed as well as the rotation direction of the stepper motor as shown in the video below.
PIC18F4550 Bipolar stepper motor control circuit
PIC18F4550 internal oscillator is used (8MHz) and MCLR pin function is disabled, it needs +5V on its VDD and VSS pins.

Interfacing PIC18F4550 with bipolar stepper motor CCS C code:
The following code is the full C code of this project where a potentiometer which is connected to channel AN0 is used to control the rotation direction and the speed of the stepper motor.
The microcontroller reads the analog value from the output of the pot and uses the digital value to control the rotation direction and the speed with ADC resolution of 8 bits.

Interfacing PIC18F4550 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.