Go Down

Topic: H-Bridge mosfets keep exploding (Read 5287 times) previous topic - next topic


Hey guys,

I am using one of the schematics from the book arduino robotics (schematic below). I have assembled the circuit on a breadboard and while testing I was using a 12 volt 1 amp wall wart for the power supply. using a parallax joystick for motor speed and direction control everything worked good for the first few minutes but then the motor would slow to a stop even with the joystick pushed all the way forward. After testing the mosfets I found the P-Channel in position Q1 to be burned out. I replaced the mosfet (thinking it may have been bad from the start) and got the same result. I looked over the circuit and my sketch for a couple of days then I sent pictures (also below) and my sketch to JD that wrote arduino robotics. He said the circuit looked good and he went over my code and fixed some things that could have caused potential issues. He also told me not to use a battery instead of a wall wart and to make sure to test ALL mosfets. So after testing all mosfets, uploading the new code and using a deep cycle battery from my boat for power supply, I pushed the joystick forward and got a little smoke at full power. Then instead of being smart and stopping I went ahead and pulled it into reverse which caused the Q2 position P channel mosfet to explode. I tried again with the same result( partly because it was cool) and another mosfet bit the dust. Now I did try putting a rectifier diode between the drain pin of both P-channel mosfets and the motor terminal in place of the wires and the H-bridge worked perfectly up until I drew over the 1amp that the diode was rated for and it popped but I expected this. Also if I disconnect from the bread board Q1 and Q4 forward will work and unplugging the opposite lets reverse or vice versa work perfectly. I am tempted to just put higher current rated diodes in place and just continue with my project but I do not want to apply the "duct tape" repair to this. I am new to arduino and I am learning as I go but I want to learn the correct way to do things and I also want to learn the "why" behind what I am doing. If I just skip over this problem with a quick fix whatever I am doing wrong weather it is my fundamentals or my execution will continue to come back and cause problems in future projects until I figure out what I am doing wrong. Any help would be greatly appreciated. Oh by the way the motor being controlled is a small gear motor out of a kids power wheels and I am pretty sure it is not drawing anywhere near the 27amp  current limit of these mosfets. The p and n channel mosfets are from sparkfun  http://www.sparkfun.com/products/10213 and  http://www.sparkfun.com/products/10213 

Here is the sketch

int potpin = 0;         // joystick
int gearspeed = 0;
int rvgearlight = 12;    // led reverse gear indicator
int fwgearlight = 11;    // led forward gear indicator
int neutrallight = 13;   // led neutral indicator

int deadband = 25;

int AHI = 2; // these names are more descriptive - A side High input (AHI) - you can open one switch on the A side and one on the B side at a time with no problems.
int BHI = 3; // B side High input
int ALI = 5; // A side Low input
int BLI = 6; // B side Low input

void setup()
  Serial. begin(9600);
  pinMode(potpin, INPUT);
  pinMode(fwgearlight, OUTPUT);
  pinMode(rvgearlight, OUTPUT);
  pinMode(neutrallight, OUTPUT);
  pinMode(AHI, OUTPUT);
  pinMode(ALI, OUTPUT);
  pinMode(BHI, OUTPUT);
  pinMode(BLI, OUTPUT);

void loop(){
  read_signal();  // read the potentiometer, adjust the value to a fwd/rev, then make sure it doesn't go over the
  if (gearspeed > deadband){        //joystick pushed forward
  else if (gearspeed < -deadband){  //joystick pulled back
  else {                            //joystick sitting in center 

void read_signal(){
  potpin = analogRead(0);
  gearspeed = map(potpin, 0, 1023, -255, 255);

  if (gearspeed > 255){
    gearspeed = 255;
  else if (gearspeed < -255){
    gearspeed = -255;

void forward(){
  digitalWrite(neutrallight, LOW);
  digitalWrite(rvgearlight, LOW);
  digitalWrite(fwgearlight, HIGH);
  // write motor values
  digitalWrite(AHI, LOW);
  digitalWrite(BLI, LOW);

  digitalWrite(BHI, HIGH);
  analogWrite(ALI, gearspeed);

void reverse(){
  digitalWrite(neutrallight, LOW);
  digitalWrite(fwgearlight, LOW);
  digitalWrite(rvgearlight, HIGH);
  // write motor values
  digitalWrite(BHI, LOW);
  digitalWrite(ALI, LOW);

  digitalWrite(AHI, HIGH);
  analogWrite(BLI, -gearspeed); // since the gearspeed value is negative, we want to make it positive but use the same speed value.

void neutral(){
  // everything is turned off except the neutral indicator light
  digitalWrite(neutrallight, HIGH);
  digitalWrite(fwgearlight, LOW);
  digitalWrite(rvgearlight, LOW);                     // turns off forward and reverse indicator leds
  digitalWrite(BHI, LOW);
  digitalWrite(AHI, LOW);
  digitalWrite(ALI, LOW);
  digitalWrite(BLI, LOW);


here are two more pics of the breadboard I forgot to attach.


I wonder if the lack of flyback diodes is causing you grief. I know they are "built in" in a mosfet, but depending on your motor, the EMF may be exceeding the mosfet's rating.
Also, I see no decoupling capacitors.
I don't see in your code where it might energize both As or Bs at the same time, so I don't think that's a problem. 


I thought back EMF was just a problem when the electro-magnetic field collapses in other words when the motor is turned off. The mosfets seem to explode as the motor speed is going up. I may be wrong, I guess that was more of a question.  Also do I still need decoupling capacitors powering the motor from a battery and powering the arduino from a pc (both grounded together) there is no voltage regulator in place so I didn't think I needed them.


I'd guess that 8 out of 10 DIY h-bridges probably smoke (at least the simple ones). Probably one set of MOSFETs are not getting either fully turned on causing them to overheat, or not getting fully turned off causing a short condition.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


This schematic is odd. The two additional mosfets (not labeled Q1 to Q4) do not switch the gates of both Q1/Q4 or Q2/Q3. In other words, usually when you're using six mosfets you're controlling the bridge with just two pins, but you're still controlling it with four pins.

Why the extra mosfets?


the two extra mosfets are simply there to invert the signal required to close the mosfet gate. Instead of having to bring Q1 and Q2 low to close the gate and q3 and q4 high to close their gates all 4 switches of the h-bridge are closed with a high signal. I have tried it both ways (with and without the N-channel controlling the p-channels) and have had the same problem.



Have you measured the current draw of the motor? Is it from a 6 or a 12 volt PowerWheels? I know on my PowerWheels, the battery fuse is a 25 amp fuse; at startup, even with no load, the motor can briefly pull quite a bit of amps (still, maybe not 25 amps - but more than you'd think).

BTW, flyback diodes don't just protect against spikes during "shutdown"; they also protect against spikes on reversal, as well as spikes during running (which do occur). You may want some external ones, for reasons already stated.

Do you have any caps across the motor terminals (and from terminal to motor case)? If not, you should (this will also reduce the high-voltage spiking from running motors).

Have you noticed if the mosfets are heating up at all (before they burn out)? This could be an indication of not fully switching on, among other things; it could also be you need a heatsink...

You should know the specs of your motor: ie, what its running and stall current ratings are in order to size the bridge properly. Let's say it runs at 2 amps with no load and stalls at 25 amps. Then you'd probably want your mosfets to be rated 2-4 times larger than the stall current. Note that stall current happens at startup as well for a brief period, not just under full load.

Generally the way bridges do this is by paralleling multiple smaller mosfets together (you can do this with mosfets - but NOT with bipolar transistors); if you do this, you'd probably only need to do the four "main" mosfets that drive the bridge, and not the others.

These kind of issues is why I always encourage people to leave high-power h-bridge design to "experts" and instead purchase such a bridge if needed, unless one is willing to put in the money and time to learn this stuff (and if that is your goal - and you don't mind spending the money to do so). Depending on your source, those mosfets don't come cheap, and you could easily spend more money on building your bridge than if you had just bought one in the first place.

I don't know what your goals are, though, jeremydial1981; if your goal is to become an h-bridge expert, then good luck with your experiments and I hope it doesn't send you to poor house; you'll definitely get an education (and if learning h-bridge design is your goal, then a good quality o-scope may be something to plan on getting sooner rather than later).
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


Hey crOsh,
Thanks for the information. No I have not measured the current draw, the motor is from a 12 volt power wheels. Also I do not have any caps in place so I will get that taken care of. As far as mosfets heating up, while using the wall wart for power I did notice the Q1 mosfet getting hot before it went out. After switching to the deep cycle battery it happens so fast i cannot tell. The smoke and then the explosion of the mosfet into two pieces happens pretty quick. Also let me ask you this, My understanding is that if current draw is too much the mosfet it will just overheat and melt but if it is actually exploding it is caused by a short?

As far as the money, you aint kidding. at a buck a pop I have already went through a bag of about 15 mosfets. My goal is to just to learn so if a spend a few bucks it will be ok but I will tell you if I could go back and start over I would have definitely just purchased one. But I am a little OCD so now that I have started I have to continue and find out what is wrong and make it work lol.

Again I really appreciate all the input from you guys.



I thought back EMF was just a problem when the electro-magnetic field collapses in other words when the motor is turned off.

Just wanted to interject that with PWM the motor is turning off (its coil is de-energised), even if only for some brief period, though you haven't effected a complete off/stop.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!


I didn't even think about that.


Feb 24, 2012, 08:35 pm Last Edit: Feb 24, 2012, 08:38 pm by Elijahg Reason: 1
Have you got the ground from your wall wart (or battery) connected to the Arduino ground too? I can't really tell from your picture, but it looks like you may not. You might want to try putting a fuse (just a single strand of standard wire works well) between the wall wart/battery supply and the FETs, at least then the fuse will blow if the current draw is too high, not your FETs.

Try disconnecting the motor, and just leaving the FETs attached to your power supply by themselves, if they still get hot you know it's nothing motor/noise related.

As it seems to be the P channel ones letting out the magic smoke, it's probably because they aren't being pulled fully high to supply voltage (which turns them off completely). Anything less than Vcc on the gate, and they'll be letting through some amount of current making them hot. The 10k pull-up resistors you have on the P-FET gates might be too large, try a smaller value like 2k.

To check if the P channel FETs are definitely turned off, disconnect the N FETs and check the P channel FET's source leg voltage is zero when pin 2 and 3 are off. If the voltage is zero, then the N channel FETs probably aren't turning off properly, causing a short. You can check the resistance between drain and source on the N FETs with a multimeter, the resistance one way should be say ~4kohms (due to the diode) and the other way should be near enough infinity.

Another thing, is I wouldn't use the Arduino Mega for high voltage/current experimentation, if something blows, you could get 12v through your Mega, which will more than likely kill it. Use an Arduino that's got a socketed chip like the Duemilanove or DIP Uno. Cheaper to replace just the ATmega than the whole board!

Hope that makes some sense and helps a tad :)


Feb 24, 2012, 08:53 pm Last Edit: Feb 24, 2012, 09:02 pm by jeremydial1981 Reason: 1
yes all the grounds are connected.

Question about the p-channel test procedure. You said to test the voltage at the p-channel Source pin...? shouldn't SOURCE leg voltage be at 12 volts regardless since it is connected directly to supply? Did you mean to test drain pin voltage?  Source is going to vcc and drain is going to motor lead.


Apologies, you're right. I was looking at my all N FET schematic which differs slightly to the P/N FET one. Test the drain pin instead :)


Ok sounds good thinks for the info. Much appreciated and from the sound of it I am starting to think it has something to do with the p-fets not being fully off. So with the n channels disconnected the drain pin of the p channels should be 0volts. right? If there is any voltage then they are not fully off. I am going to test and I will let you know what I find.

Go Up