2
\$\begingroup\$

I'm having a problem with a H-bridge, that drives a motor.


Schematic

This is the schematic for the H-bridge. Signals H[4:1] are generated by a microcontroller. mX and mY are the outputs for a DC motor.

H-Bridge Schematic


How it works

The microcontroller receives an external message via UART. When the message is received, the microcontroller switches de H-bridge, reversing the motor direction. This messages are received around once at every 4 seconds. So, in practice, the motor should be changing its rotation direction at every 4 seconds.


Microcontroller firmware

while(TRUE) {
    if(receivedCmd == 0x01) {   //direction1
        GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef) (GPIO_PIN_2 | GPIO_PIN_3));    //H1-H4
        GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef) (GPIO_PIN_3 | GPIO_PIN_4));   //H2-H3
    }
    else if(receivedCmd == 0x02) {  //direction2
        GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef) (GPIO_PIN_3 | GPIO_PIN_4));    //H2-H3
        GPIO_WriteHigh(GPIOD, (GPIO_Pin_TypeDef) (GPIO_PIN_2 | GPIO_PIN_3));   //H1-H4
    }
    else {    //do not activate
        GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef) (GPIO_PIN_3 | GPIO_PIN_4));    //H2-H3
        GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef) (GPIO_PIN_2 | GPIO_PIN_3));    //H1-H4
    }
}

The problem

At first, the circuit is working as expected, but after working for 1 minute or so, the mosfets Q3 and Q4 will endup burning.


Questions

I only have 2 spare mosfets left with me right now, so I decided to ask for help here before trying to implement some changes.

  1. I did not add flyback diodes in parallel with the mosfets. Are they really necessary? Should I add them? Could this be the problem with my circuit?
  2. Is there something wrong with my firmware? Should I add a deadtime before reversing the motor direction?
  3. Could breaking the motor (activating Q1 and Q3, and deactivating Q2 and Q4) before reversing it be a solution?
  4. Any other ideas on what may be happening?
\$\endgroup\$
11
  • \$\begingroup\$ What's the current capability of the FETs? \$\endgroup\$
    – Puffafish
    Commented Sep 23, 2020 at 15:04
  • \$\begingroup\$ It's always Q3 and Q4? How many times did you try it? As I see it, each pair of transistors is flyback-protected by the body diodes of the other pair of transistors, so that shouldn't be it, unless your 12V supply can't take reverse current. \$\endgroup\$ Commented Sep 23, 2020 at 15:24
  • \$\begingroup\$ We may need more info. What are the motor specs? Also see your board layout...electrically, this seems quite symmetrical, so if only Q3 and Q4 are affected, they may have different power dissipation capabilities if the layout geometry is significantly different. \$\endgroup\$ Commented Sep 23, 2020 at 15:29
  • 3
    \$\begingroup\$ Are you allowing the motor to stop before applying reverse voltage? Aside from that, this could be as simple as shoot-through. If you don't allow enough time for Q3 to turn off then when you turn Q1 on a high current will flow through Q3 and Q1. If that kills Q3 (short, as is customary for semiconductors) then Q1 will shortly follow its neighbor into the dark. \$\endgroup\$ Commented Sep 23, 2020 at 15:45
  • 3
    \$\begingroup\$ What’s your switching frequency and dead band? Show gate waveforms! \$\endgroup\$
    – winny
    Commented Sep 23, 2020 at 16:25

1 Answer 1

4
\$\begingroup\$

As I interpret the code:

if(receivedCmd == 0x01) {   //direction1
    GPIO_WriteLow(GPIOD, (GPIO_Pin_TypeDef) (GPIO_PIN_2 | GPIO_PIN_3));    //H1-H4
    GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef) (GPIO_PIN_3 | GPIO_PIN_4));   //H2-H3
}

In the code above, in direction 1, pins 3 and 4 are on.

else if(receivedCmd == 0x02) {  //direction2
    GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef) (GPIO_PIN_3 | GPIO_PIN_4));    //H2-H3
    GPIO_WriteHigh(GPIOD, (GPIO_Pin_TypeDef) (GPIO_PIN_2 | GPIO_PIN_3));   //H1-H4
}

Now, in direction 2, pins 2 and 3 are on. Pin 1 is never used.

This means that in both directions pin 3 is on. This would mean a short through Q3 and Q4 during direction 2. Your comments for the lines "H2-H3" and "H1-H4" are correct, but I think the pins not implemented like this.

\$\endgroup\$
4
  • \$\begingroup\$ Answer is good, but I think Spehro Pefhany's comment also needs attention, as switching from full forward to full reverse is going to produce even higher currents / voltages... so even if the code is corrected, there are chances to damage the parts. \$\endgroup\$
    – schnedan
    Commented Sep 23, 2020 at 21:58
  • \$\begingroup\$ also winny said one thing correct, a normal H-bridge controller assures a dead time control, to make sure the valves (in power electronics the switch elements are called valves) have fully closed prior to open others. here a secure state machine is a must at least, but better use a hardware chip to do that... otherwise e.g. debugging or a cpu-stall may lead to unwanted side effects... \$\endgroup\$
    – schnedan
    Commented Sep 23, 2020 at 22:03
  • \$\begingroup\$ @UweD For direction1 I'm using the port C of the MCU. For derection2 port D is used. So it is not the same pin 3 that are used for both directions \$\endgroup\$
    – espanhol
    Commented Sep 24, 2020 at 11:29
  • \$\begingroup\$ @schnedan Yeah, i did not add any dead time. I think this is one of the issues. Also breaking the motor before reversing it will probably help in some ways. \$\endgroup\$
    – espanhol
    Commented Sep 24, 2020 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.