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

From Mech
Jump to navigationJump to search
Line 3: Line 3:
Here is the [[Media:L293D_TI.pdf|datasheet for the Texas Instruments]] version of the L293D. The following images are taken from this datasheet.
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.|center]]
[[Image:L293D_circuitdiagram.png|thumb|300px|Circuit diagram. Note: the L293D contains the diodes internally (but the L293DNE does not).|center]]


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 current. Use your battery for Vss.
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 current. Use your battery for Vss.
Line 11: Line 11:
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.
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.


[[Image:L293D_bidirectional.png|thumb|300px|Bidirectional motor control and truth table.|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-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!'''
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!'''

Revision as of 16:41, 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.

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. Vs is the logic supply voltage, or 3.3V for the PIC32. Vss is the motor supply current. Use your battery for Vss.

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 Vss 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.