Tutorial: Simple H-bridges

  1. ScuD's Avatar
    ScuD ScuD is offline Positronic Brain
    Category
    Introduction
    Views
    18,788
    Replies
    6
     

    Simple H-bridges

    Difficulty
    Moderate
    Skills Required
    Basic electronics knowledge
    Simple soldering skills
    The H-bridge:

    The H-bridge is a commonly known, and commonly used way to drive a brushed DC motor.
    It allows for simple forward/reverse drive, and enables the user to employ PWM driving of the motors to obtain a speed control.

    It consists of four "switches", which can be basically any electronic component that can conduct or isolate a current / voltage depending on an input current or voltage.

    The principle is shown below, using two pairs of NPN/PNP transistors


    Note the two control lines, X and Y. Both lines are connected to the base of one NPN transistor, and one PNP transistor.
    This means that eg. if X is high, the NPN transistor (the top one) will conduct, and the PNP transistor will isolate (the bottom one).

    The two control lines can be steered according to the following truth table:
    Code:
    X    Y
    0    0      Both PNP's conduct
    0    1      Left PNP conducts, right NPN conducts, motor rotates CW
    1    0      Left NPN conducts, right PNP conducts, motor rotates CCW
    1    1      Both NPN's conduct
    In the table above, we can see it's easy to have the motor rotate in either direction, it's simply two inverted bits.
    If they're both the same, the motor is in free run mode and it will just coast to a halt.

    note: a different design of the H-bridge allows for a braking mode, but it needs security measures since it is possible to short out the driving transistors.

    The arrangement of a PNP and NPN transistor as in the schematic above is known as a push-pull configuration and is widely used in electronics, such as the final stage of an audio amplifier.
    It is also used in lots of logic gates, eg. buffers.

    Now, using some circuit bending we can abuse these buffers as H-bridges to drive small motors.

    For this example I'm using the 74hc240 Inverting octal 3-state buffer to build a simple H-bridge.

    In this extract of the datasheet we can see the buffer uses a push-pull configuration of two FET's. Since it is an Octal buffer, it has 8 of these configurations, or 4 pairs of them.

    So in theory, we could build 4 H-bridges with just one of these chips! So why hasn't anyone done it?
    Simple, the buffers are designed to buffer data. They're not meant to handle big currents, the chip we're using in the example can only drive 35mA per pin.

    Most DC motors will draw a lot more than 35mA, so how can we overcome this problem?
    Well, since we've got 4 pairs of drives, let's put them in parallel.

    http://users.pandora.be/svendecock/r...C240Bridge.PNG

    Schematic above shows how we can use 4 buffers in parallel, so we can draw currents of up to (4*35) 140mA.
    Note that the 74hc240 uses enable lines to enable the buffers. Keep in mind you'll need to drive these to enable the buffers. In this case, inverse logic is used, so the enable lines need to be driven low in order to activate the buffer outputs.

    In the schematic above, make sure to add the 4 diodes. These flyback diodes are needed to short out back-EMF from the motor, to make sure the drivers aren't damaged. Any diode can be used, although high-speed low threshold ones are recommended

    So now we can steer a motor which draws a current of 140mA. In some cases, this isn't enough and you can add more buffers, either by literally stacking chips one on top of the other and soldering together the leads, or by simply connecting them in parallel through a pcb.

    Commercial H-bridges

    DC motors on robots, however, tend to draw much higher currents than 140mA, some up to 1000x (!) as much. Obviously, it's not feasible to use 1000 of these chips to drive big motors.
    One alternative is to use commercially available H-bridges, such as the L298 dual full-bridge driver.

    This chip contains two H-bridges, is simple to hook up, and sports a current drive of 2A continuous per channel. Once again, you can connect the drives in parallel to get 4A continuous current drive.



    Above an extract from the datasheet, showing the basic schematic for driving a Dc motor in full bridge. Once again, an enable line is used (Ven, pin 11) and flyback diodes are mounted.
    On the schematic, resistor Rs can be omitted. It is a sense resistor and can be used to measure what current the motor is drawing, which might be useful in some cases but if not needed you can just connect pin 15 to ground.
    Artificial Intelligence is no match for Natural Stupidity

    "For a list of all the ways technology has failed to improve life, press three" - Alice Kahn

    Resistance is futile! (if < 1)


Replies to Tutorial: Simple H-bridges
  1. Join Date
    Jan 2008
    Location
    Montreal, Canada
    Posts
    477

    Re: Simple H-bridges

    Nice tutorial! Very interesting and I learnt quite a bit!

    Thanks, were one step closer to having a full blown section for tutorials!
        

  2. Join Date
    Jul 2008
    Location
    Belgium
    Posts
    633

    Re: Simple H-bridges

    I'm not really sure what else i can put in, anyone any requests or is it good enough to be posted?
    Artificial Intelligence is no match for Natural Stupidity

    "For a list of all the ways technology has failed to improve life, press three" - Alice Kahn

    Resistance is futile! (if < 1)
        

  3. Join Date
    Sep 2006
    Location
    Carol Stream, Illinois
    Posts
    1,695

    Re: Simple H-bridges

    I'd say it looks great! PM me if you want it moved over.

    �In the long history of humankind (and animal kind, too) those who learned to collaborate and improvise most effectively have prevailed�
    - Charles Darwin
        

  4. Join Date
    Sep 2006
    Location
    Carol Stream, Illinois
    Posts
    1,695

    Re: Simple H-bridges

    *bump* now published

    Thanks Scud!

    �In the long history of humankind (and animal kind, too) those who learned to collaborate and improvise most effectively have prevailed�
    - Charles Darwin
        

  5. Re: Simple H-bridges

    I haven't seen NPNs over PNPs in an h-bridge before, does this actually work?

    Usually it's PNPs emitter to positive, collector to the collector of the lower NPN, with that transistors emitter to ground. Check http://library.solarbotics.net/circuits/driver_4varHbridge.html
        

  6. Join Date
    Jul 2008
    Location
    Belgium
    Posts
    633

    Re: Simple H-bridges

    Quote Originally Posted by robologist View Post
    I haven't seen NPNs over PNPs in an h-bridge before, does this actually work?

    Usually it's PNPs emitter to positive, collector to the collector of the lower NPN, with that transistors emitter to ground. Check http://library.solarbotics.net/circuits/driver_4varHbridge.html
    You are absolutely correct. I am ashamed beyond belief!

    The transistors should be the other way around, PNP on top and NPN below. The only way it would work in this configuration is if VCC were lower than the driving voltage (eg. 3v with 5v drive) but that would in most cases defeat the purpose.

    I'll try updating the image, thanks for the heads-up!! +Rep!
    Artificial Intelligence is no match for Natural Stupidity

    "For a list of all the ways technology has failed to improve life, press three" - Alice Kahn

    Resistance is futile! (if < 1)
        

Reply To Tutorial