This project is designed to allow you to create a reusable module for Bi-Polar Stepper applications based on a L293D H-Bridge. An H-bridge is a circuit that allows you to reverse the polarity of a DC circuit. They're used to control the direction of motors.
A typical H-bridge has two inputs, two outputs, and two voltage supplies. The voltage supplies are called logic supply, typically about 5 volts at a few milliamps, and motor supply which can be any amount of voltage and amperage that your motor needs. This particular H-bridge needs a 5-volt logic supply, and a 5-to-30-volt motor supply. The motor supply can control up to 1 amp. If you send a small amount of voltage into the input (whatever the logic supply voltage is), it will allow voltage to flow from the H-bridge's motor supply to the corresponding output. Likewise, if you take the input pin to ground, the output goes low.
The L293D is a "Standard Quadruple Half-H Driver" which means that it's got two H-bridges in it. It's functionally the same as the SNXXXX chip, another quadruple half-H driver.
Stepper motors can be used to create projects that require fine motor control. A bi-polar stepper has two coils that have to have their polarity reversed in a set sequence in order for the motor to move. H-bridges are perfect for this task.
To control the inputs of an H-bridge, you need a microcontroller. You'll find sample code here for the PIC micrcontroller in PicBasic Pro, and the [# Arduino] and [# Wiring] microcontroller modules. If you don't like those, you can use any other microcontroller you prefer.
Please let us know what you've done!
Step 1: Get some stuff...
This one is pretty simple, mostly just get yourself some wire and two capacitors but here is the list.
1. Black Wire (22AWG, solid)
2. Red Wire (22AWG, solid)
3. Green Wire (22AWG, solid)
4. Blue Wire (22AWG, solid)
5. Yellow Wire (22AWG, solid)
6. 1 10 uF Capacitor (Electrolytic Radial Lead)
7. 1 1uF Capacitor (Electrolytic Radial Lead)
8. 1 Small Solderless Breadboard ( we're using one 3.25"x2.125", 400pnt )
9. Line of 4 male headers
10. Line of 4 female headers
11. 2 sets of 2 female headers
Honestly, you can do it all in chartreuse if you can find it, but the colors we are using are pretty standard.
Red = Power
Black = Ground
Blue/Red/Yellow/Black = stepper control lines
There is some green wire that we are going to use to hold the enable pins to logic power (more on that later). Some times those pins might go to something else other than just clean straight power, so we decided to differentiate them a bit.
Step 2: Get your HBridge (or IC socket) settled in
Especially with the Breadboard and Perfboard tracks it is nice to get what you are working around nice in settled in so you know you are hooking up to the right pins!
Pin 1 is going into e13 for us. All the coordinates given will be based on that. The top of the chip is where the little divit is. Just for kicks we've included some pictures from the data sheet (attached to this instructable ), including the pin diagram. Conveniently they also have a very official looking schematic for controlling a bipolar stepper. That is pretty much what we are building. We are going to be building our own schematic right along with this tutorial do you can start to see the connection.
Step 3: Get power connected
Put the two sets of the female headers in the board so you know where your voltage inputs are.
The input in c1 and c2 going to the left side of the board is for the motor powersource - referred to as Vcc2 on the datasheet. This can be anywhere from 5 to 36 volts, depending on how much voltage your motor needs. Red and black wires connect a1 and a2 to the red and blue supply lines on the left side of the board, making that side the motor supply voltage side of the board.
The header in d2 and d3 is for logic power - referred to as Vcc2 on the datasheet. This should be 5 volts, from the same voltage source as your microcontroller. These lead-ins define the voltage levels for logic signals to the H-bridge's inputs. If the H-bridge didn't have a logic supply and ground in common with the microcontroller, it wouldn't know what voltages represent on and off, or 1 and 0.
Be sure you're clear on the different voltage supplies on the two sides of the board. You can destroy a chip or spend hours troubleshooting a circuit if you don't know what the voltages on your supply lines are.
Step 4: Add some capacitors and connectors for the motor...
Now that we have the power lines in, we should buffer them a little with capacitors. If you like the electricity-as-water analogies - your motor going on and off and moving is going to create a lot of waves and the capacitors act as mini-flood planes to help smooth out the flow. 10 uF for the motor side. 1 uF for the logic side. We are using polarized capacitors because they last longers... make sure the "painted" side is going to ground!
Also added in this step is the sockets for connecting the micro-controller and the stepper motor in the last step.
The inputs for this board are all going in on the top left and the outs on the bottom right.
stepper-in 1 = a4
stepper-in 2 = a5
stepper-in 3 = a6
stepper-in 4 = a7
stepper-out 1 = j25
stepper-out 2 = j26
stepper-out 3 = j27
stepper-out 4 = j28
Step 5: Get some power going... II
Now we are read to power the chip itself.
1. Lines in from ground to a16, a17, j16, j17 (pins 4, 5,13,12: if you ever end up needing to hook up a heat sink to cool of your chip - these are the pins you do it on).
2. Line in from motor-power to a20 (pin 8)
3. Line in from logic power to j13 (pin 16) This is the pin that does two things - tells the chip that the X volts you are sending into the board on d3 is what "1" is and provides power to the chip itself.
Step 6: H-Bridge... enabled!
The HBridge will not allow power to pass through it without permission. You are now going to give it permission. Permission must come from LOGIC POWER not the motor power because you don't want to end up sending 12 volts through this puppy some day and really regret it.
So we mentioned the funky green wire before, and here it is!
So we've got two lines coming in from the logic power to j9 and j10. We then have a wire coming h9 down to d13 (pin 1). This wire enables the the left hand side of the chip. There is another wire running from h10 to h20 powering up pin 9.
Why did we do it this way? Why didn't we just send the nice red wire straight through? Because these are not simply power lines. Sometimes (frequently) it is really nice to hook these two pins up to a microcontroller and turn them on and off to conserve power, or pulse them to control speed. In this case we are doing the easiest thing possible and just setting them at full blast all the time, but is good to know that they are a little bit special!
Step 7: Motor lines in...
The motor lines coming from the microcontroller will eventually slot into the female headers, but for now we've got:
Blue from b4 to b14 (pin 2)
Red from c5 to c19 (pin 7)
Yellow from d6 to i19 (pin 10)
Black from e5 to h14 (pin 15)
Step 8: Motor lines out!
Blue from d15 (pin 3) to f25
Red from b18 (pin 6) to f26
Yellow from g18 (pin 11) to g27
Black from h15 (pin 14) to h28
Now we are ready to hook this baby up!
Step 9: All hooked up.