mosfet and PWM - Page 1
Forum section: electronics / general

author: Oy1r
author_rank: Contributor
timestamp: July 19, 2021, 09:14:03 am
content: I heard somewhere that driving logic level mosfets with PWM can become problematic because of frequency, why would this be and what is the max freq ?ThanksOY1R

author: Siwastaja
author_rank: Super Contributor
timestamp: July 19, 2021, 02:16:52 pm
content: Google MOSFET gate capacitance.It's just that driving a large MOSFET directly from the microcontroller pin is slow, so the MOSFET spends some time in the partially conducting state, acting like a resistor, dissipating a lot of heat if there is load current flowing through it.Why it is slow? Because the microcontroller IO pin is like a 30 ohm (approximately) resistor. Charging the MOSFETs gate capacitance through it takes time.Gate driver IC can do that faster by having less resistance.Whether this is a problem or not, depends. Sometimes it's even desirable. Total efficiency depends on how often you switch. For example, if turning MOSFET on or off takes 10 µs and your PWM period is 1 ms, you are spending 2% of the time in that highly wasteful state (work out why by yourself).In any case, driving any but the smallest MOSFETs, I recommend adding an explicit series resistor like 33 to 47 ohms. It makes iteven slower, but protects the IO pin from excessive current.Smallish power MOSFETs like something rated at 30V 5A are usually fine with no extra considerations.

author: IDEngineer
author_rank: Super Contributor
timestamp: July 19, 2021, 03:54:06 pm
content: To provide a bit more info....When you're driving the gate of a MOSFET, you're driving a capacitor. Literally charging and discharging a capacitor. Like a discrete capacitor, the initial currents can be significant - sometimesampsof current can peak even for "smallish" MOSFET's. Meanwhile, most microcontroller I/O pins are rated for single digit milliamps and even the "strong" ones usually have an absolute max rating of 25-30mA. Repeatedly subjecting those pins to overcurrents of 10-100X their absolute max ratings can blow the driver stage, either instantly or through slow degradation.That's the reason Siwastaja recommended a resistor in series with the gate: To limit this "inrush" current during capacitive charge and discharge. But the downside of doing that is, as he said, that you slow down the transition of the MOSFET from "full-on" to "full-off" and vice versa. This allows the MOSFET to spend too much time in its "linear" range where it's dissipating too much heat, likely damaging or destroying the MOSFET instead of the I/O pin.And choosing the value of the gate resistor isn't an easy formula, either. For example, the MOSFET itself has some gate resistance (check the spec sheet) which is typically in the single or double digit ohms. Personally I always use a high end current probe on my breadboards to understand exactly what is happening at the gate, and tune the driver stage and gate resistor using the scope display (with a bit of derating to allow for production variation).I only directly drive MOSFET gates from I/O pins when I'm dealing with very small devices and currents. Beyond those I generally go to a dedicated gate driver chip; it's basically impossible to reproduce their functionality for anything close to their cost (well under 50 cents/1000's) and then you get near-symmetrical charge and discharge currents of several amps which keeps the MOSFET out of the dangerous linear region. MOSFET switching times of under 50nS are easy to achieve with a cheap gate driver and you'll sleep well at night knowing that you're running neither the I/O pins nor the MOSFET's out of spec.Hope this helps!

author: MathWizard
author_rank: Super Contributor
timestamp: July 19, 2021, 09:32:37 pm
content: Interestingly, many 750W computer PSU's use a resistor divider of 30R and 10k, on the gate's of the mosfets in the PFC section, and the main inductor. They operate around 50-100kHz, from 12V or so tho, from a controller IC.

author: Kerlin
author_rank: Regular Contributor
timestamp: July 19, 2021, 10:11:52 pm
content: Yes you are correct the resistor in the gate of FETs in switching supplies is there to speed up the switching time.I was thinking about making this comment but decided, hey its a forum just leave them with it, they abound with misinformation.

author: DavidAlfa
author_rank: Super Contributor
timestamp: July 19, 2021, 11:42:59 pm
content: It'snot to driveit faster but to prevent oscillations and resonances (ringing) from driving the gate too hard.

author: Oy1r
author_rank: Contributor
timestamp: July 19, 2021, 11:52:00 pm
content: I thought/read that mosfet's are voltage driven!my plan is to pwm controll mosfet's in parallel to drive my dinghy trolling motor, it's rated at 400w max.

author: IDEngineer
author_rank: Super Contributor
timestamp: July 20, 2021, 02:49:53 am
content: Quote from: Oy1r on July 19, 2021, 11:52:00 pmStrictly speaking they are, but to get that electric field (to either enhance or deplete the channel) you must charge or discharge the gate capacitance. Changing the charge on something means current flow. Once the charge is there, the current flow drops to zero (theoretically... of course there's always some leakage in real world devices). But tochangeit, current must flow. And since you generally want to keep MOSFET's out of their linear region, you want to change the electric field (read: change the charge) as fast as possible, which means higher current.

author: Oy1r
author_rank: Contributor
timestamp: July 20, 2021, 09:33:14 am
content: Alright, i was thinking that too. Current flow while charging the gate. i just thought it wasBut it makes sense, faster switching more current flow to charge the gate.So how should i go about driving 4 or 6 power MOSFET's in parallel from an arduino ?Reg

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 20, 2021, 04:46:52 pm
content: As explained above, it's all about a compromise. Of course the higher the PWM frequency, and the more significant, on average, switching time (due to gate capacitance mainly) will be. For low freq PWM and/or low gate capacitance MOSFETs, you may directly drive them with a GPIO. As explained above, sometimes recommended to use a series resistor to minimize ringing (but it will also increase switching time.)OTOH, when switching time matters, you'll need a gate driver.To answer your last question, can you give us the reference of the power MOSFETs you are thinking of using, and the PWM frequency?

author: Siwastaja
author_rank: Super Contributor
timestamp: July 20, 2021, 05:45:20 pm
content: Parallel MOSFETs in switching applications act pretty much like one bigger MOSFET (except that current sharing during transition can be briefly poor, but that's usually a small percentage of total time), but of course if you have 4 to 6 that means they would need to be rather small already so that the IO pin could drive them directly. This means you likely need a gate driver.Why are you paralleling such number of MOSFETs? What are you actually building?

author: Siwastaja
author_rank: Super Contributor
timestamp: July 20, 2021, 05:51:07 pm
content: Quote from: SiliconWizard on July 20, 2021, 04:46:52 pmNot necessarily, though; there are cases where the power MOSFET is like some modern 30V, 10A device and these can have surprisingly low Qg(tot) and already be fully on at Vgs=3.5V. Even with a "proper" gate driver IC, you'd often drive them from a 6V supply and 47ohm explicit series resistor, and the datasheet characterization may be provided with Vgs=4.5 and Rg=47ohms. In such case, a 5V AVR IO pin with 22R explicit Rg provides basically the same switching time so this isn't a compromise. This way you can build quite powerful converters, say a 20V 5A boost, without a gate driver and without compromising efficiency, but any larger than that and gate driver starts becoming mandatory pretty soon.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 20, 2021, 06:12:36 pm
content: Quote from: Siwastaja on July 20, 2021, 05:51:07 pmSo that's a case for which switching time won't matter. You're saying the same thing as I did.Switching time itself again "matters" only if it's significant relative to the PWM period. It's only a relative issue.(To an extent, of course: if switching time is unreasonably long, then the transistor may blow up due to overheating. In any case you'll have to estimate power dissipation while switching, and see how much it affects efficiency, and by how much the die temperature will rise.)

author: Oy1r
author_rank: Contributor
timestamp: July 20, 2021, 07:49:05 pm
content: I thought i would make my 400w 12v trolling motor PWM controlled. I had one from china died, and i thought i would give it a try witha few n channel mosfets, preferably logic levlel and an arduino.Reg

author: Circlotron
author_rank: Super Contributor
timestamp: July 21, 2021, 06:08:52 am
content: I drove a similar size 24VDC motor with a mosfet driven from a micro I/O with a 100 ohm in series with the gate. Switching frequency was only ~4kHz so very little demands on fast switching transition speed. 4kHz was plenty fast enough for that motor. Several of them have been in service for almost 10 years so it was reliable too.

author: DavidAlfa
author_rank: Super Contributor
timestamp: July 21, 2021, 07:26:52 am
content: It all depends on the gate capacitance and the driver strength. It's basically a RC filter.If the driver is powerful, it will be able to supply the high current spikes needed to quickly charge and discharge the gate.If it's weak and the frequency high enough, the gate can float, which anything but good.Read:https://www.eevblog.com/forum/microcontrollers/fan-controller-with-pwm-using-stm32-chip/msg3566902/#msg3566902

author: Oy1r
author_rank: Contributor
timestamp: July 21, 2021, 08:02:04 am
content: This sounds good. i read that the arduino PWM frequency by default is approx 500hz and 1khz and can be set as high as 4MHz.Anyone know what frequencies freshwater trout are scared or attracted by ?Reg

author: Siwastaja
author_rank: Super Contributor
timestamp: July 21, 2021, 09:28:45 am
content: Quote from: SiliconWizard on July 20, 2021, 06:12:36 pmNo, it's a case where itdoesmatter but the IO pin can drive it at the same quick rate as a dedicated driver would, given small enough MOSFET. I'm saying this specifically because sometimes people think as a "rule of thumb" that IO pins are slow and dedicated gate drivers fast, but this only applies to driving large capacitive loads, obviously.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 21, 2021, 09:35:23 am
content: Oh, you are building a brushed DC motor controller. It requires these basic parts:* Two switches, one of which is a MOSFET and another can be a diode in this case,* DC bus capacitance* Somewhat well though out layout (i.e., the two previous bullet points forming a minimally small loop)* Gate driver (possibly optional for small controller)* Current sense circuit, typically consisting of a low-side shunt resistor and an amplifier IC400W 12V motor controller is already something you won't do without a gate driver. Roughly, if 400W is nominal motor power at 12V, nominal current then is 33A. If you want any more than nominal torque, i.e., for example for startup, design for, say, 60A. Choose MOSFET based on thermal calculations, but to get you in the ballpark, this is a part nominally rated at some Id=100-150A, so I can already see why you are going to parallel multiple parts, it's a good idea.If you don't want to blow up this one as well, you need a current sense circuit, and you can't afford losing some 1V (which would be tens of watts!) on low-side sense resistor, so you need a sense amplifier as well, so you are in the territory of adding external parts so why not add a gate driver as well.For controlling a motor, anything in range of 2kHz - 30kHz is usually a good choice. Some 10kHz is often quite optimal compromise between ripple current amplitude and efficiency, but the audible whine might be an issue.What I have personally done a few times, is put the sense resistor between the ground and the MOSFET Source. Amplify it with a current shunt amplifier IC, then bring it to the AVR's Analog Comparator pin. This way, you get software interrupt at the very instant the motor current exceeds the comparison level you set, allowing you to terminate the PWM cycle early and wait for the next cycle, giving you a peak current (torque) controller.

author: Circlotron
author_rank: Super Contributor
timestamp: July 21, 2021, 12:00:03 pm
content: Quote from: Siwastaja on July 21, 2021, 09:35:23 amI once saw a prototype circuit where the designer put a current transformer in the source lead of a mosfet. The inductance of the CT primary caused awful switching problems! I'm always wary of putting extra bits in line with the mosfet source. Keep it short and direct! SMD current sense resistors are your friend here.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 21, 2021, 03:20:09 pm
content: Quote from: Circlotron on July 21, 2021, 12:00:03 pmYes, a small footprint SMD current sense resistor is best. It can be physically small, because it can be designed with small resistance, small burden voltage, and hence small power dissipation also minimizing the efficiency penalty, because high accuracy measurement is not required.Youeasilyget say 5-10% accuracy with a tiny 1210 (or not so tiny but still more than acceptable 2512) part with Kelvin sensing layout below it which is more than enough for protective current limiting and torque feedback loop.But an amplifier IC is needed, just no way around it in a 400W 12V converter. Some higher voltage, lower current converter, say 48V and a few amps, could work with the shunt directly wired to the analog comparator (IC or MCU-integrated).In any case, the OP should come forward if some of this goes over their head and ask for clarifications. Designing a DC motor controller is not impossible, but not completely trivial either; we are here to help with any specific question.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 21, 2021, 03:35:21 pm
content: Quote from: Siwastaja on July 21, 2021, 09:28:45 amOK, I think you just got hung up on the "doesn't matter" term I used, even though I thought it was pretty clear what I meant all along if you read all I wrote in this thread.So to be clear, "switching time won't matter" meant that it would be short enough to fit the efficiency and thermal requirements in a given application. It absolutely didn't mean that you should not consider it. Just means that after estimating it, you conclude that it fits your requirements.A corollary point is that there's no need to look for the shortest switching time possible. Just short enough to fit your requirements (again, essentially efficiency and thermal) in a given application.Quote from: Siwastaja on July 21, 2021, 09:28:45 amWhich effectively relates to the points I made in this thread. There is no magic voodoo here. You just need to estimate the switching time using the MOSFET characteristics (gate charge, VGS(th)...) and the approximate output impedance of your driving signal. This is just what it's all about. You'll just have to pick whatever solution (including a separate gate driver or not, and which one) gets you there.People using rules of thumb without understanding what they are doing are obviously very likely to get suboptimal solutions. There are thousands (probably millions) of different MOSFETs out there, and thousands of ICs with very different IO characteristics. And, as I also said, the application! Again, even if you have a largish MOSFET (thus high gate charge), you can sometimes drive it directly from even a modest IO if the switching time you get is no problem in a particular application. If you switch every minute, and you have a pretty long switching time of 100 ms, then who cares. Efficiency wouldn't be harmed significantly, and the MOSFET would have ample time to cool down between each switching event.It's impossible to devise a general rule of thumb about this all.

author: IDEngineer
author_rank: Super Contributor
timestamp: July 21, 2021, 06:02:45 pm
content: Quote from: SiliconWizard on July 21, 2021, 03:35:21 pmI'll venture one: As a general rule you should use T&M equipment on MOSFET gates to confirm what's actually going on, and adjust component choices and values accordingly. {grin}I thought I understood what was happening on the gates of (at least) small scale MOSFET's until I put an actual current probe on the gate together with a voltage probe and watched its voltage and current on a scope. Theory is nice, but you don't really know the results of the interaction between the total gate charge and the part's internal gate resistance and the driver's output impedance and a bunch of other factors until you actually measure it. For me, it was a "What the... OHHH, now I understand what all those MOSFET appnotes were trying to tell me" moment. Maybe I'm just dumber than most people....

author: Siwastaja
author_rank: Super Contributor
timestamp: July 21, 2021, 06:52:37 pm
content: Yes, I agree that measuring what's actually happening during switching, then fine tuning parts, is effective. Probing for gate current may be interesting but even more acutely, look at gate voltage, switch node voltage and switched current; plot on the same timescale. And indeed, the actual gate charge circuit has three resistors in series; driver output R, your explicit Rg, and the MOSFETs parasitic Rg.Very simplistic calculations like Q = I*t or tau = RC, or triangle approximation of power loss, get you in the right ballpark easily, say within 30-50% and you can do that in Excel while choosing the components, a huge plus compared to complex modeling. Or, you can spend half of your life trying to model the thing until cows come home, or just measure, compare the measurement results to the simple model, and adjust component values until satisfied.One important aspects regarding gate charging is the available voltage. If you need, say, 4.5V in order to reliably and fully turn the MOSFET on over the whole temperature range, then driving from 5V gives highly variable results because charging a capacitor is an asymptotic process which takes infinite time to completely finish. The last volt takes a long time, so even minor variations in conditions cause large differences. This is actually often the reason why you need to use a "proper" gate driver IC, even if you ended up using Rg value similar to the logic pin resistance, and even if the part is nominally "logic level".Transition into more powerful ARM microcontrollers also has the side effect that 5V microcontrollers are becoming rare, further necessitating the use of external gate drivers for anything but smallest 20-30V maybe <5A MOSFETs.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 21, 2021, 07:46:21 pm
content: Quote from: IDEngineer on July 21, 2021, 06:02:45 pmAh, you're right. This is also why I carefully used the term "estimate". First step when designing is to estimate your switching time from parts datasheets and expected conditions, but it doesn't replace proper measurements after that.

author: Oy1r
author_rank: Contributor
timestamp: August 06, 2021, 04:55:34 pm
content: This is what i had in mind, it worked with a single mosfet and small fan on the breadboard, i imagine/hope it would work scaled up to the 400w motor. I`m running of a lead acid battery so ~12v, the mosfets are 30v 30a, and i think 3 or 4 in parallel ought be enough.Any input will be fine, am i missing something obvious or is it good to go ?I can set the PWM freqeuncy on the arduino between 490Hz and up towards 60KHz. PWM duty cycle is controlled with the pot.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 06, 2021, 05:42:40 pm
content: To select a proper PWM frequency, you'll need to look at the gate signal on a scope and see what you get. I haven't looked at datasheets to tell you whether you can go up to 60 kHz with this setup without significant losses. But one thing to know as well is that motors themselves have losses when using PWM at a high frequency. I have rarely seen electric motors driven with PWM at higher freq than 20 ou 30 kHz max. YMMV.Note that, unrelated to efficiency: if the PWM freq is within the audio range, you will distinctly hear an annoying "whine". Whether this matters in your application is up to you, but it can also be a criterion for choosing the frequency.

author: IDEngineer
author_rank: Super Contributor
timestamp: August 06, 2021, 06:15:00 pm
content: Quote from: SiliconWizard on August 06, 2021, 05:42:40 pmYeah, that should be revealing. A 5V MCU through a 100R resistor allows up to 50mA. I doubt the MCU pin is rated for 50mA in either direction so it's going to see significant stress. And the MCU pin is charging and discharging four MOSFET gates in parallel. Methinks there will be some serious peak currents in both directions limited only by that 100R and whatever gate resistances the MOSFET's happen to have (likely single digit ohms). Presuming the resulting charge/discharge periods are longish and have slow slew rates, that will put a LOWER limit on the desirable PWM frequency (to minimize losses).And this doesn't even address the question of dissimilar current sharing.At the very least, this application screams for a gate driver IC. They're like $0.50. Spend the money. You'll thank us later.

author: Oy1r
author_rank: Contributor
timestamp: August 06, 2021, 08:00:24 pm
content: the arduino can put out various pwm frequencies on different pins so i can experiment, see what suites best, most torque least audible etc.The spec sheet says abs max per single pin 40mA. I could increase the resistor to 470ohm and have 10mA on the pin.As for IC gate drive it will have to wait at first(10 days to order anything, i live on an island)Can't i just use a transistor or mosfet to drive the gates ?

author: IDEngineer
author_rank: Super Contributor
timestamp: August 06, 2021, 08:25:58 pm
content: Sure! And once you're done making an active source+sink drive circuit, that avoids shoot through, etc. you will find you've spent far more money and time to not quite recreate what that dedicated gate driver IC would have delivered. If you want to do it as a learning exercise I'm totally supportive, but if you're trying to solve a problem and move on the answer is clear.

author: Oy1r
author_rank: Contributor
timestamp: August 06, 2021, 10:34:11 pm
content: where do you get 0.5$ mosfet drivers ?

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 06, 2021, 11:37:42 pm
content: Quote from: Oy1r on August 06, 2021, 10:34:11 pmhttps://www.digikey.com/en/products/filter/pmic-gate-drivers/730A lot of them...Of course if you're looking at chinese parts, you may even be able to find some at under $0.1...

author: Siwastaja
author_rank: Super Contributor
timestamp: August 07, 2021, 06:30:35 am
content: You really need current sense for such large motor. Large motors tend to be high efficiency, meaning stall current is possibly order of magnitude more than nominal nameplate current. Without current sensing, this leads to massive and expensive oversizing of everything, and poor performance and efficiency due to lack of torque limiting.The solution is simple: a shunt resistor between bottom MOSFET source lead and ground, something like 0.001 ohms, calculate for max power dissipation (I^2 * R). Then a current shunt amplifier. Look at "current sense amplifier" category, a small IC costs something like $0.50.For example, if max motor current = 60A, a 0.001 ohm shunt generates U = R*I = 60mV voltage. If you use an amplifier with gain=50, you'll get a 60mV * 50 = 3V signal from 60A motor current. The shunt dissipates (60A)^2 * 0.001ohm = 3.6W, get one rated at 5W.Then you can route this measurement signal to the "Analog Comparator" pin of the microcontroller, and generate a comparison level (say 3.0V equaling the 60A) with a resistor divider, or a potentiometer. Once the motor current exceed this limit, you get a software interrupt, where you can instantly turn the MOSFET off, terminating the PWM cycle early.

author: RES
author_rank: Regular Contributor
timestamp: August 07, 2021, 08:57:43 am
content: Quote from: Oy1r on July 19, 2021, 09:14:03 amNot a problem if you don't and are able go into the MHz. High(er, few MHz) frequency PWM is used in factory dc-dc converter chips, have built-in transistor(s) or MOSFET(s) and gate driver(s) (high speed current sink driver stages)

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 07, 2021, 03:54:41 pm
content: Adding current sense and overcurrent protection is definitely a good idea here.

author: Circlotron
author_rank: Super Contributor
timestamp: August 07, 2021, 10:49:16 pm
content: Quote from: Oy1r on July 19, 2021, 09:14:03 amI think logic level mosfets have a higher gate-source capacitance than normal mosfets so achieving a fast rising and falling edge on the gate drive is that much harder.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: February 11, 2022, 07:19:12 am
content: A gate driver also allows you to use an N-channel MOSFET on the high side rather than a P-channel. N-channel MOSFETs typically have lower Rdson than P-channels.Another way to measure current that doesn’t involve a shunt is to use a toroid and a Hall effect sensor. This is isolated from the current flowing through the MOSFET with an air gap.