Difference between revisions of "NU32v2: Using the L293D H-Bridge"
NickMarchuk (talk | contribs) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
'''THIS PAGE REFERS TO A PRE-RELEASE VERSION OF THE NU32 PIC32 DEVELOPMENT BOARD. FOR INFORMATION, SAMPLE CODE, AND VIDEOS RELATED TO THE PRODUCTION VERSION (2016 AND LATER), AND TO THE CORRESPONDING BOOK "EMBEDDED COMPUTING AND MECHATRONICS WITH THE PIC32 MICROCONTROLLER," VISIT [[NU32|THE NU32 PAGE]].''' |
|||
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. |
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. |
||
Line 9: | Line 12: | ||
[[Image:L293D_truthtable.png|thumb|300px|Truth table.|center]] |
[[Image:L293D_truthtable.png|thumb|300px|Truth table.|center]] |
||
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 |
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 Vcc2 as a voltage and current source. |
||
[[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]] |
Latest revision as of 05:28, 16 January 2016
THIS PAGE REFERS TO A PRE-RELEASE VERSION OF THE NU32 PIC32 DEVELOPMENT BOARD. FOR INFORMATION, SAMPLE CODE, AND VIDEOS RELATED TO THE PRODUCTION VERSION (2016 AND LATER), AND TO THE CORRESPONDING BOOK "EMBEDDED COMPUTING AND MECHATRONICS WITH THE PIC32 MICROCONTROLLER," VISIT THE NU32 PAGE.
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. Vcc1 is the logic supply voltage, or 3.3V for the PIC32. Vcc2 is the motor supply voltage. Use your battery for Vcc2.
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 Vcc2 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.