H Bridge

From Imperial College Robotics Society
Jump to: navigation, search


H bridges provide a convenient way of controlling you motors allowing you to move them both forwards and backwards and with a higher power than that supplied by a micro-controllers pins.

How an H Bridge Works

Basic-bridge.gif
Current-fwd.gif

An H bridge is so called because it resembles an H with the motor in the center, controlled by 4 switches (see image to the left). It is easiest to think in terms of mechanical switches but in reality transistors are used to act as electrical switches. This setup allows us to control the motor and drive it either forwards or backwards.

To drive the motor in one direction, say left, we would close the switches labeled high left and low right, thus allowing current to flow, whilst opening the other switches. An example of this can be seen on the right. Doing this would cause the motor to spin in one direction and by swapping all of the switches we can drive it in the other direction.

Many H bridges, such as the commonly used L293, have a single electrical input that activates both switches in a pair, thus making it easier to use. Another function of an H-bridge is that it allows you to also cruise and brake a motor. To allow a motor to cruise one obviously just opens all switches so that no current continues to flow. However, to brake the motor one simply closes both high or both low switches. When this is done the spinning motor acts as a generator, inducing a voltage that works against itself, thus rapidly coming to a stop.





Wiring up an L293

The L293 is a commonly used H bridge and allows for two motors to be driven forwards and backwards or four motors to be driven in a single direction. The ship is almost symmetrical and each side operates individuality. Below is a diagram showing one side being used to drive a motor in both direction and the other side to drive two motors in a single direction. The pins are labeled 1 through to 16 in an anti-clockwise direction starting from the top left as shown. The top of the chip can be identified by the little indent. The entire area enclosed within the dotted line is the chip, whilst the circles labeled M are motors. The black arrows with a line are diodes, they restrict the current to flowing in a single direction. Their purpose is to protect the chip from current spikes but are not always necessary, some versions of this chip include protection inside the chip.

L293.png

Regardless of how you are using your chip you must power it correctly. This is provided through 8 on the left hand side. The chip is capable of handling a supply voltage of 4.5V to 36V. You must also ground the central two pins, 4 and 5 on the left and 12 and 13 on the right. However, to activate the motor we must also provide an activation voltage between 2.3V and 7V to pin 1 on the left and pin 9 on the right. Without this activation input the motors will not drive. Do not connect the activation directly to the power rails as anything over 7V will fry the chip. You must also connect pin 16 to a 5V source to power the logic of the chip as well.

Single Motor - Dual Direction

The outputs to the motor can be connected to pins 3 and 6 on the left and pins 11 and 14 on the right. As we are driving it in both directions it is usually unimportant which way it is wired around and can be adapted to in the code or by reversing the motor outputs. To control the motor we supply a "high" voltage to either pin 2 or 7 to drive it left or right (11 or 14 on the right hand side of the chip). A low voltage is recommended for this as anything over 7V through this input will fry the chip. A voltage above 2.3 is considered "high" and translates to an input. Remember to include the activation. To control the motor you can simply connect these two pins to a micro-controller output, usually a PWM output, and then activate them when you want the motor to drive.

Dual Motor - Single Direction

One connector to each motor can be connected to pins 3 or 6 on the left and pins 11 or 14 on the right. The other end is connected to ground. As we are driving the motors in a single direction you may need to reverse the motor connectors to reverse the direction. To control the motors we supply a "high" voltage to either pin 10 to control the motor connected to pin 11 or pin 15 to control the motor connected to pin 14 (on the left hand side pin 2 controls the motor at pin 3 and pin 7 controls the motor at pin 6). A low voltage is recommended for this as anything over 7V through this input will fry the chip. A voltage above 2.3 is considered "high" and translates to an input. Remember to include the activation. To control the motors you can simply connect these two pins to a micro-controller output, usually a PWM output, and then activate them when you want the motors to drive.