Arduino Forum

Using Arduino => Motors, Mechanics, and Power => Topic started by: kimmjoe on May 28, 2018, 10:06 am

Title: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 28, 2018, 10:06 am
Hey Guys,

for a school project, I have to build a discrete H-Bridge using MOSFETs to drive a 12V DC-Motor in both directions. I haven't had a chance to measure the motor yet, but I guess starting (and blocking) current will be about 20-30 A'ish and continuous current will be below 5A

It will be used for educational purposes, so it should be as simple as possible. I would like to avoid separate drivers and drive all the FETs directly from the 5V Arduino Nano.

For the low side, I want to use IRLIZ44n, because I already have them here and I've worked with them before. They are real logic-level devices and can be used with PWM. So if i decide to maybe include some smooth start for the motor, I can PWM them on the low side and dont need to care for that on the p-channel side.


I'm looking for p-channel MOSFETs for the high side. Preferably these should be in TO220 packages as well. So far I found these two:

NDP6020P
which is a real logic-level device.
Datasheet:
http://www.onsemi.com/pub/Collateral/NDP6020P-D.PDF (http://www.onsemi.com/pub/Collateral/NDP6020P-D.PDF)

and

FQP27P06
which is sold by Adafruit and Sparkfun for usage with micro controllers. It is not a real logic level device but has a better source-gate voltage rating for my project (I think).
Datasheet:
https://cdn-shop.adafruit.com/datasheets/1794datasheet.pdf (http://)



I never used p-channel before, so I'm really not sure, which ones to get.
In post #3 in this threat link (http://forum.arduino.cc/index.php?topic=184546.0) the guy says, that for p-channel MOSFETs the gate level is less important than the source-gate voltage.

So, I really dont know how to decide, can you help me out?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: Wawa on May 28, 2018, 01:29 pm
No need to use logic level p-channel fets high-side, because you have 12volt gate drive available there.
The NDP6020 has a max Vgs of 8volt !
Post a diagram.
Leo..
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 28, 2018, 01:40 pm
Yeah, thats what I meant. So the NDP6020 will not do, because vgs will be 12V when i apply a low signal to the gate, right?

So you got a reconmendation for high side FETs?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: Wawa on May 29, 2018, 12:55 am
Any p-channel with a low Rds(on) will do.
You might run into switching loss problems with fets with high gate charge.
Keep PWM frequency low if you don't want to use a gate driver chip.
Leo..
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on May 29, 2018, 05:27 am
Quote
I would like to avoid separate drivers and drive all the FETs directly from the 5V Arduino Nano.
So your motor supply is 5V?

Remember that to turn the high side P mosfets off you must give them a gate voltage equal to the supply voltage. An N mosfet and a pullup resistor can do this but I don't know if that violates your "no drivers" rule.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MarkT on May 29, 2018, 02:58 pm
You can't drive 12V high-side p-FETs from a 5V Arduino without some sort of driver - like a NPN transistor
as a level shifter.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 29, 2018, 04:58 pm
Thank you guys for your input. Anyway, there is a change of plan. I need galvanic isolation. So I will have to use opto couples.

I found that, but to be honest, i have no idea, hot the part between the MCU and the bridge works:
https://onebyzeroelectronics.blogspot.com/2016/03/how-to-make-simple-h-bridge-from-mosfet.html


(https://2.bp.blogspot.com/-QM4fcXBmQ8s/Vvq6_DyhE7I/AAAAAAAAASk/J8vBu2wRqjswIOH39hMqwAf1kZMlF1BIg/s1600/Alternative-to-L293d.png)

So I guess, wenn "C" is LOW, voltage from VCC to the left FET on the HIGH side of the bridge, turning it "OFF" and the lower one "ON".
While, wenn "C" is "HIGH", voltage from VCC is drained through the optocouple and the gates on the FETs discharge and do the opposite? Is that right?

Also, I guess, its not possible to PWM this thing, right?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MarkT on May 29, 2018, 05:45 pm
You have classic problem of shoot-through with that circuit - both top and bottom FETs will be on
for a brief instant during switching and create a big current spike from the supply through them.
I'd drive each FET separately so you can properly sequence the switching with "dead time" between
switching one off and its partner on.

Your circuit claims galvanic isolation but you've shared the same ground in the diagram - I presume
you don't mean that.

Normal opto-couplers (photo-transistor based) are slow enough that PWM isn't going to work except for
very low rates (though the default Arduino PWM is pretty slow, note).

Faster opto-couplers are available for logic speeds, they generally need 5V power on both sides as
they have signal conditioning circuitry for transmitting and receiving to improve the speed.  Internally
they use photodiodes, not photo-transistors.

Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 29, 2018, 06:24 pm
You have classic problem of shoot-through with that circuit - both top and bottom FETs will be on
 [...]

Your circuit claims galvanic isolation but you've shared the same ground in the diagram - I presume
you don't mean that.
Yeah, thats what I thought, but with four opto-couplers I could do it? So, with these, I wouldn't need gate drivers, because I could just drive all the the gates from the 12V?


Its not my schematic, its from the webb adress i postet. But yes, i guess the guy didnt mean to have same GND on both sides.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on May 29, 2018, 06:47 pm
The concept of a H bridge is very simple. That diagram is very simple. Making it really work at non-audible PWM frequency is not simple.

Does this actually have to work for a long period under different conditions? Or do you just demonstrate it to the teacher? If it is demo only then build that circuit.

If you actually do want to use this in a project that will run for a long time then buy a chip like the VNH5019.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 29, 2018, 07:37 pm
Haha, i know there are loads of ICs out there, but my teacher wants it discrete ;)

Well, its supposed to work for a couple of yeara to open a hatch in a cupboard. Its a noisy room, so its not really important if it makes a PWM sound.

Will 4n35 optocouples work?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on May 30, 2018, 12:51 am
Ok, good information.

So why is galvanic isolation important? It will be much more robust with mosfets instead of optos.

You can buy dedicated mosfet drivers that take away most of the gate drive problems. They are able to switch the mosfets very fast and you could probably find a chip with 4 drivers and built-in shoot-through protection.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 30, 2018, 07:20 am
Ok, good information.

So why is galvanic isolation important? It will be much more robust with mosfets instead of optos.

To be honest, because my teacher says so ;) I dont think its really necessary, I would use a step down module to drive the Arduino from the 12 Volt PSU and have no galvanic isolation if it was my decision but my teacher insists on having everything neat and tidy separated. To use two separated PSUs and so on..

I will order some 4n35 and some PC817 and see how it works out in real life. Arduinos PWM isnt that high anyway (I hope). I will use FQP27P06 for the HIGH side (There is not to much to choose from when it comes to P-MOSFETs, and these ones seems to be the top seller on mouser).
You guys have a recommendation for the N-MOSFETs? Or can I just stick to the IRLIZ44 even though I will be driving them with 12V?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on May 30, 2018, 04:19 pm
Yes most or all logic level mosfets can be driven by 12V. Most of them will have a Vgs maximum of 20V. Look for this in the section of the datasheet that says "Absolute Maximum Ratings".
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MarkT on May 30, 2018, 05:01 pm
One nice feature of galvanic isolation is that if you blow up MOSFETs you don't risk blowing up the
Arduino as well.  The downside is the sluggish response of standard(*) optoisolators.

(*) those with photo-transistor outputs.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 30, 2018, 05:34 pm
Alright, now I got almost all the info I need to make my big order ;)

I got one more question about freewheeling diodes. Both' FETs datasheets speak about body diode characteristics, so do these have freewheeling diodes built-in? Or should I add external ones as well? If so, which ones? I got loads of n4001 lying around, but I guess 1A is not enough, even though it will be only for a splitsecond, right? Or shoul I go for Zeners (which)?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MarkT on May 30, 2018, 06:22 pm
Power MOSFETs happen to have body diodes as an integral part of their high-current handling structure.

If, and only if, you have a bridge with both high and low-side MOSFETs, each one can be the diode
for the other.  If you only have a single switching MOSFET, the load will need a diode across it, since
the MOSFET diode is no use in that situation.

For more efficiency you can add schottky external diodes.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 31, 2018, 03:39 pm
I made a schematic, please dont laugh, its my first time with KiCAD...

(https://forum.arduino.cc/index.php?action=dlattach;topic=549970.0;attach=260198)

I'm not sure about the Resistors between 12V and the GATES. should these be different on the P and N Channel FETs?

Also, how to determine the Value for these Resistors?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on May 31, 2018, 05:26 pm
You don't need those diodes. Look inside the mosfet symbols to see the body diodes.

The resistors must charge the mosfet inherent gate capacitance quickly enough to support your PWM speed. The gate capacitance is complex but the datasheet should give you a headline number to work with.

Or copy the resistor value from someone else's similar project.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 31, 2018, 06:05 pm
What about the position of the resistor? From what I saw here: http://www.bristolwatch.com/ele2/mosfet_relay.htm
the ones on the HIGH Side are right, but on the LOW site, they need to go between GATE an SOURCE, is that correct?

I edited it on the right side in the new schematic, so you can see what I mean.
(https://forum.arduino.cc/index.php?action=dlattach;topic=549970.0;attach=260220)

How would I calculate the value? Datasheets mention "Input Capacitance", "Coss Output Capacitance", "Crss Reverse Transfer Capacitance" and "Drain to Sink Capacitance".

So the gate and the resistor form an RC network, which is bad for fast switching, but what equation gives me the ideal value for R?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on May 31, 2018, 07:20 pm
From what I gather, the higher the resistance, the slower the rise and fall times of the FET will get.

But there has to be a certain amount of resistance to protect the transistor in the opto isolator.

So, in order to be able to PWM it, resistance has to be as low as possible to make the FET as fast as possible.

The 817 transistor's maximum collector current is 50 mA. This means R = U / I ->> 12V / 0.05 A = 240 Ohm. But I don't want to drive the transistor at maximum, so I could double or quadruple and try 500 or 1k Ohm. 
Is that correct?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: Wawa on Jun 01, 2018, 12:00 am
Try calculating the resistors the other way.
You have 20mA (40mA absolute max) available from an Arduino pin.
Vf of the opto's IR LED is ~1.3volt, so 5-1.3= ~3.7volt across the LED's current limiting resistor.
CL resistor value is 3.7/0.02= ~185ohm.
Standard value of 180ohm will do.

Worst case CTR (current transfer ratio) of a PC817 is 50%, so 10mA transistor current available.
You want full swing of the collector at 12volt/10mA.
Collector resistor minimum value with worst case PC817 = 12/0.01 = 1200 = 1k2.
Let's hope the PC817s are not that bad, so use 1k.

Where to put the opto transistor. As in the diagram for Q3 or for Q4.
Not conducting transistor is almost ideal open circuit, but conducting has a saturation voltage.
Fet Vgs 'off' voltage range is small, but Vgs for 'on' can be anything between 6volt and 12volt.
I think it's therefore better to have the resistors between gate and source, and the transistor between gate and ground/12volt.
Leo..


Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: Wawa on Jun 01, 2018, 05:16 am
Possible parts reduction.

The four schottky diodes, as axplained by MarkT (post#16).

Two Arduino pins instead of four.
The opto LEDs for Q1 and Q4 can be driven by one Arduino pin, by connecting the LEDs in series.
The single CL resistor for the two LEDs must be reduced to 100 or 120ohm to keep LED current the same.
Same for the Q2, Q3 pair.

If the supply is at least 12volt, then you might be able to get away with only two optocouplers.
Connect one opto transistor between the gate of Q1 and the gate of Q4.
Gate to ground resistor for Q4 must have a slightly lower value than the gate to 12volt resistor for Q1.
Because one is fet is logic level, and the other one is not. 470ohm+560ohm could be ok.
Leo..

Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on Jun 01, 2018, 08:15 am
Two Arduino pins instead of four.
The opto LEDs for Q1 and Q4 can be driven by one Arduino pin, by connecting the LEDs in series.
The single CL resistor for the two LEDs must be reduced to 100 or 120ohm to keep LED current the same.
Same for the Q2, Q3 pair.
Hey Wawa, thank you for your input! Woulnd I need another logic invertng transistor to do that? My understanding is, that the high side FETs conduct, when no voltage is applied, while the low side ones conduct when voltage is applied. So I would need to invert one, if I were to drive them diagonally with one signal.
Anyway, it would safe me only about 50ct for optos and resistors and I got enough I/O pins to spare on the Nano. Another thing is what would happen if I were to use PWM in that configuration, since high and low side FETs have different characteristics, maybe it would mess up PWM even more...?
My Idea was to turn on the High side and apply PWM to the other to avoid that.

Im hoping that I'll get the parts this weekend so that I can put it all together and do some mesuring on Monday.
I will let you know how it turns out!
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on Jun 01, 2018, 09:22 am
Where to put the opto transistor. As in the diagram for Q3 or for Q4.
Not conducting transistor is almost ideal open circuit, but conducting has a saturation voltage.
Fet Vgs 'off' voltage range is small, but Vgs for 'on' can be anything between 6volt and 12volt.
I think it's therefore better to have the resistors between gate and source, and the transistor between gate and ground/12volt.
Leo..
Ao you're saying i should rather do it like I drew it on O3 rather than how I drew it on Q4?
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: MorganS on Jun 01, 2018, 03:42 pm
My Idea was to turn on the High side and apply PWM to the other to avoid that.
Yes, that is a common method.
Ao you're saying i should rather do it like I drew it on O3 rather than how I drew it on Q4?
No, like Q4. The mosfet is off when Vgs is near zero. Many have threshold voltages as low as 1.4V so your opto on Q3 has to work hard in saturation mode to get its voltage that low.

The opto on Q4 is off to turn the mosfet off. The resistor will (eventually) discharge the gate capacitor to zero volts.

You should test the voltages on these drivers before hooking up the mosfets. I expect that either arrangement will work unless the optos are using an internal Darlington topology or something weird.
Title: Re: Building H-Bridge with MOSFETs - P-Channel question
Post by: kimmjoe on Jun 01, 2018, 07:07 pm
Thanks for that clarification! I edited my schematic accordingly. Maybe you could have final look, before I solder it all on a hole grid board ;)


(https://forum.arduino.cc/index.php?action=dlattach;topic=549970.0;attach=260398)

Oh, btw I left the diodes in there, because ... well I ordered them and I guess my teacher will like additional safety measures. I got SB530 which are in DO-201 packages, they're so huuuge!! ;) I like components that look like they can take couple of Amps ;)