Automotive PWM control of p-channel MOSFET (IRF4905) as high side switch

Just one question Dirk. Is there any particular reason why you want to persist with circuits that don't work, when you have already been given much simpler circuits that do work? The ones below for example.

stuart0:
Just one question Dirk. Is there any particular reason why you want to persist with circuits that don't work

I really do not "want to persist with circuits that don't work" (not sure where you got the impression I do).

stuart0:
when you have already been given much simpler circuits that do work?

I would love to have something simpler, but I'm puzzled as to why you'd say this; outside the zener bit (required to ensure the PMOSFET's gate doesn't get too much voltage), the pull-down (see notes below) and one more resistor, my latest isn't more complex than your second suggested circuit - plus, it has been suggested that, by using the BC327 and BC337, I could eliminate R3 and Q1 (the gain of the BC3*7 is significantly higher than anything else I've had in there previously - suggesting that the current required to drive them is well within the ability of the Arduino output's 20mA).

I know you explained it earlier, but I still don't completely understand your first suggested circuit (which is itself only one pin less complex than your second suggestion). From what I can understand, it seems to be somewhat less efficient than a totem pole arrangement (inverted or not). I could, of course, be wrong about this last...

I have a few questions:

  • how do either of your suggested circuits have the PMOSFET off by default? (This is foundational to me not using either of them; the PMOSFET must be driven OFF when the whole circuit first receives 12V. This is not optional.)
  • it seems you're applying 12(+)V to BJTs which use 5V at their base (noting my prior comments about having to manage voltage transients/spikes possibly in excess of 20 volts); could this be corrected with a simple voltage divider or should I use the regulated 5V I have available that's also powering the Arduino?
  • was the explicit suggestion by someone else in this topic to stay away from having a resistor in series with the PMOSFET's gate misguided? If so, how would this be corrected?
    Why and/or where specifically does my circuit not work? The largest concern I understand is the "shoot-through" for inverting the totem pole (I would love to hear about how to mitigate this), and I'm a bit suspicious of the pull-down, but not sure how to mitigate the Arduino output possibly floating before it can be initialized.

Cheers!
Dirk

dephwyggl:
I really do not "want to persist with circuits that don't work" (not sure where you got the impression I do).

I would love to have something simpler, but I'm puzzled as to why you'd say this; outside the zener bit (required to ensure the PMOSFET's gate doesn't get too much voltage), the pull-down (see notes below) and one more resistor, my latest isn't more complex than your second suggested circuit

Dirk, the big difference is that my circuits work (yes I haven't shown the zener or the mosfet, I expect you to add those).

The first circuit (with the diode) is just as "efficient". As I explained earlier it saves little in components but is easier to wire up, particularly in prototype. The two terminal axial diode is just easier to breadboard than a transistor. And it works just fine, as you need no further current gain in the pull down stage.

There is nothing "inefficient" in these circuits. They are relatively simple and will drive your mosfet perfectly. They both default to "mosfet off" when the input is removed. Just set the output resistor to the value you required for the particular switching speed you need (currently 22 but you could go up to about 150 without any significant switching losses, and which btw may make your circuit less sensitive to layout and stray inductance issues).

dephwyggl:
I have a few questions:

  • how do either of your suggested circuits have the PMOSFET off by default? (This is foundational to me not using either of them
  • When the input is high impedance then the bottom transistor is off. (And all Ardunio pins except those used by the boot loader default to input high impedance at power up).

  • When the bottom transistor is off then its collector is pulled high.

  • This makes the base of the second transistor high, and hence the driver output is high.

  • When the driver output (gate of the p-mosfet) is high then the mosfet's source-gate voltage is less then the threshold, hence it is off.

Remember that the source terminal of the p-mosfet is tied high (at the power supply positive potential), so when the gate voltage is high the source-gate voltage is low.

I explained this earlier btw. Understanding the required voltages to turn on and turn off the mosfet is just so fundamental that you can't design a driver circuit without this knowledge. You don't appear to have this knowledge, so you need to listen to those who do.

it seems you're applying 12(+)V to BJTs which use 5V at their base (noting my prior comments about having to manage voltage transients/spikes possibly in excess of 20 volts); could this be corrected with a simple voltage divider or should I use the regulated 5V I have available that's also powering the Arduino?

No need to correct anything. It will work correctly within the voltage range you've specified.

Note however that you should be clear about what are the steady operating voltages you expect (eg 10 to 14.5 volts), and what are just brief (< 1 sec) transients (eg 15 to 22 volts). You don't need to worry much about average power dissipation issues (aka heating) at the voltage levels associated with only brief transients.

was the explicit suggestion by someone else in this topic to stay away from having a resistor in series with the PMOSFET's gate misguided?

Yes, if that was said then it was misguided. (Or perhaps you took it out of context).

If so, how would this be corrected?

By ignoring it.

stuart0:
Dirk, the big difference is that my circuits work (yes I haven't shown the zener or the mosfet, I expect you to add those).

I expected as much (both that your circuits work, and that I'd have to add some of the "extra" bits).

stuart0:
The first circuit (with the diode) is just as "efficient".

I'm happy to take your word on this. Though:

stuart0:
As I explained earlier it saves little in components but is easier to wire up, particularly in prototype. The two terminal axial diode is just easier to breadboard than a transistor. And it works just fine, as you need no further current gain in the pull down stage.

I still don't understand it any better. :o Just gotta stew on this one a bit, I guess.

stuart0:
There is nothing "inefficient" in these circuits. They are relatively simple and will drive your mosfet perfectly.

I'm sure they are and do. I just don't understand either of them, apparently.

Thank you very much for your patience and additional explanations, Stuart. I really do appreciate them.

...and I just noticed you posted some more responses while I'm putting together this one. Thank you! All very helpful. (I think I nearly understand most of it. :slight_smile: ) Though I should re-iterate: I do have regulated 5V (at least 400mA) available; wouldn't it make things more reliable if I used that to drive the BC3*7 bases with that?

Cheers!
Dirk

the gain of the BC3*7 is significantly higher than anything else I've had in there previously

Just about any small general purpose transistors (of the correct npn/pnp type) will work in the above circuits. I just use the bc327/337 because they have reasonably good performance and are readily available at extremely low cost (usually a few cents each in qualities > 20). That and I have a load of them on hand. :slight_smile:

Though I should re-iterate: I do have regulated 5V (at least 400mA) available; wouldn't it make things more reliable if I used that to drive the BC3*7 bases with that?

No. The first stage (bottom bc337) is already driven from 5V maximum from an Arduino output. The second stage (the class B push-pull stage) NEEDS the bases to be driven at (nearly) the full swing of the power supply. This is not a problem, it is like that by design. The emitter voltage simply "follows" this base voltage (this configuration is sometimes referred to a push-pull emitter follower), so there is no problems with too much Vbe if that was you concern.

dephwyggl:
I still don't understand it any better. :o Just gotta stew on this one a bit, I guess.

Their operation is actually a whole lot simpler than the output stages in the recent circuits that you've been proposing. In those circuits the upper and lower transistors (in the output stage) are constantly fighting each other. Almost all of the output current just shots straight through those transistors, heating up the resistors but providing almost no output current where you actually need it (to charge and discharge the mofet's gate). Those circuits that you have been proposing are really really really horrible. You need to completely forget about them ok. :slight_smile:

Where you might have gotten confused here, is that in some applications (half bridges in particular) it really is more efficient to have the upper and lower transistors fully saturate. And when done properly, an upper pnp / lower npn arrangement like you've been considering can be more efficient. But this configuration is trickier to drive, and it has to be done properly.

In the present application however, that of providing gate drive to the mosfet, there is absolutely no requirement that the upper and lower transistors fully saturate, so the simple "emitter follower" stage is just fine. This simple push-pull emitter follower arrangement is very easy to drive and pretty much bullet proof as the two transistors physically CANNOT be on at the same time. When the upper npn is conducting the lower pnp has it's base reverse biased, and vice versa.

The alternate circuit (first one) with the diode might seem a little harder to understand. If however you can understand the other (3 transistor) one, then just think of it as acting precisely the same way, but with the lower pnp transistor (now actually a diode) having a current gain of unity. It doesn't effect the operation because the first stage already provides plenty of pull down current, so no further current gain is required in that direction. Sorry I can't explain it any other way.

it seems you're applying 12(+)V to BJTs which use 5V at their base (noting my prior comments about having to manage voltage transients/spikes possibly in excess of 20 volts); could this be corrected with a simple voltage divider or should I use the regulated 5V I have available that's also powering the Arduino?

Ah the penny has finally dropped. I think I've figured out what your obsession with 5 volts and the BJT's base is. On the transistor data sheet the absolute maximum emitter-base voltage is 5 volts right. Is that the reason?

Well that is a reverse voltage limit and has absolutely nothing to do with the operation of either circuit. :slight_smile:

I disagree with one of your respondents. You do not I repeat not need a resistor in the gate circuit of the FET. Put the totem pole transistors, which can also be described as a bi-directional current source (the clue is in the description), as close to the FET gate as you can get them and all will be well.
If you are still unconvinced I will try to get some scope shots of my 15A supply, which uses a P Fet with the drive circuit I have been proposing, to demonstrate the point.

NOSUM

First, thank you very much for all your additional explanations on both your suggested circuits, and what may be less than ideal on mine. I'll be going over them for a bit before I respond further.

stuart0:
Ah the penny has finally dropped. I think I've figured out what your obsession with 5 volts and the BJT's base is. On the transistor data sheet the absolute maximum emitter-base voltage is 5 volts right. Is that the reason?

Well that is a reverse voltage limit and has absolutely nothing to do with the operation of either circuit. :slight_smile:

Welp, there you go again, being all helpful and explain-y. ;D One of the larger challenges I've been facing is trying to interpret specs. My general approach to learning electronics (at least so far) has been to visualize components with characteristics I do know, and try to build on that by stirring in bits of specs which I think I understand - only to have to break out the marshmallows every time I stick something into a breadboard. (The last time, I was - unintentionally - feeding 12V into the base of a 2N3904. The scars on that breadboard are permanent. ...though, from what you're saying here, that may have been for reasons other than feeding 12V into the base of a 2N3904.) Reading specs for BJTs will never - thankfully - be the same again; I actually understand now the difference between VCBO and VEBO. :slight_smile:

Thank you, Stuart. After the next post (to you and NOSUM), I'll be spending some time trying to (better) grok everything you've been saying about both of your suggested circuits.

PS I'm still foggy on how to use the (apparently profligate - though maybe necessarily so) hFE specs to calc current use by the base of BJTs.

Cheers!
Dirk

NOSUM, Stuart,

Here is another of the challenges I'm facing; two - clearly both very experienced - contributors (maybe) at odds. I had originally said to Stuart:

dephwyggl:
I have a few questions:
[...]

  • was the explicit suggestion by someone else in this topic to stay away from having a resistor in series with the PMOSFET's gate misguided?

To which Stuart replied:

stuart0:
Yes, if that was said then it was misguided. (Or perhaps you took it out of context).

And just now, NOSUM says:

NOSUM:
I disagree with one of your respondents. You do not I repeat not need a resistor in the gate circuit of the FET. Put the totem pole transistors, which can also be described as a bi-directional current source (the clue is in the description), as close to the FET gate as you can get them and all will be well.
If you are still unconvinced I will try to get some scope shots of my 15A supply, which uses a P Fet with the drive circuit I have been proposing, to demonstrate the point.

Which is it? Did I take something out of context? Maybe only totem pole arrangements shouldn't include a series gate resistor? ...though Stuart's second suggested circuit has a (slightly oddly shaped?) totem pole and a series resistor?

NOSUM, thank you for your characterization of a totem pole as a "bi-directional current source". This provides a much better and more accurate visual. As in my PS below, just gotta figure out how to have it drive the PMOSFET's gate high by default...

PS Despite all the explanations for why my suggested inverted totem pole arrangement doesn't work (very well), I'm still thinking (I know, "sigh") there must be a way to drive the PMOSFET's gate to turn it off by having as little obstruction to getting current there as possible. An un-driven PNP attached to its gate still seems to be the most efficient way of doing that; then just how to turn it on again without fighting that PNP. Maybe small inductors between the PNP's emitter and the NPN's collector before their junction to the PMOSFET's gate? Or, maybe a derivative of Stuart's first suggested circuit? (Note: It's of little consequence if the Arduino has to have its outputs initialized to "flip" how they behave.) If anyone feels that this is beating a dead horse, you're likely right. Doesn't stop m'noggin from going there... ::slight_smile:

Cheers!
Dirk

stuart0:
[...] you have already been given much simpler circuits that do work?

Stuart, I've re-drawn both of your suggested circuits and added the PMOSFET and load:

(I was very careful while doing this transcription; let me know if I got something wrong.)

While reading the following, keep in mind there may be terminology I'm torturing somewhat; it's the way I think these things through. Any corrections to - or variations on - how things should/can be viewed are decidedly welcome. Along this vein, you may very well have already explained this - just differently. If so, I just didn't grok it your way.

For BJTs, the collector-emitter "path" offers significantly less resistance to current than the base - enough so that when a CE connection and a base share available current, the majority of that current flows through the CE path, and effectively ignores the base (provides insufficient current to turn it on). Otherwise your first circuit would simply provide a short from 12V to ground (Q11 CE -> D12 -> Q13 CE) whenever PWM is high. Is this "CE trumps base" assessment correct? (I'm thinking that maybe it's a bit more complicated than that - like maybe the resistances offered by R13 and D12 play a role in this "current imbalance".)

I suspect something similar is occurring in your second circuit: when Q23 is conducting, there is insufficient current to keep the Q21/Q22's bases saturated, so they shut off/on?

Here is how I see your first circuit working:
PWM is low: current flows through R12 into the base of Q11, turning it on. With Q13 off, there is nothing else to affect the PMOSFET's gate and it "disconnects" the load from 12V.
PWM is high: the Arduino turns on Q13, which makes current available to both the base of Q11, and Q13's CE path. As Q13's CE path offers less resistance than Q11's base, Q11's base is starved sufficiently to turn it off (turning the PMOSFET on).

Your second circuit:
PWM is low: current flows through R22 into the base of both Q21 and Q22, turning them on and off respectively (turning the PMOSFET off).
PWM is high: the Arduino turns on Q23, which makes current availble to the bases of both Q21 and Q22, and Q23's CE path. As Q23's CE path offers less resistance than Q21's and Q22's base, Q21 and Q22 turn off and on respectively (turning the PMOSFET on).

Am I getting close?

If I am getting close, how large could R12 and R22 be before their respective circuits stop functioning properly - at, say, 11-30V?

Cheers!
Dirk

NOSUM:
I disagree with one of your respondents. You do not I repeat not need a resistor in the gate circuit of the FET. Put the totem pole transistors, which can also be described as a bi-directional current source (the clue is in the description), as close to the FET gate as you can get them and all will be well

Hi NOSUM. Dirk made that comment without reference to any specific circuit. That's why I said (without looking at the circuit for which that comment was made) that he may have taken it out of context. As expected, he did.

Clearly if you already have the resistance in each leg of the "totem pole" then it's much the same thing. I've said as much in a previous reply, that you can have just the one resistor in the "class-B" output stage or you can have a resistor in each leg.

With a voltage driven circuit it is preferable to have some output resistance. Particularly now that Dirk wants to handle transients above 18V with a zerner diode, it is essential!

Please (all) do not make sweeping statements without reference to a specific circuit. Otherwise it may get taken out of context.

dephwyggl:
Here is another of the challenges I'm facing; two - clearly both very experienced - contributors (maybe) at odds

Which is it? Did I take something out of context?

Yes I suspect so. Remember that I still haven't seen the specific circuit in which that comment was made with respect to.

While the output resistance is essential if you need to operate with transient over voltages that require a gate zener, it is optional otherwise.

The series gate resistor limits the rate at which the gate charges/discharges. It slows down the mosfet switching speed, and the larger its value the slower it will switch. So clearly having too larger value is undesirable.

Small resistor values, typically in the range of about 10 to 100 ohms (though it really depends very much on the size of the mosfet) are often desirable however. Their inclusion can help mitigate the some of the undesirable effects of stray inductance if your circuit layout is less than ideal.

dephwyggl:
Stuart, I've re-drawn both of your suggested circuits and added the PMOSFET and load:

I was very careful while doing this transcription; let me know if I got something wrong.

Nothing wrong there with the basic circuit. Just remember to add the gate zener and some power supply bypass capacitors as close as possible to the switching device.

Also, you may need to check how much inductive energy there is when you come to switching (off) the actual halogen globes (including wiring inductance between your circuit and the lamps). You may eventually need some form of snubber or a catch diode there if the voltage overshoot is too much.

dephwyggl:
For BJTs, the collector-emitter "path" offers significantly less resistance to current than the base - enough so that when a CE connection and a base share available current, the majority of that current flows through the CE path, and effectively ignores the base (provides insufficient current to turn it on). Otherwise your first circuit would simply provide a short from 12V to ground (Q11 CE -> D12 -> Q13 CE) whenever PWM is high. Is this "CE trumps base" assessment correct?

It's actually a lot simpler than that. Consider the 1st circuit with the diode. Note that for any current to flow through the diode (D12) that it must be forward biased, but any forward bias on the diode reverse biases the transistor (Q11). Look closely at the circuit, the BE junction of Q11 and the diode are in "anti-parallel" configuration (in parallel but pointing opposite directions).

It's very much the same situation in the second circuit. The BE junctions of Q21 ans Q22 are also anti-parallel, so when Q22 is conducting then Q21 MUST be off and vice versa.

You start out wonderfully with:

stuart0:
It's actually a lot simpler than that. Consider the 1st circuit with the diode.

Woo hoo! Looking forward to another explain-y thing which will help. ...er, and then:

stuart0:
Note that for any current to flow through the diode (D12) that it must be forward biased, but any forward bias on the diode reverse biases the transistor (Q11).

Uh oh.

stuart0:
Look closely at the circuit,

(Exactly how cross-eyed do you want me to get?)

stuart0:
the BE junction of Q11 and the diode are in "anti-parallel" configuration (in parallel but pointing opposite directions).

"anti-parallel"? "pointing [in] opposite directions"? Huh? Not from what I can see. You have now completely messed up everything I thought was happening there; I liked my explanation better. :stuck_out_tongue: You did say "It's actually a lot simpler than that" - which seems to imply that perhaps my explanation (though maybe using unconventional terminology) was reasonably accurate? ...at least in consequences?

stuart0:
It's very much the same situation in the second circuit. The BE junctions of Q21 ans Q22 are also anti-parallel, so when Q22 is conducting then Q21 MUST be off and vice versa.

Pray tell; what is this "anti-parallel" of which you speak, my good sir? :wink:

Alright. On to some of your other responses.

First, thank you for clarifying the "resistor in series with a MOSFET gate". As for a specific circuit to which NOSUM's comments applied, it was definitely the totem pole circuits I was proposing. Your comment about not combining a resistor before either totem pole element and a resistor before the gate makes sense. (I'm looking forward to NOSUM corroborating this.)

stuart0:
Nothing wrong there with the basic circuit. Just remember to add the gate zener and some power supply bypass capacitors as close as possible to the switching device.

Glad I got that right, and yep; already being considered.

stuart0:
Also, you may need to check how much inductive energy there is when you come to switching (off) the actual halogen globes (including wiring inductance between your circuit and the lamps). You may eventually need some form of snubber or a catch diode there if the voltage overshoot is too much.

I've thought about this, and will be exploring this in more detail when I get that far. (As is likely apparent, this may be a while yet. ::slight_smile: ) Quick question: could such a snubber or catch diode occur close to this circuit vs close to the actual load?

Thank you for your patience and continued participation, Stuart.

PS For those who may have lost sight of the original goal of this project, this topic deals with just the "driving the PMOSFETs part" of my goal to replace the turn signal flasher unit in my 2014 Scion FR-S with a fully programmable one. I know: "WTF?" Well, that's only the beginning. Turn signals do not need 10A-capable switching circuits, but the ability to programmatically control various lights for cars leading parades or at car shows does. 8) Plus, this wouldn't be fun unless it was at least perceived to be - at best - unnecessary. :slight_smile:

Cheers!
Dirk

Oh, and you didn't answer my question:

dephwyggl:
If I am getting close, how large could R12 and R22 be before their respective circuits stop functioning properly - at, say, 11-30V?

Cheers!
Dirk

dephwyggl:
Woo hoo! Looking forward to another explain-y thing which will help. ...er, and then:
Uh oh.
(Exactly how cross-eyed do you want me to get?)
"anti-parallel"? "pointing [in] opposite directions"? Huh? Not from what I can see.

See if these annotations help.