Help debugging a PWM control - Page 1
Forum section: electronics / projects

author: awakephd
author_rank: Regular Contributor
timestamp: July 10, 2024, 07:45:28 pm
content: I hope that this is the right place to post this ... I have put together a PWM motor control circuit, as shown in the attached schematic. Let me hasten to say, I don't know if this is utter garbage, or somewhat on the right track ... but currently (pun intended) the N-FET is getting quite hot, just driving a motor at a max of 12V and 350mA.Supposedly the N-FET is capable of 250V and 50 amps, so it shouldn't exactly be overloaded. It has a max of 38W of thermal dissipation, with .06Ω across D-S at Vg = 10V. Gate threshold is a minimum of 3V; max gate voltage is +/- 30V.As shown, I am using an optically isolated gate driver ... probably not a very good one ... so my first thought is that it was too slow in rise and/or fall times, leading to extended periods in the higher-resistance range. But I've attached scope shots of the PWM pulse coming in on the gate of the N-FET. As shown, the rise and fall times are in the vicinity of 40ns. Since the PWM frequency is only around 500Hz, I would have thought this was plenty fast to avoid overheating ... ?However, two other details that show up in the scope screen shots. One is that the drive voltage on the gate is nominally 14V. The second is that there is quite a bit of ringing on any given pulse - sometimes more, sometimes less, but looks like typically it is ringing as much as half-a-volt negative and as much as half-a-volt over the nominal 14V drive - maybe more, as I am not completely sure how to interpret what I am seeing on the scope.One other bit of information: even if I hold the PWM signal high (on), continuously enabling the N-FET, I am getting a good bit more heat than I would expect from 350mA.So, questions: 1) Would driving the gate at a voltagegreaterthan the voltage across D-S cause problems? 2) Could the ringing (especially the negative) cause the overheating? (Even though, as best I can tell, the ringing does not rise to the minimum gate threshold voltage? 3) Am I wrong in thinking the rise/fall time on the gate drive is fine? 4) Could the N-FET be defective? I will admit to sourcing it from Ali-Express, so I am wondering if I got "bitten" by a forged part, or something like that.Perhaps I should add 5) Is my entire circuit junk, and needs to be redesigned?Any help that anyone can offer will be most appreciated!!

author: moffy
author_rank: Super Contributor
timestamp: July 10, 2024, 07:53:01 pm
content: Quote from: awakephd on July 10, 2024, 07:45:28 pmNo attached schematic.

author: awakephd
author_rank: Regular Contributor
timestamp: July 10, 2024, 09:15:37 pm
content: Argh! I hate when I forget to attach the attachment! I have edited the OP and added the attachments. The schematic is in the motor drive.pdf file; the screen shots are PWM_1.png and PWM_2.png (one showing a rising edge and one showing a falling edge.)

author: moffy
author_rank: Super Contributor
timestamp: July 10, 2024, 09:37:30 pm
content: The FDPF51N25 carrying only 0.35A in a TO-220 package and fully on is only dissipating 0.02W so it shouldn't be getting warm. So possibilities:1. It is carrying more current than expected or is not fully on. How are you measuring current? What does the D-S waveform look like?2. You have a fake device.3. You have a defective device.14V on the gate is no problem it is rated for +/- 30V.

author: Benta
author_rank: Super Contributor
timestamp: July 10, 2024, 09:41:06 pm
content: Am I reading your schematic correctly? You're PWM driving a 12 V motor at 180 V?

author: Mahagam
author_rank: Regular Contributor
timestamp: July 10, 2024, 09:44:21 pm
content: Actually you have no ringing. Try to catch picture with the higher samplerate. Just increase the memory depth.

author: awakephd
author_rank: Regular Contributor
timestamp: July 10, 2024, 11:28:54 pm
content: Quote from: moffy on July 10, 2024, 09:37:30 pmThanks, Moffy. I am measuring current by way of the bench power supply, which is feeding only the "high voltage" part of the circuit (i.e., what is going through the N-FET and motor). I have it set to a maximum of 350mA, but at lower duty cycles it is showing more like 275-300mA.I am more and more inclined to think the N-FET I was using is a fake part. One thing that I wondered about when I got the part is that the tab is enclosed in plastic (is that a TO-220F? or ??) - that made me nervous about its ability to dissipate heat, though as you say it shouldn't have been getting hot in the first place. And perhaps more conclusively ... it has now failed completely!I swapped it out for an FDP33N25, which is rated 250V / 33A. So far, it seems to be performing better; unlike the previous part, it runs completely cool when the PWM is 100% (i.e., no actual pulse, just continuous on). It still seems to get a bit hot when the PWM is at a low duty cycle (10-15%), but not when the PWM is at a higher duty cycle (>20%). Odd ...Quote from: Benta on July 10, 2024, 09:41:06 pmNo, not at this point, though that sounds like it could be exciting!Ultimately I would like to control higher voltage (90 - 180V) DC PM motors with this circuit - thus the rating of the N-FET for 250V / 50 amps (or now, 33 amps) and the indication of a high-voltage DC power supply. But since I am not entirely sure that I know what I'm doing ... I figured it would be a heck of a lot safer to hook up the bench power supply set to 12V, 350mA, rather than the rectified-and-filtered mains - which, yes, is also not 180V, but closer to 160. Did I mention that I am not entirely sure that I know what I'm doing??Quote from: Mahagam on July 10, 2024, 09:44:21 pmMahagam, can you say more about not having ringing? Are you saying that this is an artifact of the DSO? FWIW, when I swapped out the N-FET a little while ago, I also experimented with a slightly different configuration and some different values for the resistors at the gate of the N_FET. The original circuit had the 10Ω resistor before the 100KΩ resistor to ground; I changed it so that it now comes after (see R6 and R7 in the attached, updated schematic). In terms of changing values for the resistors, I first tried going with a 100Ω resistor to the gate, and a 1KΩ resistor to ground. This seemed to eliminate the ringing (or what I thought I was seeing as ringing), at the cost of drastically increasing the rise and fall times, to nearly 1υS. I then changed back to a 10Ω resistor to the gate, keeping the 1KΩ resistor to ground; now the rise/fall time is in the vicinity of 100ns; no apparent ringing on the rising edge, but what looks like ringing at the bottom of the falling edge.Please, anyone, do not hesitate to tell me what I am doing wrong. As you can no doubt tell from the above, though I have dabbled in electronics for many years, my only training is trial and error ... and I'm really, really good at the second part.

author: awakephd
author_rank: Regular Contributor
timestamp: July 10, 2024, 11:35:02 pm
content: Well, a little more thought and I realized that, of course the FDPF51N25 was completely enclosed in plastic (TO-220F case) ... that's because it was (or was supposed to be) an FDPF, rather than an FDP.

author: moffy
author_rank: Super Contributor
timestamp: July 11, 2024, 12:33:06 am
content: Quote from: awakephd on July 10, 2024, 11:28:54 pmHave a look at the drive waveform and the D-S waveform, it sounds like it is not turning fully on and/or some interaction with the PSU current limit, you should set the PSU so that the overcurrent doesn't engage except in a fault condition.For higher voltages the FET drain will need some high speed clamping to prevent overvoltage and failure. A good starting point is by placing a high speed capacitor across the supply near the FET, polypropylene is a good choice, and a fast reverse diode from drain to supply/fast capacitor to catch any spikes. A snubber across the FET can also be helpful.

author: Circlotron
author_rank: Super Contributor
timestamp: July 11, 2024, 02:40:36 am
content: That ACS712 current sensor in the MOSFET source lead is ringing alarm bells. Any extra inductance in the source lead can play havoc with the gate-source voltage. MUCH better to put the sensor in the drain lead and have the source take as short and direct path to ground as possible.Also, the fact that there is ringing in the gate drivebeforeeach transition is a bit weird. After the transition, sure, but before when everything is quiet...

author: Mahagam
author_rank: Regular Contributor
timestamp: July 11, 2024, 07:18:55 am
content: Quote from: awakephd on July 10, 2024, 11:28:54 pmYou saw artifacts of the sinc interpolation.Please, take the image with sample rate 1Gsps or 2Gsps. Or try to switch from sinc(x)/x interpolation to the x.

author: inse
author_rank: Super Contributor
timestamp: July 11, 2024, 09:29:28 am
content: As in your first screenshot at 20MS/s you have a sample every 50ns, so only 4 samples per division at your zoom level.The interpolation the scope does, gives you funny results like the voltage already trembling in expectation of the pulse.Turn off the interpolation and be surprised

author: Mahagam
author_rank: Regular Contributor
timestamp: July 11, 2024, 09:39:10 am
content: Or, instead of turning off interpolation, just increase sample rate to the max value.

author: inse
author_rank: Super Contributor
timestamp: July 11, 2024, 09:44:24 am
content: Sure - I was just proposing to turn off interpolation to see the reality 😳

author: awakephd
author_rank: Regular Contributor
timestamp: July 11, 2024, 01:31:43 pm
content: Quote from: moffy on July 11, 2024, 12:33:06 amIf by drive waveform, you mean the signal at the gate of the MOSFET, that is shown in the attached scope shots in the first post. To show the D-S waveform, would I put the probe on D, or S, or put a probe on each and take the difference? Or ... should I be probing the gate and the drain, and see how the timing compares? I am sorry to be asking what are likely to be dumb questions - in addition to the limits of my understanding of electronics, I am just now learning to use my first DSO (I've only used ancient analog scopes in the past).QuoteCould anyone point me to a sample schematic of something like this? I *think* I understand where to put the capacitors, but I don't have any idea what value they should be. For the fast reverse diode, are you talking about something different than D2?Quote from: Circlotron on July 11, 2024, 02:40:36 amYes, I gave myself a proper dope-slap a couple of days ago when I realized what I had done. I am not sure what I was thinking! FWIW, the ACS712 uses hall-effect sensing on a straight-through conductor between pins 1 & 2, so maybe, sorta, it kinda is like the FET is connected directly to PGND ... ? Okay, probably not. I have already been pondering how to bodge the circuit board to move the AC712 to where it should be, between the drain and the motor. My poor one-off home-brew PCB already has quite a few bodges on it, but thus far I have gotten lucky; the traces have been placed such that I've been able to make revisions by cutting a trace here and/or soldering an 0603 component across two traces there or so on - no actual bodge wires required. One option I have considered is to remove the AC712 from the circuit and short across, then test the FET circuit; that might be the first step.

author: awakephd
author_rank: Regular Contributor
timestamp: July 11, 2024, 01:37:00 pm
content: Quote from: Mahagam on July 11, 2024, 07:18:55 amQuote from: inse on July 11, 2024, 09:29:28 amQuote from: Mahagam on July 11, 2024, 09:39:10 amClearly this is a place where I have a lot more to learn about using a DSO! I will try both, though I'll have to look for the interpolation setting - still figuring out the many and incredible capabilities of this SDS804X. Question: what are you seeing in the scope trace that helps you know that this is an interpolation artifact? Or to ask it another way, what should I be looking for so that I don't get fooled into thinking I'm seeing signal where I'm actually seeing interpolation?

author: awakephd
author_rank: Regular Contributor
timestamp: July 11, 2024, 01:38:45 pm
content: Thanks to all of you for helping me learn! Again, please do not hesitate to tell me when / if I am doing it all wrong - that will not come as any surprise to me.Of course, I'm even more grateful when / if you tell me how to do it right instead!

author: Mahagam
author_rank: Regular Contributor
timestamp: July 11, 2024, 01:54:11 pm
content: Quote from: awakephd on July 11, 2024, 01:37:00 pm1. Ringing before signal rise/fall.2. 20MSa/s

author: Wolfram
author_rank: Frequent Contributor
timestamp: July 11, 2024, 02:11:44 pm
content: Your "flyback" diode is in the wrong place. The FET will avalanche the energy stored in the motor inductance on every switching cycle. This diode needs to be across the motor, ideally forming a tight loop together with the MOSFET and the local decoupling caps. I notice those are missing in your schematic as well, you need some caps between the motor supply voltage and ground.

author: moffy
author_rank: Super Contributor
timestamp: July 11, 2024, 02:37:12 pm
content: Quote from: awakephd on July 11, 2024, 01:31:43 pm1. Look at the Gate to Source waveform for the low duty cycle where you have the strange heating.2. Look at the Drain to Source waveform under the same conditions to see if it is turning fully on.3. How you do that is up to you and your setup.I have attached part of a PWM circuit I designed and use for my CNC3020 milling motor. The capacitors C1(electrolytic) and C12(polypropylene) are very close physically to the MOSFET. The diode D1 is a fast diode to clamp inductive spikes into C1/C12 and R6/C2 provide a snubber to help dampen any ringing.

author: awakephd
author_rank: Regular Contributor
timestamp: July 11, 2024, 03:47:42 pm
content: Quote from: moffy on July 11, 2024, 02:37:12 pmThank you so much! Are R12/16/17/18/19 for current sensing (through R10/R11, attached to something outside the right side of the schematic )? If so, does it pose any problem placing this between source and ground? Kind of have to put it there, I'm assuming, to get a ground-referenced voltage? I'm now realizing that this must be why I put the ACS712 in the same location (between source and ground) in my circuit.If you all get tired of answering my questions, please let me know - I don't want to be an annoyance, but I surely do appreciate what I am learning!

author: moffy
author_rank: Super Contributor
timestamp: July 11, 2024, 03:57:44 pm
content: Quote from: awakephd on July 11, 2024, 03:47:42 pm"Are R12/16/17/18/19 for current sensing?" Yes, a cheap and easy way to get a lowish value current sense resistor, they feedback to a UC3843, current mode PWM which is used in a slightly different way.

author: awakephd
author_rank: Regular Contributor
timestamp: July 19, 2024, 09:35:54 pm
content: Sorry for the long delay in following up - today has been the first chance I've had to modify the circuit. As you will see in the attached schematic, I have, for the moment, taken the ACS712 out of the circuit, moved the flyback diode, added the snubber circuit, added bypass capacitors for the motor - essentially copying the circuit that Moffy provided, except with somewhat different capacitor values due to what I had on hand.On the one hand, the outcome is a vast improvement. The MOSFET is no longer heating up in the same slow-speed range as before (10% or so). I've attached scope shots of the gate (yellow), drain (purple), and source (blue). As you will see, the start of the PWM pulse is fairly clean, but there is a bit of "ringing" after it goes high (ringing in all three signals). The end of the PWM pulse is ... quite exciting, with a LOT of ringing (or at least, that's what I assume it is) going on on all three signals. Given that the MOSFET is happy - at least driving the motor at 12v - I don't know if this is a problem, or related to not having quite the right capacitor values, or yet another artifact of the DSO that I don't yet know how to recognize.Speaking of artifacts, before I changed the circuit (bodge wires everywhere!) I tested again to show myself what others were observing as far as the interpolation artifacts that seemed to show ringing *before* the signal changed. Yep, sure enough ... switching from sinc to x flattened out those artifacts, as did making sure I had more samples. The learning continues ...

author: awakephd
author_rank: Regular Contributor
timestamp: July 29, 2024, 04:14:01 pm
content: So, a bit of follow-up. Since the circuit was working with a small DC motor (first at 12V, shown in the previous set of scope pictures, then tried it at up to 36 volts with no apparent problems), I decided to try it with the 160 volt (mains rectified and filtered) on a treadmill motor. It worked ... for a minute or two. Then the MOSFET popped.Looking back at the last set of scope shots, I am thinking that, even though it seemed to work without generating excess heat when switching 12V, there is an awfully big voltage spike on the drain - around 25V. I don't know what the voltage spike was when switching 160V, but if the proportion remains the same, perhaps > 330V ... which would exceed the 250V maximum Drain-Source voltage of the MOSFET.Obviously, I need to do a better job of filtering out that spike. I have been reading about RC snubber circuit designs, and I think I have a plan for how to optimize the capacitor and resistor values. (This article was particularly helpful for my limited level of knowledge:https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/196/SEM_5F00_900.pdf&ved=2ahUKEwjw5aXJz8yHAxVgP2IAHWhQLtAQFnoECBcQAQ&usg=AOvVaw2TaDv2dP89Z9Nr8yn68AZt).Meanwhile, I am wondering whether the flyback diode is doing what it should. I was thinking it would clamp any over-voltage spikes ... but perhaps these are happening too fast? The spikes look to be only 10-20ns wide. (No, I didn't measure them - I am planning to go back and do a better job of measuring everything when I am able to sit down with the circuit again.) Perhaps that is too fast, even for an "ultra-fast recovery" diode? To be honest, I'm not sure how fast the diode (actually, diode pair) currently in the circuit really is; it was one I had on hand, that seemed to have sufficient power ratings for the job ... but I am away from the circuit, and don't have the exact part number, so can't check it until I can sit back down with the circuit.I guess my question is this: do the voltage spikes that I'm seeing when the MOSFET turns off indicate any deficiency in the flyback diode? Or is it mostly indicative of a need to fine-tune the snubber circuit? I have some ultra-fast recovery diodes ordered from DigiKey, and they should be on hand by the time I get back from vacation and get a chance to work on the circuit again. But I don't know whether this is actually a point of concern, or a red herring.Thanks again, all, for your patience and help - I feel like I have learned a LOT just through wrestling with this one circuit. Someday, maybe I will get to where I am sorta, half-way, almost competent ...

author: moffy
author_rank: Super Contributor
timestamp: July 29, 2024, 10:01:08 pm
content: Congratulations on your success to date, very impressive.Spikes 10-20ns wide are probably too short for the diode to catch and more dependent on the snubber to keep them at controlled voltage levels. As you have found out MOSFETs die to overvoltage relatively quickly, if possible, I generally like to double the voltage rating of the MOSFET, so in your case for a 160V supply I would look for a 320V minimum MOSFET just for safety reasons. It might seem excessive derating but reliability is worth a little extra.A good snubber design and good layout practices though are the real solution as you already have stated.

author: awakephd
author_rank: Regular Contributor
timestamp: July 30, 2024, 06:41:26 pm
content: I was starting to think that I need to go to a higher-voltage MOSFET. I've been looking on Digikey particularly at the R6530 family of MOSFETs from Rohm - 650V, 30A. There are small variations that I don't quite know how to choose between. For example, the R6530KNZ4C13 is described as a "high speed switch" version, while the R6530ENZ4C13 is described as a "low noise power" version. The specs seem nearly identical to me, with slight variations in total gate charge, rise or fall time, etc. I don't know how to judge whether or which would be better for my needs.I've also wondered whether an IGBT would have any advantages for this purpose. My *extremely limited* understanding, which may well be incorrect, is that "in general" MOSFETs can handle higher switching speeds, while IGBTs can handle higher currents - but of course, when one starts looking at the hundreds or thousands of different options, there are plenty of what seem to be high-speed IGBTs and high-current MOSFETs. One thing that is distinctly different, from what I can tell, is the voltage drop across the IGBT C-E - a couple of volts - vs across the MOSFET D-S - only millivolts. Not sure if that makes any practical difference in my application.I'm learning so much ... and yet the more I learn, the more I recognize that there is so much more to learn!

author: moffy
author_rank: Super Contributor
timestamp: July 30, 2024, 11:47:38 pm
content: I found a nice article comparing MOSFETs to IGBTs:https://weishielectronics.com/igbt-vs-mosfet/It seems fairly balanced, the IGBTs are meant for high power applications, voltage/current, which are appropriate for their slower switching compared to MOSFETs. In your application MOSFETs are probably the best choice as they will have lower conduction losses than an IGBT.Regarding the two versions of the MOSFET, the R6530KNZ4C13, with the lower gate charge, will give faster switching, but also excite higher voltage spikes. The R6530ENZ4C13 with the higher gate charge will give slower edges and excite less aggressive voltage spikes but will also dissipate a little more in switching losses. It's all a compromise and just depends where your priorities lie for this design.P.S. You can slow down the switching of a MOSFET by reducing the gate drive current, and the simplest way to do that is to increase the value of the series gate drive resistor.

author: moffy
author_rank: Super Contributor
timestamp: July 31, 2024, 04:56:41 am
content: Just as an illustration of how the switching speed of a MOSFET can effect the spikes, I ran two simple LTSpice sims which are identical except the gate resistor in the 'fast' one is 5R and it is 33R in the 'slow' one. The ringing peak in the 'fast' one reaches close to 550V while the 'slow' peak is just 330V.

author: awakephd
author_rank: Regular Contributor
timestamp: August 06, 2024, 07:01:13 pm
content: Moffy, very helpful indeed. Many thanks! I have continued to work on this off and on, in the bits and moments of time available. I am close to finalizing a circuit board design which, hopefully, will bring together all of the things I have learned thus far. Chances are good that it will be a "first draft" needing further revision, but I am excited to be getting this close!