Stepper Motor Interface PIC16F
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.
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
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
Current Project / Post can also be found using:
- servo motor pic16f