MOSFET H-Bridge

Hello all,

I need a little bit of help designing an H-Bridge Circuit for a 4-6V motor that draws max 140 +/- 50 mA at 6 VDC when operating in no load conditions. I want to maximize power to the motor. The Arduino will be powering a lot of other things so instead of using the Arduino to directly power the motor, I was planning on using the Arduino to provide power to the MOSFET gates, and power the H-Bridge with a 6V battery.

I've found a couple of starting circuit designs that I want to start with, and make modifications to them as needed. One that I really like is from here, and here's another that I think is fairly simple. I'm leaning towards the first, though I'm not sure what the purpose of the two outside MOSFETs is.

I'm not planning on using a MOSFET driver, so I was thinking of replacing standard MOSFETs with logic-level FETs. However, I'm not sure how well this would work and am afraid of switching too quickly. Does anybody have any suggestions or warnings?

Here are some MOSFETs that I was thinking of using:

IRLZ24
IRF9510

Edit: I just saw another H-Bridge post and I think we may be from the same school

So this is a school assignment? Otherwise you are far better to just go buy one. A 6V bridge isn't all that complicated, so you'll be OK. The two "outside" MOSFETs are level shifters since if you reason through how you would turn on the "top" pair of FETs, it can't be done without them. The Arduino cannot source but 40mA max, so you do need drivers.

Yes the 6V supply is an issue - you need to bring the gate of the p-channel MOSFETs to the
rail to turn them fully off.

Usually an NPN is used as a level shifter, but actually for just a volt or so a red or IR LED can
be used to drop this voltage. Have say 2k2 gate-source resistor on p-channel FET, and
LED anode to the gate, LED cathode to Arduino pin (add perhaps a 150 ohm current
limiting resistor too). Alternatively 2 ordinary diodes in series will drop 1.2V or so.

rmetzner49:
Yep, school assignment, so some type of H-Bridge is required.

From what I've learned in this class, MOSFET gate current is assumed to be 0. What do you mean when you say that I do need drivers? The Arduino is only going to gates.

MarkT:
I haven't heard the term "to the rail" before, can you explain?
Edit: Some quick Googling - in order to completely turn off a high-side P-FET we’ll have to drive it’s gate as high as it’s source. Thanks, Mark! Some more questions:

If the P-channel FETs were also logic-level, would I still need level shifters?

And is there any danger to switching the motor in the opposite direction?

Thanks for the quick replies, guys.

As Mark said: Let's say you have your supply voltage at 6V, you generally have a pullup from the gate to 6V that holds the P-FET off. Now your gate is at 6V which the Arduino won't tolerate since it' can't get past the 5V supply. You need to "level shift" the Arduino's output to 6V.

Mark suggested just two diodes in series between the Arduino and the gate. That will work, but I prefer a good old 2N2222's collector tied to the gate which he also suggested, since it also does the necessary inversion for you. It also makes it more stable since if someone decided to give you 8V instead of 6V, you'll be in trouble with the diodes.

Without the 2N2222 when your Arduino powers up, it's outputs default to GND which will turn the P-Channel FET on nicely. In my opinion it's poor design practice to have a device that defaults to the "on" state. Even if you are watching every penny, that 2N2222 isn't much more expensive than two diodes. It makes all your logic "high true" then which is cleaner.

One other thing, I think the N-Channel you picked will work just fine. The P-Channel if you look at the curves doesn't come ON very well with only 6V VGS.

rmetzner49:

Thank you for all your help! I think that answers all my questions and covers all my concerns. We're making robots for a competition so hopefully this will give us the upper hand. Thanks again

The below is a DIY h-bridge project. Might be worth a read.

http://forum.arduino.cc/index.php?topic=53425.0

Driving signals : Dead-gap

When driving the H-bridge it is important to note that because PMOS and NMOS transistors turn on and off at different speeds, it is possible to create transient short-circuits along the two vertical paths of the H-bridge which can destroy the transistors.

The solution to this, is to have a dead-gap - I.e. a period where there are no drive signals when transitioning between forward drive and reverse drive. This will ensure that all the transistors in the bridge are in an off-state before turning the next pair of transistors on.

Many MCU's (e.g. Atmel) have dead-gap circuits as part of their PWM signal generator hardware.

Although the term is not mentioned in the above quote, it is addressing the subject of "SHOOT-THROUGH
PREVENTION". "SHOOT-THROUGH" is the term used to describe "transient short-circuits along the two vertical paths of the H-bridge which can destroy transistors.."

zoomkat:

It was. At least with regard to the choice of MOSFET, I've tried to choose those without too much resistance that will maximize power based on the motor's current.

raschemmel:

One of my main concerns is that I will be switching too fast for the FETs to fully discharge. Do you think leaving a delay before switching is a good solution to the problem? If so, how would I calculate the delay needed? I would think finding the time constant of the FETs would be sufficient (that was my plan, at least)

First consider the definition of "shoot through". For the sake of simplicity let's designate the mosfet in the
upper left of the schematic as "10:00", the one in the upper right as "2:00", the one in the lower left as
8:00 and the one in the lower right as 4:00. So for the motor to go one direction , 10 & 4 must be ON,
while 8 & 2 are OFF. To reverse direction , 8 & 2 are ON and 10 & 4 are OFF. Now consider that the ONLY
things BETWEEN the POSITIVE rail and the NEGATIVE rail are those four mosfets. If they turn as I just
described , everything's fine because there is a load (the motor) in between the two rails. BUT, WHAT IF,
10 & 8 were to turn ON , OR 2 & 4 ? That's right, DIRECT SHORT ACROSS THE PS RAILS. So what kind of
delay do you need between the two combinations described above ? I would say "turn on time + 30% " ,
so the delay is 1.3 x tturn-on. and then wouldn't you need to consider TURN OFF time ?
Should the delay be equal to (TURN ON TIME + TURN OFF TIME) ?
To be honest, I don't know. I have a feeling mestzner49 does though...

Well now, the IRLZ24 N-channel logic FET sounds an excellent choice for the task, while the IRF9510 P-channel would be quite useless (isn't a "logic" FET).

And the "another" link in your original post isn't quite a proper H-bridge circuit, just a diagram of some FETs, while your "here" isn't a link at all, so we cannot tell anything from that.

If you found a logic level P-channel FET to match, you could drive the H-bridge skeleton from four Arduino pins, given that the 10k pull-up and pull-down resistors are in the wrong place; they should be connected to the input side of the 330 ohm gate resistors, not the gate side. You would have to be very careful in your code not to enable both high- and low-side drivers simultaneously. If you use separate instructions in the correct sequence, the discharge times with 330 ohm resistors will not be a problem. On consideration, if you can devote four Arduino pins per motor and do your testing with a 12V 10W automotive or Halogen globe in series with the power in case of "accidents", this may be the most practical way.

It would probably be just as well to use "plain" PNP transistors for the high-side if you cannot readily get proper FETs. They would need only a 330 ohm base resistor - no "pull-ups" as they are not high-impedance devices. What you do not want to use in a H-bridge, are Darlington transistors.

Oh, and there is no reason to need Schottkys - ordinary power diodes are just fine.

raschemmel:

Just to be safe, the delay should probably be 2 or 3x that, but if the solution to the problem is as easy as adding a delay to the code then it should be fine! I was worried it'd be more complicated than that.

Paul__B:

Sorry, the correct links should be up now. I just tested the circuit today, in fact, and it didn't run as smoothly as I thought it would. The motor ran, but more slowly than I expected, and my best bet is it's related to the IRF9510 and it's 1.2ohm Rds(on), not to mention the fact that the 5V from the Arduino isn't turning it on fully. I do want to stick to MOSFETs for max power across the motor, though. I had PN2222As on hand today and I tried to use those for the outside level-shifters, but what ended up happening was the transistors got really hot and I don't think I want to do that again. I tested it with a 5VDC at 1A going into the H-bridge and 5VDC 1A into one level shifter. The other level shifter was at 0V. Does anybody have any insights on why that might happen?

This is what I tried today:

with bad results. The resistor and inductor in the middle is just a representation of the motor (I don't actually know the motor resistance or inductance). The 5V and 0V DC on the side represent pins from the Arduino, and I tested it with a Vcc of 5V @ 1A.

When I replaced the transistors with IRLZ24s, the circuit worked, albeit not as well as I'd hoped.

en28:
I just tested the circuit today, in fact, and it didn't run as smoothly as I thought it would. The motor ran, but more slowly than I expected, and my best bet is it's related to the IRF9510 and it's 1.2ohm Rds(on), not to mention the fact that the 5V from the Arduino isn't turning it on fully.

OK, I did explain, did I not, the IRF9510 P-channel in fact quite useless in this application?

en28:
I do want to stick to MOSFETs for max power across the motor, though.

However, I pointed out that "It would probably be just as well to use "plain" PNP transistors for the high-side if you cannot readily get proper FETs".

en28:
I had PN2222As on hand today and I tried to use those for the outside level-shifters, but what ended up happening was the transistors got really hot and I don't think I want to do that again. ... Does anybody have any insights on why that might happen?

Yes, they are bipolar transistors, not FETs.

It would be easy to say that it is because you have not provided bias resistors in series with the bases, but other people have been trying (perhaps confusingly) to explain that you need to be much more careful than that. Which is why I suggested certain particular things. I see no errors in what I wrote, so I have no reason to repeat it.
[/quote]

en28:
The resistor and inductor in the middle is just a representation of the motor (I don't actually know the motor resistance or inductance).

Irrelevant, really.

en28:
When I replaced the transistors with IRLZ24s, the circuit worked, albeit not as well as I'd hoped.

Using useless P-channel FETs would explain that. Mind you, because they are in fact, useless, at least you could do little damage. :grin:

@en28,
Yes, more or less correct , but please confirm you know where to put the delay.

P-CHANNEL
You might consider using these:

N-CHANNEL

Paul__B

I will try what you suggested.

raschemmel:

In the code? Correct me if I'm wrong, but it should be before any high/low pin changes going into the FET gates. Also, thanks for the suggestions! These are actually within the right price range.

Correct:
Specifically, you should have a function called ON, and one called OFF, (or FORWARD, and REVERSE if it
is bi-directional , which is probably the case. The delay should be at the beginning of these routines before
the actual HIGH or LOW signal which drives the fets. Personnaly I would use boolean flags to monitor the
state of the fets and set a flag before the delay and clear that flag AFTER you turn it OFF.
ie:
If you have 4 routines;
1-FORWARD ON
2-REVERSE ON
3-FORWARD OFF
4-REVERSE OFF

If you preceed either FORWARD or REVERSE with OFF, you can CLEAR the forward_flag AFTER the OFF
routine at the beginning of the REVERSE routine and CLEAR the reverse_flag at the end of the OFF at the
beginning of the FORWARD routine.

The sequence would then be:
CLEAR ALL FLAGS
forward_flag = false;
reverse flag = false;

FORWARD
if (reverse_flag == false)
[turn ON forward signal]
SET FORWARD FLAG
forward_flag = true;

FORWARD OFF
[turn OFF forward signal]
CLEAR FORWARD FLAG
forward_flag = false;

REVERSE
SET REVERSE FLAG
reverse_flag = true;
[turn on reverse signal]

REVERSE OFF
[turn OFF reverse signal]
CLEAR REVERSE FLAG
reverse_flag = false;

@Paul_B,
Since you are a real programmer as opposed to an amateur hack such as myself, how does the above sound ?

raschemmel:

This looks good to me, though I may go a different route and just use _delay_ms() to add a delay every single time I switch, no matter what. Another question I have about the MOSFETs you recommended though: Looking at the datasheets it seems to me that the FETs won't be fully on at 5V from the microcontroller (the P-channel one especially). Does this increase resistance across the FET or decrease current? Are there any negatives to not having the FET fully on?

raschemmel:
P-CHANNEL
You might consider using these.

N-CHANNEL
FQP30N06

The P-channel one looks almost plausible.

The FQP30N06 is no better than the IRF9510 first cited.

What delay are we talking about now?

As far as avoiding "shoot through", it would be sufficient to switch FETs simply using different (separate) DigitalWrite instructions - as long as no smart-arse "optimiser" in the IDE decides "Oh, we could do all those operations in one go"! But I do not think the optimisers here would do that.

The problem I see with the P-channel is that based on Fig-2, page-3 of the datasheet, you need -5V dc
to get 20A. The Gate Threshold Voltage is -2V to -4V. You would need a -5V dc supply (a two conductor
wall wart with floating output leads so you can connect the "+" to your GND so the output is -5V
with respect to GND. You could then use that as the -V supply for an op amp and use a Gain of 1 Inverting
amplifier to convert the Arduino HIGH from +5V dc to -5V dc. Your VD for the fets will of
course have to be a proper negative supply voltage that is the mirror image of your VD for
your N-channel fets. (-30V to -60V for the P-Channel mosfets, with respect to circuit GND). This can be
accomplished using the same method you use for the negative op amp supply, namely a floating (two wire)
wall wart with the positive lead connected to circuit GND.

Ideally , what you need is a level converter that converts 0V - 5V to +5 - 5V range so the arduino LOW (0V) give +5V . The op amp inverter only converts +5V to -5V. It does not convert the arduino logic LOW
from 0V to +5V.

ie:

UNO OUTPUT P-CHANNEL OFF P-CHANNEL ON
LOW=0v +5V
HIGH=+5V -5V

To do this you need a GND, a +VDD and a -VDD
Arduino connects to only GND, and signal IN
P-CHANNEL GATE connects to signal out
+VDD is your system +5V dc
-VDD is your -5V obtained by using a floating 5V supply connect with POS lead to GND,
so the NEG lead reads -5V with respect to GND.

The voltage Level Converter would take the arduino 0 - 5V from a digital output pin and convert it
to +5 / -5V , with +5V being the output for a 0V in and -5V being the output for a +5V in.

TTL/CMOS level converters only convert 3V to 5V or vice versa so those won't work.
I know this kind of level converter can be done using an op amp comparator running on +5V/-5V.
The logic would reversed so instead of using a HIGH to turn ON the fet, you would output a LOW
which , if properly configured, would give a HIGH output of +5V from the Comparator. A HIGH would
give -5V from the Comparator output.

Truth Table
Vref = 1V (arduino LOW is always LESS than 1 V, therefore Vref=1V distinguishes a LOW from a HIGH)

Vin < V ref => +5V
Vin > V ref => -5V

I recommend the LT-1215 op amp but there are many other alternatives.

"The problem...with the P-channel is that based on Fig-2, page-3 of the datasheet, you need -5V dc
to get 20A." [and so on]

Schemmel, it's relative to the source potential (you should know this.)
If the P-channel source is at +V then it starts to turn on when its gate is less positive than the source (potential).
If the source is at +15V, then the P-FET is good and on when its gate is 5V less than that: when VG is +10 (with respect to Gnd.)