Difference between revisions of "NU32v2: Using the L293D H-Bridge"
NickMarchuk (talk | contribs) |
NickMarchuk (talk | contribs) |
||
Line 13: | Line 13: | ||
[[Image:L293D_bidirectional.png|thumb|300px|Bidirectional motor control and truth table. Note the L293D contains the diodes internally.|center]] |
[[Image:L293D_bidirectional.png|thumb|300px|Bidirectional motor control and truth table. Note the L293D contains the diodes internally.|center]] |
||
You can drive a motor in both directions using two half- |
You can drive a motor in both directions using two half-Hs. Use the circuit above. Take care not to accidentally touch an output to an input (the pins are right next to each other). '''Touching a high voltage output to your low impedance, low voltage input can fry the pin or the entire PIC!''' |
||
Take a look at the bidirectional truth table. By calling one input the direction pin, and the other the velocity (from a PWM source), you can see how to control the direction and velocity of the motor. Note that by changing the direction pin when the PWM duty is 75%, the new velocity is only 25%! Correct for this in your code by altering your duty depending on the desired direction of the motor. |
Take a look at the bidirectional truth table. By calling one input the direction pin, and the other the velocity (from a PWM source), you can see how to control the direction and velocity of the motor. Note that by changing the direction pin when the PWM duty is 75%, the new velocity is only 25%! Correct for this in your code by altering your duty depending on the desired direction of the motor. |
Revision as of 16:43, 23 February 2011
The L293D is an IC that contains four half-H drivers. We will use it for bidirectional control of a DC motor. The output of a pin from the PIC is limited to <20mA, not enough to drive a motor. We use an h-bridge to amplify the current and allow use of a different voltage source to power the motor.
Here is the datasheet for the Texas Instruments version of the L293D. The following images are taken from this datasheet.
The L293D can be used to drive four motors in one direction only, or two motors bidirectionally. Vs is the logic supply voltage, or 3.3V for the PIC32. Vss is the motor supply voltage. Use your battery for Vss.
The truth table above is used to determine the output of a half-H. When the enable pin is low, the output is high impedance. When the enable pin is high, the output is the same state as the input, but uses Vss as a voltage and current source.
You can drive a motor in both directions using two half-Hs. Use the circuit above. Take care not to accidentally touch an output to an input (the pins are right next to each other). Touching a high voltage output to your low impedance, low voltage input can fry the pin or the entire PIC!
Take a look at the bidirectional truth table. By calling one input the direction pin, and the other the velocity (from a PWM source), you can see how to control the direction and velocity of the motor. Note that by changing the direction pin when the PWM duty is 75%, the new velocity is only 25%! Correct for this in your code by altering your duty depending on the desired direction of the motor.