H-bridge Design Help, 3 ADC

Hey Guys,
So after about a week of trial and error and google searches, I want to ask for some feed back before I "might" fry my third circuit.

The goal is to control a DC motor with speed and direction from a micro controller.
The motor is from a cordless drill, has no model number on it. From testing, its pulling about 2.5 Adc at 12vdc with small restriction holding the shaft. Its rated for 18 Vdc, but working with 12v PS.

Failed Circuit

The second I built was working fine when I was testing it with LEDs and using only digitalWrite to the output pins, alternating between pin 3 & 5.

const int motorPinFrw = 3;
const int motorPinRev = 5;

//Void Setup Code

void motor_setup() {
  pinMode(motorPinFrw, OUTPUT);
  pinMode(motorPinRev, OUTPUT);
  analogWrite(motorPinFrw , 255);
  analogWrite(motorPinRev , 255);
}

//Alternating ON/OFF between outputs

    digitalWrite(motorPinFrw, HIGH);
    delay(2000);
    digitalWrite(motorPinFrw, 0);
    delay(25);
  
    digitalWrite(motorPinRev, HIGH);
    delay(2000);
    digitalWrite(motorPinRev, 0);
    delay(25);


//Alternate Fade ON/OFF between outputs

  digitalWrite(motorPinRev, LOW);

  for (int i = 0; i < 255; i++) { //A Fade On
    analogWrite(motorPinFrw, i );
    delay(10);
  }
  for (int i = 255; i > 0; i--) { // A Fade Off
    analogWrite(motorPinFrw, i );
    delay(10);
  }
  digitalWrite(motorPinFrw, LOW); 

  for (int i = 0; i < 255; i++) { // B Fade On
    analogWrite(motorPinRev, i );
    delay(10);
  }
  for (int i = 255; i > 2; i--) { // B Fade Off
    analogWrite(motorPinRev, i );
    delay(10);
  }

It fried when I used analogWrite in a for loop to fade between the LEDs.

LED test strip I used

I BELIEVE Q1 & Q4 was the active path and Q3 let the magic smoke out.

Since this blew when PWM was active, I found out after that pin 3 is 490 Hz and 5 is 980 Hz.

I was testing this circuit as I was building it so I didn't put in diodes yet.
I figured diodes were only needed on inductive loads to protect the MOSFETs but perhaps I'm wrong and LEDs need them as well?

This is going to be my next build.
Next Circuit Idea

So my question, will my next circuit work for the DC motor and LEDs?

Files:
2nd built but fried with LEDs
schem built.png

3rd I'm planning on building
schem with D.png

LED strip I used for testing
12v LED test load.png

IRF4905 Datasheet

IRF540N Datasheet

Since it failed with a non-inductive load, the problem was probably not the missing flyback diodes.
The input capacitance of the mosfets (3nF) is high as is the maximum switching time of the optocoupler (18uS).
This could mean that the mosfets are often in a half conducting state and will get hot. A lower value pull up resistor could help.

This is the most important of OPs schematics (it's the second one):

It's an H-bridge, with no protection against shoot-through. As the gates are connected there will be periods that BOTH MOSFETs are conducting: as the voltage rises by the 4k7 pull-up (less of an issue when the voltage drops through the opto which is MUCH faster) the N-MOS gets switched on when the voltage is about 2-3V, and the P-MOS gets switched off when the voltage is about 9-10V. That period, a few µs, both MOSFETs are on, and create a short. that's going to kill your MOSFETs.

The diodes in this schematic are redundant as you have the body diodes of your MOSFETs already. Those can do the job just fine. A 1N4148 is a small signal diode, you need one that can handle the motor current. As you have a 2.5A motor you'll need a diode rated 2-3A continuous.

Solution: get a proper, purpose built H-bridge. Maybe you can find a 2.5A H-bridge IC, maybe you need a complete motor driver.

Solution: get a proper, purpose built H-bridge.

Agreed. Pololu has an excellent selection. Choose one that can handle the 15-20 Ampere startup/stall current.

This is one of those things that looks simple in the textbooks but the actual implementation isn't.

Look up "gate capacitance". Basically the gate on the MOSFET is a small capacitor. You have to charge and discharge the capacitor to turn the MOSFET on and off. The discharge curve is complex, with a flat spot in the middle.

As you charge Q1 and Q2 together, they both end up on that flat spot for a significant amount of time. They are both conducting so very large currents flow from the supply through Q1 and Q2 straight to ground.

I forget exactly which ones but I think most Arduino chips have special PWM modes to allow 4 pins to control 4 MOSFETs with a controlled time delay to prevent this "shoot through". No Arduino hobbyist ever uses this mode and I don't know of any library available. We just all use dedicated H bridge chips which have this complex stuff built in.

What model is the drill motor. Some of them can have a stall current close to 50A.

In years past there have been some long discussions with people attempting to DIY their own H-bridges with poor outcome. I haven't checked in a long time, but ebay use to have I think 43 amp H-bridges at reasonable prices. I think successful H-bridges incorporate a boot strap charge pump on the MOSFET gate to keep the gate at a higher voltage than the voltage being switched. The higher voltage is needed for the MOSFET to be fully on. You can google "boot strap mosfet" to see the setup.

6v6gt:
Since it failed with a non-inductive load, the problem was probably not the missing flyback diodes.
The input capacitance of the mosfets (3nF) is high as is the maximum switching time of the optocoupler (18uS).
This could mean that the mosfets are often in a half conducting state and will get hot. A lower value pull up resistor could help.

Thanks 6v6gt.
Alright so adjust the PWM timing to compensate for proper drainage of the gate capacitance and get the Vgs more tuned in.

wvmarle:
This is the most important of OPs schematics (it's the second one):

It's an H-bridge, with no protection against shoot-through. As the gates are connected there will be periods that BOTH MOSFETs are conducting: as the voltage rises by the 4k7 pull-up (less of an issue when the voltage drops through the opto which is MUCH faster) the N-MOS gets switched on when the voltage is about 2-3V, and the P-MOS gets switched off when the voltage is about 9-10V. That period, a few µs, both MOSFETs are on, and create a short. that's going to kill your MOSFETs.

Thank you wvmarle.

The idea was with both optos active, Q2 & Q4 would be Vgs 0.1 mV/Open and Q1 & Q3 would Vgs ~-10 V/Closed and applying +12 V to both sides of the motor.
This was thought of since the micro controller goes into an all pins high state during power on.

wvmarle:
The diodes in this schematic are redundant as you have the body diodes of your MOSFETs already. Those can do the job just fine. A 1N4148 is a small signal diode, you need one that can handle the motor current. As you have a 2.5A motor you'll need a diode rated 2-3A continuous.

I do have power diodes that'll fit those requirments.

wvmarle:
Solution: get a proper, purpose built H-bridge. Maybe you can find a 2.5A H-bridge IC, maybe you need a complete motor driver.

I agree that'll easily fix it and I'll look into it as time contiunes. If anything, I might just get one to reverse engineer the design to understand it better.

MorganS:
This is one of those things that looks simple in the textbooks but the actual implementation isn't.

Look up "gate capacitance". Basically the gate on the MOSFET is a small capacitor. You have to charge and discharge the capacitor to turn the MOSFET on and off. The discharge curve is complex, with a flat spot in the middle.

As you charge Q1 and Q2 together, they both end up on that flat spot for a significant amount of time. They are both conducting so very large currents flow from the supply through Q1 and Q2 straight to ground.

I forget exactly which ones but I think most Arduino chips have special PWM modes to allow 4 pins to control 4 MOSFETs with a controlled time delay to prevent this "shoot through". No Arduino hobbyist ever uses this mode and I don't know of any library available. We just all use dedicated H bridge chips which have this complex stuff built in.

Thank you MorganS.
So far from all this, the charge of the Vgs has to be controlled, perhaps by an RC circuit and 4 pins from the uC with more controlable timing.

detown:
What model is the drill motor. Some of them can have a stall current close to 50A.

I don't remember detown, I think it was Ryobi? I bought it from a thrift store for $5 so can't beat that for a geared motor. I tore it apart a few months ago, finaly getting to play with it.

zoomkat:
In years past there have been some long discussions with people attempting to DIY their own H-bridges with poor outcome. I haven't checked in a long time, but ebay use to have I think 43 amp H-bridges at reasonable prices. I think successful H-bridges incorporate a boot strap charge pump on the MOSFET gate to keep the gate at a higher voltage than the voltage being switched. The higher voltage is needed for the MOSFET to be fully on. You can google "boot strap mosfet" to see the setup.

I understand the poor outcome part. I did look at some ebay controllers and could probably get them to work. One thing I don't like is the blue/green screw terminal blocks that push down a little contact.

Conclusion:
Going to check into the drain/charge time of the mosfets to make sure they are close to equal with additional circuitry that can work with the timing of the frequency of the uC and optos.

Thank you all very much for your assistance with this!

dallasw1983:
Conclusion:
Going to check into the drain/charge time of the mosfets to make sure they are close to equal with additional circuitry that can work with the timing of the frequency of the uC and optos.

That is never going to work - you NEED dead time (make sure one is off before the other is switched on). A few us is enough, but it must be there or you WILL get shoot-through.

Instead of optocouplers you may use gate drivers. Much faster, and can also do the level shifting you need (5V to 12V). One driver per gate, so four drivers, and you can do the dead time in software. The slow switching through optocouplers is an issue if you want to PWM your design, it may cause excessive heating of your MOSFETs.

And when you go for a commercial H-bridge, don't go for the ancient L293/L298 chips... That huge heat sink is there for a reason... they're terribly lossy.

Hi,
For a start you are feeding the H-Bridge with two PWM signals of different frequencies, 980 and 490Hz.
The MOSFET gate operations are not synchronized.

So there will be many times that MOSFETs that are ON will be a combination that shorts the power supply out.

All you can do with your H-Bridge is have full speed forward/reverse
You cannot in my opinion PWM speed control this H-Bridge.

D5 HIGH and D3 LOW, motor spins one direction.

D5 LOW and D3 HIGH, motor spins in the other direction.

D5 LOW and D3 LOW, motor in brake mode.
D5 HIGH and D3 HIGH, motor in brake mode.

Do you have a DMM to measure circuit voltages?
What are you using for the motor power supply?

Tom... :slight_smile:

Another similar H-bridge project from the past.

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

If you want to learn how to make a MOSFET H-bridge, first realize this is done using a chip designed for the purpose to drive the MOSFETs. And then you'll see its normal to use only n-channel MOSFETs, not a mix of p-channel and n-channel. I recommend reading the datasheets of chips like the HIP4081A (H-bridge driver) or
half-H-bridge chips like IRS2004, FAN7380. There are 3-phase drivers like FAN7888 and HIP4086 too, which are basically 3 half bridges.

Its essential for a high power H-bridge that there is no possibility whatever of shoot-through (instant death to the MOSFETs), and tight layout is always necessary as stray inductance can lead to gate over-voltage (instant death to MOSFETs). The gate drive must be suppressed when the supply voltage is below the level needed to switch the MOSFET fully (otherwise you get severe dissipation leading to MOSFETs burning out). Without all the protection features in place MOSFET bridges tend to just blow up.

I think I would skip the DIY and get one of the below H-bridges. I like the second traditional one as it has thick power bus and heavy screw terminals for the thicker wires one would be attaching.

https://www.ebay.com/itm/US-Dual-Motor-Driver-Module-Board-H-bridge-DC-MOSFET-IRF3205-3-36V-15A-Peak30A/264472008972?epid=21021256406&hash=item3d93c2990c%3Ag%3AbEIAAOSwU0tdhJFA&LH_BIN=1

I used this circuit and put a delay between the A and B inputs .

FYI, Reply#11 is very good advice. It might be worth copying it and pasting into a Word file for future
reference.

When it comes to H-Bridges , you can never be too careful.
I wish I had a dollar for every H-bridge destroyed by shoot-through (in the world).

How does that prevent shoot-through? You can't even switch off Q1 and Q3!

The circuit I build used TC4427s, (non-inverting, not the one shown)

How does that prevent shoot-through? You can't even switch off Q1 and Q3!

A B Q1 Q2 Q3 Q4


0 0 ON OFF ON OFF NO CURRENT PATH
DELAY
0 1 ON OFF OFF ON (REVERSE)
DELAY
1 0 OFF ON ON OFF (FORWARD)
DELAY
1 1 OFF ON OFF ON NO CURRENT PATH

If I have overlooked something I am certainly open to feedback

On thinking about it, it probably would be better to add another TC4427 and have a separate
control for each of the fets.
Like THIS:

A LOW
D HIGH = FORWARD

A HIGH
D LOW

DELAY (DEADTIME)

B HIGH
C LOW = REVERSE

B LOW
C HIGH

DELAY (DEADTIME)

The previous schematic shows 5V to the gate drivers, that's not going to switch off the pmos whose drains are at 12V. Also as the gate voltage rises or falls, as the voltage is halfway both FETs are on.

The new schematic should work, but as pointed out before even better would be a purpose built half bridge driver and nMOS at the high side.

The TC4427 runs off 12 to 18V. (I usually use 12)

5V on the TC4427 (non-inverting version) give Vdd (+12 to 22V) on the gate.
0V on the TC4427 gives 0V on the gate.

The gates are either at +12 or 0V.

The mosfets used in the schematic are logic level, which do not require a bipolar supply.

When you use proper half-bridge drivers (or multiples thereof) you are normally constrained to doing PWM due
to the need to keep refreshing the bootstrap capacitors that power the floating high-side gate drivers. In otherwords you cannot park the output of that half-bridge HIGH, as the cap discharges. 95% PWM duty cycle will do the job almost as good.

That's a downside (some drivers like the HIP4081A avoid this problem with extra charge-pump circuitry, note)

There's a plus side to high-low drivers that's very useful - the motor supply voltage can be anything you like,
1V, 10V, 100V (within the specs of the driver chip of course, some are 80V, some 200V, some 600V....). The bridge works completely independently of the driver supply due to the floating drivers. You can power down the
motor supply with the bridge still running - not an issue. You can power down the driver with the motor supply still present and its undervoltage lockout should prevent bad things happening.

The more I learn about how complicated
H-Bridge drivers are, the more feel like
it's just one of the things you can't tackle
as a weekend hobbyist. You have to either
be 'All in' and learn everything you're talking about
(and blow up some boards in the process ),
or just don't try to be an amateur h--bridge
designer and simply pay extra money for a
full featured H-bridge plug&play solution..
I did order one each of the cheap ones from
eBay someone linked to try them out. At
those prices it's hard to turn down.

There's a lot of choices and the prices run the
gamut:
Google: "hip4081a h-bridge circuit"