Introduction: Stepper Motor Driving With Less Pins
To drive a stepper motor successfully (as for example, the unipolar 28BVJ-48 with its driver board ) what is needed is :-
1. a circuit to make about 500mA flow through 4 coils
2. and in the right order
3. and with the right timing.
This is can be done with logic circuits (or a program) and separate buffers, and four pins.
It can be done by using the logic capability of the buffers, a program on Raspberry Pi, and using two pins.
If you are not certain of three of the ways commonly used in driving a stepper motor GO TO STEP 2
The 4 buffers used to drive the coils are in the ULN2803/ULN2003. (ULN2003 on the driver board). The buffers are inverters, and are wired in pairs (see figure 5). The outputs are used to drive the coils ( each coil is connected to the buffer output and the coils are wired together to the +ve supply at the other end. (see figure 5)) The supply can be 5v to12v (with the above stepper motor) and the circuit imay be connected directly to a Raspberry Pi. The COM is connected to the +ve supply.
The output of buffer A is connected by a resistor (10kohm for 5v, 33kohm for 12v) to the input of buffer C Similarly buffer B and D are connected with a resistor. The circuit will work logically with just one resistor. viz when A is HI the output of A goes LO and LO is fed to C and turns its output off = HI. A LO on A's input turns off buffer A, the output goes HI, and the input of C goes HI making the C output go LO.
It has a fault. A is driven by a (weak) 3.3v logic, and C by a 5/12v level. The resulting differing currents through the coils attached to A and C can be heard to be different when the motor is connected!
Connecting another resistor from the output of C to the input of A corrects the above fault. With the second resistor, "A" turning off, turns on "C" which turns off "A"; it becomes a bistable. "A bistable with attitude". (see figure 5) Thus the buffers drive the coils but they are arranged such that when A is driving a coil C is not driving a coil; then, when A is not driving a coil C is driving a coil. (see figure 6) The same with B and D (see figure 6). To drive it , write a program that has to go A-B-C-D (note the order of the current waveforms in figure 6) :-
step 1 B= LO, A=HI(to start) wait. step 2 B=HI wait step 3 A=LO wait. step 4 B=LO wait, and then back to step 1 A=HI. The "wait" sets the frequency (try 10 milliseconds per wait). The truth table and circuit is in figure 6.
To reverse :- A-D-C-B
step 1 B=HI A=HI wait step 2 B=LO wait step 3 A=LO wait step 4 B=HI wait back step1 ............ Yes just invert B!
The bistable buffer has a some of interesting characteristics:-
1. both buffers can be set either high or low from one input. That is, one output HI one output LO.
2. short either input (with two tactile switches) will set either output to HI. (Press both switches, both HI! Let go of both switches and the circuit will remember the first to be let go...... )
3. the buffers are now "memory". If the logic input is an input (high impedance), the outputs will not change.
4. it is possible to "read" the memory. ( HI is 2.1v, LO is 0.5v, at input which is Raspberry Pi compatible))
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Testing the Circuit
The circuit can be tested using a breadboard, and a ULN2003, with perhaps 4 LEDs. Use 10 ohm (5 watt) loads instead of the coils for (hot) realism with a 1 amp, 5v supply. The other resistors are all 10kohm. The breadboard circuit can be safely connected to a Raspberry PI (even if 12v supply is used ). If 12v is used, change resistor values (change 10kohm to 33kohm, and use 22 ohm (10 watt) load resistors). The circuit is as figure 5. Two bistables ( 4 buffers) are required to drive a unipolar stepper with full step drive. (see figure 6). Compare this with figure 2. The two bistables may be driven with "0" and "1" (pin 2 and 3) connected to IN1 input, and "1" and "2" (pin 3 and 4) connected to IN2 input only. (The 4 diodes are still needed).
* It is easier to connect to two outputs of the Raspberry Pi and use a program, which by inverting B can reverse the direction of rotation of the stepper motor .
Perhaps a better way is to use the driver board supplied with the 28BYJ-48 stepper motor. The LEDs are already there. The board has IN1to IN4 which connect via a ULN2003 to outputs A to D. The following connections are made by 4 resistors (put (dupont) sockets on each end of each resistor and heat shrink tube to stop shorts):-
Look carefully at the socket to identify +v supply (its the one nearest to the supply connections)
A(output in 5 pin socket) to IN3 (for C) (opposite end of socket to +v supply)
B(output) to IN4 (for D)
C(output) to IN1 (for A) (can omit this for "Flip" (see text))
D output) to IN2 (for B) (can omit this for "Flip")
Logic input for A to IN1
Logic input for B to IN2
* IN1 and IN2 may be driven by the same program as above.
The loads for the buffers will be the resistors and LEDs. The motor can't be connected unless the four resistors can be soldered on the back of the board. Tricky! Touching a wire connected to 0v to IN1 then IN2 will light C and D, which should stay on!
Step 2: Three Ways to Make a Stepper Motor Run
Figures 1,2 and 3 show Wave drive, Full Step drive and Half Step drive for Unipolar ( one power supply ), permanent magnet, up to 500mA per coil, stepper motors. The diagrams showing the waveforms are of the coil current, not voltages. The "stator" is the moving, permanent magnet, part.
WAVE DRIVE Probably the easiest to wire-up, but it gives the lowest torque ("turning power") and the noisiest, slowest performance. The stator's magnetic pole is pulled to directly under the coil. But it does use the least power, as only one coil is "on" at a time. To reverse swap B and D or invert both B and D.
FULL STEP DRIVE The coil currents flow in two coils at the same time, 50% "overlapping" so that the stator is magnetically pulled to between two coils. (That is, half a step displaced from the "wave" drive.) It moves one step at a time like the "wave drive". The torque is 70% greater (but it is using twice the current), the maximum speed is increased, and noise is reduced..This is the preferred and usual way of driving a stepper motor. Note that the A waveform is an upside down version of C's waveform i.e. Inverted. Similarly for B and D. Reversing is by swapping or inverting B and D. The diodes (1N4148) ( figure 2) act as an OR gate, allowing a coil to pass current for two clock pulses.
HALF STEP DRIVE In this mode the A coil passes current for three clock pulses, but the "overlap" is 33%. Thus the coil currents "overlap" with the previous coil (D), then the A coil is "on" alone, then overlaps with (B) each for a third of the time. ( It may help to remember that the stator is pulled directly under the coil in "wave" drive and halfway to one side with "full step". Combining both drive methods gives the half -stepping). With this method the stepper runs smoother and there are 8 steps not 4 steps.
MICROSTEPPING The diagrammatic figure 4, shows 3 steps per coil although up to 10 steps are possible. If in the Half Step drive, the current in the individual coils is reduced to 50% when they "overlap", the current would stay constant. In this (simplified ) example the "overlap" is more (40%, ). The currents are now 100%, 70%+30%, 30%+70%. Which produces:- start of step, a third of a step, two thirds of a step. The rotation of the stepper motor becomes smoother as the number of steps is increased, and the electronic control becomes more complex.