Rob Turner continues his discussions about motors. Check outA Few Words About Motors for the previous article.
Then I got my hands on the L293D motor driver chip (See motors part 1) and life got a lot easier. The L293D contains two H-bridges for driving small DC motors. Now the home-viewing audience might say: "Rob, its easy to drive DC motors. What I need to do is drive a stepper motor." No problem. After all, what is a DC motor but a coil and the L293D drives two of them backwards or forwards. Thats what stepper are - two (or more) coils being driven in a sequence, backwards and forwards. So one L293D can, in theory, drive one bi-polar 2 phase stepper, if you supply the sequence.
I found some close-out two-phase bi-polar steppers (part#117954) in the Jameco Catalog. For six bucks plus shipping I get a 7.5 degree stepper with 48 steps per revolution. The stepper motor runs at about 5 volts and pulls 800 milli-amps of current. Thats a lot of current so I can expect my chips to heat up. The way I fix the heat problem is by gluing a heat sink to the top of the chip. Any piece of metal three or four times the size of the chip will do. If things get real hot, I use a small fan to move air over the top of the heat sink.STEPPER CONTROLLER SCHEMATIC
I realize that Seattle has developed its own mutant breed of controller circuits, I think its based on the 68HC12, but I have successfully resisted all attempts to be lured to the dark side of the force and will continue to use the BS-2 (Basic Stamp II). Here is a real quick description of the L293D inputs:
1, 9 Enable pins. Hook them together and you can either keep them high and run the motor all the time, or you can control them with your own controller.
2,7,10, 15 Control the two coils. Here is how you pulse them for a single cycle:
|STEPPER TABLE||COIL A1||COIL B1||COIL A2||COIL B2|
3,6,11,14 Here is where you plug in the two coils. You want to ohm them out and make sure you get one coil hooked up to 3,6 and another one hooked up to 11,14.
4,5,12,13 Gets hooked to ground.
8 Motor voltage, usually about 6 volts.
16 +5 volts. Its a good idea to keep this power supply separate from your motor power.
And here is the schematic to hook the BS-2 and the L293D together. Hey, Ive even included the code!
The software to program the Basic Stamp II can be found in stepprog.bs2
Notice that this single chip can handle a two coil stepper otherwise known as a two-phase stepper motor. If you want to do more than that, you need more chips. The cool thing is that if you have multiple steppers and you want to drive them one at a time (say on a PC board driller), its easy to have multiple L293Ds driven on the same line.
Lets say you get this thing all hooked up to your microcontroller and it doesnt work. Here are a couple of symptoms and what they point to as the cause. Since Ive had the misfortune of experiencing each one of these problems personally, I thought I might be able to save you a little time and pain.
Symptom: The stepper motor shaft turns easily with fingers.
Cause/solution: No power to the circuitry, no power to the motor, or enable pin is low.
Symptom: Everything on, but motor is locked in one position.
Cause/solution: The L293D got the first position and thats all. Check software, check connections, and check that the hard-wired ports match the software. You might want to pull out the logic probe.
Symptom: Everything on, stepper is shifting in position, but the motor wont turn.
Cause/solution: The correct line isnt getting pulsed. Either the software is trying to pulse the wrong line, or the lines are connected incorrectly. First thing to do is slow the pulses way down. Next, try different combinations of the lines or software. You are looking for a pulse series that increments the motor continually in one direction.
Symptom: Motor pulses, but its erratic and sometimes changes direction. Using your fingers you can turn the shaft either direction even though you still feel a pulse.
Cause/solution: One of the coils isnt energizing. Check your wiring and your software. You might want to put the circuit to the probe or unplug the motor and check the voltages.
Symptom: Motor pulses, but the direction is wrong.
Cause/solution: Reverse the pulse order in the software or turn the cable around.
Symptom: Circuit over-heats quickly without anything working. You hear a pop, see smoke, and one or more chips crack and/or turn to carbon.
Cause/solution: Congratulations! you have reversed one or more voltages and fried one or more components in your circuit!
Im getting a Snappy 3.0 Deluxe and a camcorder so I can post some pictures of my robots on the web.
Of course now that Im getting a camcorder, I want to make some tapes of my robots walking. I need to know an easy, fairly inexpensive way of editing and mass-producing the video. Can you help me out? Please write me at ROBT612@aol.com Thanks!