Choices about my H-bridge DC motor driver

Thread Starter

Ephex

Joined Jul 4, 2021
19
Hi!

I'm new to the forum, and glad to be here!

I've designed my own H-bridge (hugely inspired by others on the internet) but I'm struggling with some of the choices. I've tried to figure these things out on my own by searching through the hundreds of other people designing their own H-bridges, but I really need help.

Here's where I am at right now:

H-bridge.PNG

Components used:
P-MSFT1 and P-MSFT2: P-channel MOSFETS
P-MSFT3, P-MSFT4 and PWM-N-MSFT: N-channel MOSFETs
D1, D2, D3, D4: FM4007W-W Rectifiers
C1: 1000 uF capacitor (?)
R1 and R2: 1000 Ohm resistors

Vcc is supposed to be around 12 V and I'm planning on controlling DC motors for small RC cars/robots. I want to be able to control it with a microcontroller via PWM (hence the N-channel MOSFET nearest GND) but I'm unsure about the frequency (typical microcontroller PWM frequency at ~700 Hz?) and whether f > 1000 Hz is possible with the diodes I am planning on using.

My thought is that the current configuration controls the direction with IN1 and IN2 (5 V or 0 V) to close/open the MOSFETs and then to vary the average current through the motor by letting the PWM signal switch the bottom-most MOSFET. Speaking of which, does it work to use the same type as the other N-type MOSFETs or is it possible to use something smaller and less hardcore?

One thing I thought about is that you could use a transistor or a MOSFET to switch between forwards and backwards with only one digital input signal, instead of using both IN1 and IN2. Would that be possible? Would it limit the things the driver circuit could do (I can't imagine what happens if IN1 and IN2 are both on/off)?

Which leads me to braking and coasting. Which MOSFETS have to be closed/open to enable breaking or coasting? This would be a very interesting thing to be able to do.

The capacitor: What should the capacitance be, and does type of capacitor matter? Does the current placement work, or do I need to make sure that it's also cut off by the PWM-switch?

If you see something weird with the schematic, feel free to roast it. I need help! :)

// Ephex
 

Irving

Joined Jan 30, 2016
2,308
The way you have IN1 & IN2 wired to the gates is wrong. As you have it, there will be a point where both top and bottom will be partly on at the same time causing a phenomenon called shoot-through and a massive current spike. You are much better off driving the gates top left & bottom right, and vice-versa, together. If you want braking as well you need to turn the bottom MOSFETs on and the top two off. You would normally apply PWM to the top MOSFETs. Here's an example of one I've used before.

1625430869995.png
 

Thread Starter

Ephex

Joined Jul 4, 2021
19
@Irving Also, do you have some documentation around this circuit? I'd like to know why the resistors have their respective values and why it is wired the way it is :)
I see that you don't have a capacitor, how should it be wired if I'd like to have one?

The 4 diodes D1 to D4 that I have in my circuit, will they function if wired in the same way in your circuit right?

EDIT: Grammar
 
Last edited:

Irving

Joined Jan 30, 2016
2,308
@Irving Thank you so much! How important is it that you have the exact same components as in your schematic?
Well, it all depends on what your driving it from, your supply voltage, and your motor characteristics.

The lower MOSFETs, IRLZ44, are logicFETs and will turn on sufficiently at 3v for motors taking up to 1A, but the circuit is designed for 5v MCU like Arduino Uno and can handle 10A motors with the right heatsinks (incidentally your BUZ11's will only just turn on at 4.5v so they will potentially get quite warm depending on your drive voltage and motor current).

Your BUZ171 will substitute ok for the FP27P06s at motor currents <1A. BTW, that was another flaw in your cct I didn't mention; assuming your drive was from an MCU, the gate voltage would never be higher than 5v, which means with a >=9v supply the source-gate voltage on the BUZ171 was never going to be less than 4v - it would have been pretty much on all the time. Turning on the matching BUZ11 could have released the magic smoke if there were a few amps available from your power supply; in any case both would have got very warm very quickly!

@Irving Also, do you have some documentation around this circuit? I'd like to know why the resistors have their respective values and why it is wired the way it is :)
Nothing written down, but its pretty straight-forward. Q3 & Q4 act as level shifters, turning Q3 on turns Q1 on (likewise Q4 & Q2). Can you see how that avoids the issue I mentioned above? Why don't you have a stab at explaining the values of R1 & R3? Its not rocket science, assume Q3 is a perfect switch... and that the supply voltage is 11v.

Diodes D1 and D2 perform a safety function; can you see what effect they have? (hint: work through what happens when FWD_PM and REV_ENABLE cycle through the 4 possible states of 0v and 5v).

R5 - R8 are there to limit the current in and out of the MCU during the switching transition. I can explain more about that later if you want.

I see that you don't have a capacitor, how should it be wired if I'd like to have one?

The 4 diodes D1 to D4 that I have in my circuit, will they function if wired in the same way in your circuit right?
There is always a capacitor, its not shown because its a given. PWM motor circuits are very spikey in current usage, and when the MOSFETs turn off back-emf from the motor returns current to the supply. The capacitor is there, very close to the MOSFET source connections (top and bottom) to provide a local bulk energy reserve. How big a capacitor depends on your motor current, the ability of your power supply and how long (and thick) the cables from the H-bridge to the PSU are. A good quality, low ESR, 200 - 500uF electrolytic, sized at double the supply volts (so 25v on a 12v supply) is typical. A larger capacitance/higher voltage won't hurt but will be more expensive. This is one area where you want to avoid cheap Chinese and go for a good quality Japanese part (eg Panasonic) where you can get a datasheet and check the ESR (effective series resistance). In parallel with that, a 100nF ceramic capacitor to absorb high frequency transients.

The diodes... what purpose do they perform? Now look at the symbol for the BUZ11 MOSFET on page 1 of the datasheet (below)... what do you see? Look at the MOSFET symbols on my circuit... Now what purpose do your D1-D4 perform? Learn to read the datasheet fully...

1625516494066.png
 

Thread Starter

Ephex

Joined Jul 4, 2021
19
I am learning so much.

This is where I am at right now:

1625602152131.png

I forgot to change the BUZ171 and IRLZ44 "names" in EAGLE to the kind of MOSFETs that are actually going to be on the PCB.. I couldn't find the exact same ones in Fusion360 that I am planning on using, namely this P-channel MOSFET and this N-channel MOSFET. I am not going to use either BUZ171 nor IRLZ44 MOSFETs.

Q1 and Q2 are equivalent mosfets to the ones your Q3 and Q4.

The 4 extra diodes must have been from a YT video that used transistors and not MOSFETs (or some other variant of an H-bridge).

I've added a red LED to view if VCC is connected. This is one of the LEDs (a green one) and this is the part I'm referring to:

1625596550463.png

Vcc will be ~12 V so I calculated R9 by:

v_R9 = 12 V - LED_fwd_voltage = 12 V - 2.2 V = 9.8 V
R9 = v_R9 / LED_i = 9.8 / 0.020 = 490 Ohms

Did I do this correctly? The forward voltage of an LED is the voltage over it at operation current, right? It sort of feels like threshold voltage lol, as if it's when it's when it begins lighting up. What if it's a blue LED with a fwd voltage of 3.3 V? With R9 = 490 Ohms, the current will be ~17.7 mA. I assume this is close enough, and that the blue ones will shine aswell?

Why don't you have a stab at explaining the values of R1 & R3?
I think I actually saw something similar from a YT video. It's a voltage divider? So when FWD_PWM = p and FWD_ENABLE = 1, the voltage at Q1's gate is 11*100/(100+1000) = 1 V, which means that Q1 will be on since the voltage between G and S is 1-11 = -10 V which is "greater" than the threshold (2 V). So it's all to control the voltage I guess?

I have some 1000 uF capacitors coming in so I'm going to use one of them in parallell with a 0.1 uF as you recommended! :)

Now, I have some loose LEDs in the picture, and I actually had them in series with the 150 Ohm resistors, but I became unsure if it would work since I assume there is (practically) no current flowing "into" the MOSFET from the gate? The best way is just to make a new connection from the ports that has a resistor and an LED in series that then leads to GND (obviously it now being +5V and not Vcc)?

I can't stress how helpful this is btw!
 

Attachments

Irving

Joined Jan 30, 2016
2,308
I am planning on using, namely this P-channel MOSFET and this N-channel MOSFET.
The P-channel MOSFET is fine, as you have plenty of Vgs to play with, but your N-channel is less convincing. What is your expected drain current? And from what are you driving the N-channel MOSFETs, ie what do you expect your Vgs to be?

(I guess from the links you're based in Sweden?)

Vcc will be ~12 V so I calculated R9 by:

v_R9 = 12 V - LED_fwd_voltage = 12 V - 2.2 V = 9.8 V
R9 = v_R9 / LED_i = 9.8 / 0.020 = 490 Ohms

Did I do this correctly? The forward voltage of an LED is the voltage over it at operation current, right? It sort of feels like threshold voltage lol, as if it's when it's when it begins lighting up. What if it's a blue LED with a fwd voltage of 3.3 V? With R9 = 490 Ohms, the current will be ~17.7 mA. I assume this is close enough, and that the blue ones will shine aswell?
Yep, perfect. Generally on all 3 and 5mm LED anything >=5 or so mA is good enough. If you are driving them from a GPIO pin (pulling down from 5v on both 5 and 3.3v MCU) 8mA is generally a good value so as not to overheat the MCU.

I think I actually saw something similar from a YT video. It's a voltage divider? So when FWD_PWM = p and FWD_ENABLE = 1, the voltage at Q1's gate is 11*100/(100+1000) = 1 V, which means that Q1 will be on since the voltage between G and S is 1-11 = -10 V which is "greater" than the threshold (2 V). So it's all to control the voltage I guess?
Yes, it is a voltage divider and sized to ensure that not only is there sufficent Vgs to ensure the p-channel turns on, but sufficient gate current to ensure it is turned on quickly as well. I'll cover this in a follow-up post because its not a well understood aspect of driving MOSFETs - it hardly matters driving an LED or a small relay but in H-bridges or other similar topologies such as inverters and dc-dc converters its critical. The 1k resistor is there to ensure it turns off quickly as well. Can you explain why its needed?

Now, I have some loose LEDs in the picture, and I actually had them in series with the 150 Ohm resistors, but I became unsure if it would work since I assume there is (practically) no current flowing "into" the MOSFET from the gate? The best way is just to make a new connection from the ports that has a resistor and an LED in series that then leads to GND (obviously it now being +5V and not Vcc)?
No it wouldn't work. And I'd recommend you don't put anthing else on the GPIO pin driving the MOSFET. It'll become obvious why after the follow up post sometime tomorrow...

I can't stress how helpful this is btw!
You're welcome! :)
 

Thread Starter

Ephex

Joined Jul 4, 2021
19
The P-channel MOSFET is fine, as you have plenty of Vgs to play with, but your N-channel is less convincing. What is your expected drain current? And from what are you driving the N-channel MOSFETs, ie what do you expect your Vgs to be?

(I guess from the links you're based in Sweden?)
I don't really know what the expected drain current is.. All I know is that the MOSFETs can handle a continous drain current of 40 A and 60 A respectively. I also don't know if this is enough with current spikes from the motor in mind.

Driving the MOSFETs as in what's connected to G (PWM signal with amplitude 5V) or what the real source of Vcc is (10-12 V either from 3S LiPo or 3S Li-ion)?

Regarding my N-channel MOSFETs; I can't find any drastic difference between a IRLZ44N and a TK40E06N1,S1X.
Vds: 55V instead of 60 V
Id: 41 A instead of 60 A
Vgs: -16V, +16V instead of -20V, +20V
Vgs th: 1.8V instead of 2.0V

What was it exactly that made TK40E06N1,S1X less convincing? I can't figure it out..

Yes I am Swedish!

The 1k resistor is there to ensure it turns off quickly as well. Can you explain why its needed?
If it weren't there, Vg would always be Vcc which means that Vgs would always be Vcc - Vcc = 0 V? When Q3 is on, there would also be a lot of current shooting through it?
 

Irving

Joined Jan 30, 2016
2,308
OK, starting at the end ...
If it weren't there, Vg would always be Vcc which means that Vgs would always be Vcc - Vcc = 0 V? When Q3 is on, there would also be a lot of current shooting through it?
The gate input of a MOSFET is a capacitor, a pretty good one. So if I charge the gate of Q1 up by turning Q3 on... and then disconnect the drive voltage by turning Q3 off - what happens to the charge?

Regarding my N-channel MOSFETs; I can't find any drastic difference between a IRLZ44N and a TK40E06N1,S1X.
Vds: 55V instead of 60 V
Id: 41 A instead of 60 A
Vgs: -16V, +16V instead of -20V, +20V
Vgs th: 1.8V instead of 2.0V

What was it exactly that made TK40E06N1,S1X less convincing? I can't figure it out..
Lets look at the data-sheets in detail... The TK40E06N1 is characterised at a Vgs of minimum 4.8v. Remember that Vgs(th) is a threshold, at which the leakage current through the channel is guaranteed to be the given value. So for the TK40E06 it says that the leakage will be 0.3mA at Vds of 10v at a Vgs <= 4v but >=2v. It says much more about when the device is off than when its on. The IRLZ44 is characterised down to a Vgs of 2.5v. The upshot is that if you're driving the MOSFET from a MCU the IRLZ44 will turn hard on, the TK40E06 may not. Now, to be fair, it does depend on drain current. If your motor is only taking 1A say (and remember motor start current can be 10x the free running current) then the TK40E6 will probably be just about good enough on a 5v MCU, but useless on a 3.3v one. But if you need, say, 10A start current then you're going to have issues with the TK40E6.

1625758270003.png

1625758352120.png
Here's some simulations to illustrate the point. The top trace shows the drive pulses, increasing from 2.5 to 5.5v. The middle pane is the IRLZ44N, the lower the TK40E06N1. As you can see, the IRLZ44N is delivering from 3v upwards, while the TK40E06N1 needs 5v before its safe (the actual minimum is 4.8v).

1625768085311.png

Now, I'm not saying the IRLZ44N is a perfect MOSFET, far from it. The next traces show the gate voltage and current and as you can see the TK40E06N1 reqires less energy to drive it by virtue of its 23nC gate charge v 45nC for the IRLZ44N. This is down to its more modern construction. This also means its a faster switching device, about twice as fast as the IRLZ44N.

1625770141655.png

For most purposes below say 200kHz the IRLZ44N suffices for both 3.3 and 5v operation, especially for driving relays and the like direct from the MCU, but the TK40E06N1 is the better choice for example in a high-frequency DC-DC converter at switching frequencies > 50kHz and where gate drive voltages of 10v+ are available. I probably should spend some time tracking down a new contender for low frequency MCU interfacing < 10A/50V.

The difficulty for hobby projects is finding devices in through-hole packages. There are some really good MOSFETs out there, but in packages that make thermal management without a 4 or 6 layer PCB really tricky, you can't just slap some thermal goo on and bolt it to the nearest heat-sink...
 
Last edited:

Thread Starter

Ephex

Joined Jul 4, 2021
19
The gate input of a MOSFET is a capacitor, a pretty good one.
Wow, I didn't know that. That's really interesting (and good to know).

So if I charge the gate of Q1 up by turning Q3 on... and then disconnect the drive voltage by turning Q3 off - what happens to the charge?
It would have nowhere to go? "Locking" G at drive voltage and therefore "locking" the MOSFET aswell?

Now for the rest of your post;

I think I understand, but I'm just confused to why such important information is "hidden" in one of the graphs on the datasheet and not on the main characteristics of the component? When I read "Vgs-th = 2.0 V", it sounded like you only have to overcome that voltage for the MOSFET to turn on. I assume you have to take current into consideration, since the required gate-source voltage is dependent on how much current is flowing through the MOSFET. Did I get this right?

Thank you for taking the time to write your informative answers!
 

Irving

Joined Jan 30, 2016
2,308
It would have nowhere to go? "Locking" G at drive voltage and therefore "locking" the MOSFET aswell? =
Exactly. The charge will drain away, but it takes time. Putting the 1k there discharges the 'gate capacitor' fairly quickly. How quickly? Well the gate charge for that MOSFET is (from datasheet) around 35nC (thats nanoColumbs) and we know that Q = i.t so t = Q/i and assuming a linear discharge rate the initial current is Vgs/R = 11/1k = 11mA so the average = 5.5mA. Therefore t = 35e-9/5.5e-3 = 6.4uS. This is a crude calculation and gives a massive over-estimate. For more information, better ways to calculate and an overview of MOSFET operation have a look at this application note.

I think I understand, but I'm just confused to why such important information is "hidden" in one of the graphs on the datasheet and not on the main characteristics of the component? When I read "Vgs-th = 2.0 V", it sounded like you only have to overcome that voltage for the MOSFET to turn on. I assume you have to take current into consideration, since the required gate-source voltage is dependent on how much current is flowing through the MOSFET. Did I get this right?
Its not hidden, the graphs are there for you to use! Reliance on headline figures in the tables is foolhardy. Parameters are dynamic and vary with Id, Vds, etc. As the designer, you have to work the numbers! Gate current is necessary to charge up the gate capacitor (and others). Its not linear. Read the app note above.
 

Thread Starter

Ephex

Joined Jul 4, 2021
19
Alright, I checked the data sheet of the PSMN017-30PL,127 and the gate voltage seems to be acceptable (if I've understood everything). Does it look good to you?

1625852909776.png

Also, how does one know if the time periods are too long or too short for a specific application? Look at the PWM signal frequency that the circuit will experience? Speaking of which, what frequency is suitable for H-bridge? I want the circuit to be able to be controlled by simpler microcontrollers like Arduino, and they have PWM frequencies at ~980 Hz. That would mean a period time of ~1.0204 ms. Should I then watch out if any of the below time periods compose more than a certain percentage of this period time?

1625855712887.png

Now they won't make up a considerable amount, with them being in nanoseconds and the period time of my PWM being around 1 ms, but you never know.
 

Irving

Joined Jan 30, 2016
2,308
Alright, I checked the data sheet of the PSMN017-30PL,127 and the gate voltage seems to be acceptable (if I've understood everything). Does it look good to you?
That's a good one, I found a couple of others from NXP and Vishay, but only "on back order" at Mouser

Also, how does one know if the time periods are too long or too short for a specific application? Look at the PWM signal frequency that the circuit will experience? Speaking of which, what frequency is suitable for H-bridge? I want the circuit to be able to be controlled by simpler microcontrollers like Arduino, and they have PWM frequencies at ~980 Hz. That would mean a period time of ~1.0204 ms. Should I then watch out if any of the below time periods compose more than a certain percentage of this period time?
An excellent question, and not one that's easy to answer. For a DC brushed motor a lot depends on the motor - specifically the number of poles and the winding inductance L, resistance R and the time constant L/R. If the pulse is too short the L won't allow enough current to build up in the windings before the pulse is over... so you can't run easily at slow speeds and starting slowly under load becomes an issue. Unless you have detailed motor spec's the simple answer is try it and see. An Arduino Uno by default outputs PWM at 490Hz on D3, D9, D10, D11 and 976Hz on D5 and D6. Crudely, a typical small motor has 3 windings and 6 segments on the commutator. So at 3600rpm, or 60rps, a pair of windings are energised for approximately 50mS, roughly equivalent to 25 pulses on D5/D6 or 12 pulses on the other outputs. You may find, for a 12v motor, you need to run the H-Bridge at 18v or 24v to get enough torque at low speeds - remember amps = torque, volts = speed.

A serious large motor controller, like the one on my wheelchair that is capable of 90A, or up to 120A for 10sec on starting/turning, has a current sensor (typically a few mOhm sense resistor between the lower N-channel MOSFET sources and ground) so it can control current as well as volts. It actively changes the pulse width during the cycle so the current is high initially but reducing so maintaining the average voltage lower to keep the speed low, but the torque high. An Arduino doesn't have the processing speed to do that effectively and its common to find a dedicated hardware brushed motor controller between MCU and H-Bridge.
 
Last edited:

Thread Starter

Ephex

Joined Jul 4, 2021
19
Alright! It will probably be used on robots or something like that, so low rpm is really necessary. The motors I plan on testing with this circuit are not geared, which makes me feel like I need to have some reducing. Wouldnt that mean, that the problem of not being able to drive it well at low rpm, would disappear (or be reduced)? If the wheels on the robot need to rotate slowly, the motor will have to rotate much faster (how much depends on the gearbox) and therefore (partly) avoiding the problem of driving it at low speeds? Ofcourse, if I'd want to drive the wheels at an extremely slow speed, the motor would have to rotate at relatively low speeds, which would make it come closer to the problematic area.

Thanks for the help, once again! I'll hopefully remember to post a picture with the finished PCB and if it worked. That'll take a few weeks though..
 

Irving

Joined Jan 30, 2016
2,308
A typical small DC motor will rotate at 3000-5000rpm and has relatively little torque. To drive a robot you'll need to gear it down to reduce the rpm and increase the torque. Typically a 20:1 to 30:1 gearbox. You need to choose a motor/gearbox/drive-wheel combination to give appropriate power/rpm/torque that matches the mass of your robot and any other load it carries, the acceleration/top speed desired, hill-climbing ability, etc. You can't just start with a random motor and try to make it work - it won't.

I feel a tutorial on basic mechanics coming on... (yes, I teach that too!).
 
Last edited:

Thread Starter

Ephex

Joined Jul 4, 2021
19
Yes, those things are actually something we've done a bit of (mostly the mechanical part), I am studying Mechatronics Engineering :). Now that I think of it, I will be able to use the same MATLAB scripts again haha!. I was just sharing my thought about if a gearbox would eliminate or at least minimize the problem with driving DC motors at low prm, since the motor would have to turn much faster than the wheels, hopefully rarely rotating too slow.

Solving the gearbox issue once I have a motor with the right specs and actually implement such a mechanical solution on the other hand, that will be interesting!
 
Top