Summary of Stepper Motor Interface PIC16F
This article details interfacing a PIC16F microcontroller with unipolar stepper motors using a ULN2003A driver instead of an L293D. It explains identifying coils via resistance measurement and using the PIC to determine winding order by feeling motor movement. Four specific motors from printers were tested, including Mitsumi, Minebea, and Canon models, utilizing 4 I/O pins on PORTC for control.
Parts used in the Stepper Motor Interface Project:
- PIC16F Microcontroller
- ULN2003A Driver
- Unipolar Stepper Motors (5 leads)
- Digital Voltmeter (DVM)
- 4 I/O Pins on PORTC
Here is a simple example for PIC microcontroller interfacing Unipolar stepping motor with assembly code. Instead of using a dedicated stepper motor driver IC like very popular L293D
PIC16F with ULN2003A
were used. Just 4 I/O Pins are required to drive each coil of the motor. By energizing each coil in a particular sequence you can control the speed and direction of the motor. 4 lower bits of PORTC are used for controlling the step motor
, triple nested loop is used to delay winding switching to about 200ms. Decrease the delay for more speed but not too much, otherwise your motor will “stall” . More advanced code should be available in a few weeks. I’m planning to expand a Solar Power Charger design by adding solar tracking capabilities using stepping motors, so this small project is a good beginning for testing various designs and interfacing techniques. 4 Unipolar step motors were tested (5 leads), see attached schematic and pin out for each motor, these motors were dismantled from old printers and scanners.
So now we’ll need to identify the individual coils and common connection of the motor. Use your DVM to measure resistance between pairs of wires, it should be around 120 Ohm. The terminal with half of measured resistance is a common wire, connect it to positive voltage 5-12V depending on the motor.For identifying each coil there are a lot of techniques available, however I’ve used PIC to help me to find out the winding and connect them correctly. As explained above PIC will repeatedly send “1” to each coil according to its number. At this point you know were common wire is and it’s already should be connected to a positive voltage. Take one of the wires and assume that it’s Coil 4 and connect it to ULN2003A
Coil 4 output. Now you can use your fingers to feel the small movements every pulse and its direction. Take additional wire and connect it for example to Coil2 output, feel the direction of the movement. If it’s a correct wire the direction will be the same and the duration will increase with each attached wire till you have assembled them in correct order. At this point you can slightly decrease the switching delay to get continues rotation. I’ve used this method on 4 motors and managed to find the correct winding in 15 minutes.
First step motor is Mitsumi M42SP-4NP.Common – Red,W4 – Yellow,W3 – Orange,W2 – Black,W1 – Brown.
Next is PM35S-048-ZTP8 Minebea Electronics. Common – Red,W4 – Brown,W3 – Yellow,W2 – Black,W1 – Orange.
Now for Canon QH4-4115 Stepper Motor. Common – Black,W4 – Red,W3 – White,W2 – Yellow,W1 – Brown.
The last motor had no marking, but its wires configuration was the simplest among all tested steppers. If you hold it looking at the back of the motor the first wire from the left is a common followed by W1,W2,W3,W4.
That’s it for now. I’ve also found 2 Bipolar motors with 4 leads we’ll see if a simple PIC interface can be built and published.
For more detail: Stepper Motor Interface PIC16F
- What components replace the L293D driver?
The project uses a PIC16F microcontroller paired with a ULN2003A driver. - How many I/O pins are required to drive each coil?
Only 4 I/O pins are required to drive each coil of the motor. - Which port is used for controlling the step motor?
The 4 lower bits of PORTC are used for controlling the step motor. - How can you identify the common wire in the motor?
The terminal showing half of the measured resistance between pairs of wires is the common wire. - What voltage range should be applied to the common wire?
A positive voltage between 5 and 12 volts should be connected to the common wire. - How do you verify the correct winding order of the coils?
You connect wires sequentially to the ULN2003A outputs and feel for consistent direction and duration of movement. - What happens if the switching delay is decreased too much?
Decreasing the delay too much will cause the motor to stall. - Where did the tested motors come from?
The motors were dismantled from old printers and scanners.

