Stepper Motor Controller using pic16f628a

Since I finished my degree in April, I have been looking for work. The search has been slow but hopefully soon I will be making the big bucks. To fill my spare time I decided to do something with the mounds of electronics and such sitting in my room. First is to build a robot using stepper motors.

Motor Controller

The stepper motors were purchased at a local auction house. They took apart old hard drives and printers and such selling the parts separately. You can usually barter and get a good deal, the ones being used in this circuit cost about $3 each. These particular motors are unipolar steppers. You can usually tell by the number of wires coming out. This one has 6 wires coming out of it: 2 green, 1 blue, 1 yellow, 1 red, and 1 white. In a 4 phase unipolar motor There are 2 coils which are center tapped and have a wire for each of phases. If the wire colours are random or if there were only 5 wires, then you would have to use an ohmmeter to distinguish between the phases and center tap. Fortunately for me 2 of the wires were the same colour, so they must be the center taps. Another plus was the wires were grouped in threes.

There is a lot of online literature about stepper motors and controlling them. A Google search turned up the circuit below. It uses a PIC microcontroller to sequence the steps, TIP120 Darlington pairs for the switching circuitry, and a 4050 hex buffer for logic levels and circuit protection.

schematic Motor Controller

For the first circuit I used a PIC 16F628A to test the stepper motor and find out how fast I could get it going. Just a note to people who have built or want to build the LVP, I had problems with trying to get the internal oscillator working. It might be a quirk with how this paricular chip works or a problem with how the configuration bits are being set with the programming software. But for the test circuit I used a 4 MHz crystal. A stepper motor works by pulsing each phase in a certain sequence. The delay between pauses determines how fast the shaft rotates. Beginning at a 50 ms delay I was able to get it down to 3 ms for this particular motor.

Doing some some quick calculations:
On the motor it states that each step is 7.5 degrees per step, so that makes 48 steps for one full revolution.
4 phases/step x 3 ms/phase x 48 steps/revolution = 576 ms/revolution
Converting to revolutions/second we get roughly 1.736
1.736 revolutions/second x 60 seconds/minute = 104.16 RPM, not a bad speed.

The motors are rated for 24V, But I am running them at 13V because that is all I had available.

Source code

Compiled hex file

For more Detail: Stepper Motor Controller using pic16f628a

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us: