Unipolar stepper motor control with PIC18F4550 – CCS C

Unipolar stepper motor drive with PIC18F4550 microcontroller

Unipolar stepper motor drive with PIC18F4550 microcontroller
After interfacing PIC18F4550 microcontroller with bipolar stepper motor in the following topic:
Bipolar stepper motor drive with PIC18F4550 and CCS C

Now let’s see how to drive a unipolar stepper motor using PIC18F4550 and CCS PIC C compiler.
Usually the bipolar stepper motor has 2 colis and therefore it has 4 wires, and the unipolar has 4 coils which are connected as shown in the following figure:
Unipolar stepper motor coils

The unipolar stepper motor can be controlled in full step mode or half step mode, the usual method is the full step driving mode which gives higher torque. The following table shows driving sequences:
Unipolar stepper motor driving sequence

Interfacing PIC18F4550 with unipolar stepper motor circuit:
In the circuit there are 2 pushbuttons which are connected to RB0 and RB1 pins, they are used to choose motor rotation direction. PortB internal pull-ups are enabled in the software.
To control the stepper motor speed a potentiometer (10K) is used and it is connected to analog channel 0(AN0).
ULN2003 (or ULN2004) chip is used to energize the stepper motor coils.
The ULN2003(ULN2004) is a Darlington transistor array which contains seven open collector Darlington pairs with common emitters. For stepper motor controller we need 4 transistors form this chip which means 4 inputs and 4 outputs are needed.
PIC18F4550 stepper motor control circuit uln2003
Instead of the ULN2003 chip, another chip can be used which is L293D dual H-bridge circuits as shown in the circuit schematic below.
For the L293D chip VS voltage always +5V and VSS voltage is the same as the motor voltage for example if the motor voltage is 12V, VSS should be connected to +12V power supply.
PIC18F4550 stepper motor control circuit l293d
PIC18F4550 internal oscillator is used (8MHz) and MCLR pin function is disabled.
The PIC18F4550 microcontroller needs +5V between its VDD and VSS pins.

Interfacing PIC18F4550 with unipolar 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 sequences.

Interfacing PIC18F4550 with unipolar stepper motor video:
The following video shows project hardware circuit.


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top