Let's Make Robots!

Making a FET "H" bridge (revised)

Drives motors
AttachmentSize
Ammeters_and_shunts.pdf137.75 KB
heatsink.pdf135.15 KB
24V_H_bridge_Schematic.jpg795.28 KB

One thing most robots need is the ability to control motors. This circuit will work from 7.2V to 15V with PWM frequencies up to 25KHz and drive motors with a stall current of 20A. Features include not only speed and direction but it also has electronic braking, fuse protection and current sensing. Click on the schematic for a larger image. I have now attached some files with information on current shunts and heatsink calculations.

This circuit was my own exercise to teach myself about "H" bridges. It cannot work at high PWM frequencies, it works perfectly with Arduino's default PWM frequencies. In most cases I suggest you buy a ready made "H" bridge.

As this schematic has been updated you may need to reset your browser cache to see the new schematic. For Firefox users this is done by pressing [Ctrl] + [F5]. This circuit is now smoke proof.

I finally had time to build and test this circuit thoroughly using a DSO (Digital Sampling Oscilloscope) to check that it all worked properly. I have replaced the LM324 with an LM339. The outputs of the LM339 change a lot faster than the LM324 making it better suited for higher frequencies but they are open collector outputs so they need a pullup resistor to work properly.

The current sensing part of the circuit was discussed in detail in a previous walkthrough where it was suggested that a fuse could be used as the "Shunt resistor". I have used that in this circuit and included a LED to indicate if the fuse has blown. Although not as precise as a proper Shunt resistor the fuse is a lot cheaper and performs a vital service. I have added a 200K pot for adjusting the gain allowing this circuit to work with any shunt resistor.

The fuse should be a "slow blow" fuse with a rating less than your stall current. If your software is working well it will detect the stall current and shutdown the motors before the fuse blows. If something goes wrong then the fuse will do it's job.

Note that suitably heavy wire should be used between the batteries, the motor controller and the motor to get maximum power to your motors and to ensure the fuse does it's job. With the 20A circuit shown I would use at least 1.5mm² stranded copper wire.

I have shown IRF540 Nch and IRF9540 Pch FETs in this circuit as used by Jip in his robot "Tiny Tim" because they are relatively cheap and will handle stall currents of 20A. Other FETs could be used in their place depending on the requirements of your robot.

The maximum Vgs of the FETs shown is +/- 20V. I recommend not using batteries higher than 14.4V (12 x NiMh) as the peak voltage of the batteries during charging and just after charging can be a fair bit higher.

No "Flyback" diodes have been included in this circuit because in most cases the FET's internal "Body Diode" is usually sufficient. Additional diodes may be added if required.

The comparators perform 2 functions, they translate the logic level outputs of your microcontroller to the higher voltages needed to drive the FETs and they prevent your FETs from aciddently turning on in such a way as to short out your battery.

The voltage translation is done by comparing your logic level inputs with voltages derived from your 5V supply. The input is compared to 1V and 4V levels generated with a voltage divider. If your microcontrollers output is higher than 4V then the appropriate Nch FET will turn on. Lower than 1V will turn on the Pch FET. Voltages in between 1V and 4V will turn off both FETs preventing any possible Short circuit.

Because the outputs of your microcontroller can change state so quickly I have added 10nF capacitors and 100Ω resistors in series with inputs A and B. As the capacitors must charge and discharge via the 100Ω resistors this slows down the inputs rate of change enough to guarantee that both Nch and Pch FETs have time to turn off during transistions.

Below is a screen shot from the DSO. This shows the LM339 outputs to the Nch and Pch FETs when input A is PWM at 50% duty cycle @ 16KHz with a battery voltage of 15V. Input B is tied high. As shown on the truth table this is alternating between 50% brake and 50% reverse. The yellow signal goes to the Nch FET while the Cyan signal goes to the Pch FET.

When both signals are high, the Nch FET is on and the Pch FET is off. When both signals are low then the Nch is off and the Pch is on. During switching, you can see the Nch turns off before the Pch turns on and that the Pch turns off before the Nch turns on.

Each input has a diode and transistor on it. This strange setup is known as MML (Mickey Mouse Logic) which is basically logic gates cobbled together from resistors, diodes and transistors.This MML generates open circuit outputs when both inputs are low but allows all other combinations to pass through allowing both "brake" and "no power" states as shown in the truth table.

When both inputs are low then the diodes block the inputs and the + inputs of the opamps are held at 2.5V via the 4K7 resistors. In this state the transistors on the inputs are both off.

When both inputs are high then the + inputs of the opamps are driven high via the diodes turning the PCh FETs off and the Nch FETs on causing the motor to brake. Both input transistors are off since their base and emitter pins are both high.

When one input is high and one is low then the high input passes through it's diode and the low input passes through it's transistor which is now on.

Speed is controlled by holding one input low and PWM the other input. Electronic braking of the motor can be controlled by PWM both inputs together so that they are both high or both low at the same time.

Although 5V logic is assumed in this circuit it will work with 3.3V logic just as easily. Just replace the 4.7V zener in the current sensing circuit with a 3.3V zener to protect the LM358 input.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thank you a million times for this! I will go through this and im sure it will help alot. 

I had simulated a circuit <a href="http://1.bp.blogspot.com/-V-U10_jsfGM/Uc7mR73gpCI/AAAAAAAAAjQ/YBSyxKstD78/s1600/design32-full.BMP">this one</a> but it gives only 1-2A due to ir2112. and my motors need 13A. realized it too late in the project. now working on the new design, without mosfet drivers. i hope that wont be unsafe to do so. i like the idea of LM339 though.. 

You're welcome :)

Using the LM339 isn't the best method to do it, but if it fits your needs then it's the way to do it.

About the current issue, if I'm not wrong this circuit would handle as much current as your cooling could handle.

I would apreciate that OddBot comments this circuit.

tschüss

Your correct that the LM339 is not the best way. This is an old design of mine.

The newer designs all use Nch FETs only as they are more efficient and then use charge pumps to generate the gate drive needed for the upper FETs.

Current Limits: There are two current limits you need to take into consideration, the continuous current (or average current) and the peak current.

With motors, your peak current is your stall current. The FETs need to be rated for this current and you should have fuses or some other method of shutting the power off if the stall current persist for more than a second.

Your cooling should be sufficient to protect the FETs when running at the continuous current level on a hot day with a small amount in reserve for brief overload conditions.

It is not really something you can put a formula to as it can vary greatly depending on the motors used and the application. I try to use FETs that are rated for twice the motor stall current. The FETs are a bit more expensive but you can use a much smaller heatsink and do not need a fan so the end result is cheaper.

24V motors can run on 12V but just with less power and speed. Before you replace anything try the motors at 12V. They might be powerful enough.

Ok. I will try it before purchasing new stuff then. I hope it works suffiiently on 12V, then i can use the circuit here... and all would be great :) 

What about that 24V_H_bridge_Schematic.jpg ? I though that is 24V version of this H-bridge? Or is it labeled 24V for some other reason?

Your correct, I forgot about it. You can see it has zener diodes to limit the Vgs on the FETs

This looks like a great H-bridge, and I would really like to try and build it, but I am a n00b when it comes to making actual circuit from schematic :\ Did anyone make a PCB layout or something similar for this H-bridge, please?

I would not call this a great design. The methods I used to ensure a deadtime when the FETs switch limit the frequency of PWM to less than 20KHz. It works well at the default PWM frequencies of the Arduino.

So there is a better version? Could you please point me, I have searched a lot on the web but am very confused as to which H-bridges are good and which are not :S