NU32v2: Using the L293D H-Bridge

From Mech
Revision as of 16:42, 23 February 2011 by NickMarchuk (talk | contribs)
Jump to navigationJump to search

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