Difference between revisions of "NU32v2: Using the L293D H-Bridge"

From Mech
Jump to navigationJump to search
(New page: The L293D is an IC that contains four half-H drivers. We will use it for bidirectional control of a DC motor. Image:L293D_circuitdiagram.png Image:L293D_truthtable.png [[Imag...)
 
 
(8 intermediate revisions 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 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.
[[Image:L293D_circuitdiagram.png]]


Here is the [[Media:L293D_TI.pdf|datasheet for the Texas Instruments]] version of the L293D. The following images are taken from this datasheet.


[[Image:L293D_circuitdiagram.png|thumb|300px|Circuit diagram. Note: the L293D contains the diodes internally (but the L293DNE does not).|center]]
[[Image:L293D_truthtable.png]]


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.


[[Image:L293D_bidirectional.png]]
[[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 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]]

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.

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.

Circuit diagram. Note: the L293D contains the diodes internally (but the L293DNE does not).

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.

Truth table.

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.

Bidirectional motor control and truth table. Note the L293D contains the diodes internally.

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.