PWM a DC Motor Problems - Page 1
Forum section: electronics / beginners

author: mribble
author_rank: Regular Contributor
timestamp: April 06, 2015, 02:02:51 pm
content: I'm driving a 12V Motor (typically runs at 0.8 A and stalls around 2A) an L298N h-bridge. I have a pretty big heat sink on the L298N and when I run everything at constant on the motor gets a little warm. However, if I PWM at at around 200 hz the motor and heat sink get pretty hot (finger can't touch more than for a few seconds).So my questions are:1) Why do things get hotter when running the system as a PWM? And is there something I could do to reduce the heat? I would think higher frequency switching would cause more heat, but it would be good to confirm this.2) I've read about approximating a sine wave by using different length PWM. If you think think this would help I could modify the software to do this, but is there some way to figure out the timing I should use? Is it as simple as attaching a scope to the motor terminals and driving it at high enough frequencies to see what voltage gets generated?Thanks for any suggestions!

author: nuno
author_rank: Frequent Contributor
timestamp: April 06, 2015, 02:40:18 pm
content: A few points.The frequency must be "adapted" to the motor's winding inductance. If the frequency is too low, current in the windings will go up "a lot" and come back to zero or thereabouts on every PWM cycle, and remember that losses are proportional to the current's square (the motor will be running in what's called "discontinuous mode"). This heats up both motor and driver. If you have how to measure the motor's current, you should check that the current ripple is a small percentage of the average, something like 10% or less.When you do PWM, there are additional losses due to the switching events (ON, OFF). The losses are proportional to frequency and switching time (how much time it takes to go from OFF to ON and vice-versa), besides motor current and supply voltage.For a small motor, 200Hz looks like very little; I would start at 3 or 4KHz. You also need to have some capacitance near the supply pins of the L298.

author: bktemp
author_rank: Super Contributor
timestamp: April 06, 2015, 02:52:03 pm
content: The typical L/R time constant for small DC motors is about 1ms. This sets the lower limit to around 500-1000Hz. The upper limits are the losses in the iron core and switching devices.The optimal PWM frequency is 2-5kHz, but it is also most audible. Therefore it is often a tradeoff between switching losses and noise free operation.

author: mribble
author_rank: Regular Contributor
timestamp: April 06, 2015, 03:30:37 pm
content: Thanks guys! It sounds like I just should try different PWM frequencies. I will admit I choose a low frequency because it sounded better and I'm willing to take some extra inefficiencies for less noises. I will do some experimenting to see if I can find a better trade-off.Is there a website that explains the efficiency of PWM at different frequencies in practical terms? I've started googling for this, but so much of it is too theoretical for my current level on this subject. Also if you could point me to a good way to measure efficency that would be good. DMMs don't seem accurate at these frequencies or is there a way to use one? Would something like this work (http://www.amazon.com/GT-Power-Analyzer-Consumption-Performance/dp/B00C1BZSYO/ref=sr_1_5?ie=UTF8&qid=1428334190&sr=8-5&keywords=power+meter)?

author: Ian.M
author_rank: Super Contributor
timestamp: April 06, 2015, 03:49:57 pm
content: PWM the enable pin not the input pins. If both input pins are in the same state with ena ble high that is dynamic braking. If you are actually PWMing both inputs in antiphase thats even worse. Both require the L298 to dissipate all the power that was dumped into the motor's rotational K.E. in the active part of the PWM during the rest of the cycle.If you PWM the enable pin, and just use the input pins to set direction and braking mode, when its low, the motor can coast and you will get much smoother rotation and far less dissipation in the L298.

author: bktemp
author_rank: Super Contributor
timestamp: April 06, 2015, 04:01:58 pm
content: Quote from: Ian.M on April 06, 2015, 03:49:57 pmFor the L298 this may be true, but for a more modern motor driver with mosfets instead of bipolar transistors, applying PWM to the input pins not the enable pin is the right way. Shorting the motor winding for a short time enables the so called synchronous rectification. When you change the duty cycle the avarage voltage the motor sees follows the duty cycle and therefore depending on the current motor speed it either accelerates, brakes (regenerative braking) or keeps its current speed. Using antiphase PWM is no problem, it only increases the ripple current, but as long as it is small enough no problem. This enables true 4 quadrant control.

author: Ian.M
author_rank: Super Contributor
timestamp: April 06, 2015, 04:29:51 pm
content: Yes, the L298 is a bit of a Dodo and being bipolar has high losses.I agree that if you are using a MOSFET H-bridge at a high enough frequency that the self-inductance of the windings provides effective smoothing of the current, PWMing one end of the winding properly will set the average voltage and control the speed far more effectively without excessive losses.

author: nuno
author_rank: Frequent Contributor
timestamp: April 06, 2015, 04:55:26 pm
content: mribble, doesn't make much sense to talk of "efficiency of PWM at different frequencies" alone. It's a combination of PWM frequency, motor and driver that leads to a certain efficiency. The minimum PWM frequency needed is set by motor characteristics; what you don't want is to have the current go up and down (ripple) too much when the motor is stalled (or at the maximum load it will ever see in its application). If you have a scope you should measure the current in the motor and try various PWM frequencies and duty cycles (with stalled motor), you'll see the current ripple and understand better. You can also take a look at some DC-DC buck converters theory (like in the wikipedia), keeping in mind that the inductor would be the (stalled) motor.Something that is not usually clear is why a big current ripple is bad for efficiency. There are other factors (as mechanical), but one that is not so obvious is that a constant average current of X over a certain period is not the same as an non-constant average current of the same X on the same period, in respect to power dissipation.A simple example: In one case you have 2A for 0.5s and 0A for 0.5s, in another case you have 1A for the full second, both over a 1 Ohm resistor. Question: what's the average current and how much power is dissipated in each of the 2 cases?

author: mribble
author_rank: Regular Contributor
timestamp: April 06, 2015, 07:48:45 pm
content: Ian, I am PWM the enable pins like you recommended for the L298. Perhaps next time I'll look at one of these more modern motor drivers.Nuno, I do have a scope, but I've never measured current with it. I've just ordered a beefy shunt resistor and will check my current at the motor under load.Thanks for all the help! I will report back after I've done some experiments.

author: Ian.M
author_rank: Super Contributor
timestamp: April 06, 2015, 09:42:03 pm
content: I assume you are following the circuit in fig 6 of thedatasheet(although the sense resistor may be 0 ohms if you aren't measuring motor current)What are you using for D1-D4?What's the actual size of your "pretty big" heatsink?

author: Mechatrommer
author_rank: Super Contributor
timestamp: April 06, 2015, 10:41:30 pm
content: read at the bottom of the page "Some oscilloscope views of signals" for continuos mode motor 2nd pic compared to 1st pic discountinous...https://www.picotech.com/library/application-note/some-power-pwm-drivers-for-electric-dc-motorsi'm experimenting with 2KHz PWM software generated by pic16f690, custom driver and h-bridge. the motors still got hot after few minutes, not good... voltage and current probing shows (as below), not good not continuous, i need faster mcu to generate PWM, 20-40KHz is much preferable.

author: mribble
author_rank: Regular Contributor
timestamp: April 07, 2015, 01:49:05 am
content: Ian, Yes fig6. One change is I use a 100 uF cap instead of 100 nF on the source. I also didn't need to drive two different motors so I linked together all 4 of the outputs instead of using just two. See the image below for my schematic. These are the diodes I'm using:http://www.mouser.com/ProductDetail/NXP-Semiconductors/PMEG4020ER115/?qs=sGAEpiMZZMuIUjt4yeP9cyH9QML0fiM5iZUs2A5NcSc%3dAnd here is my heatsink:http://www.mouser.com/ProductDetail/Ohmite/RA-T2X-38E/?qs=sGAEpiMZZMttgyDkZ5WiumlCfl50RTwzz%2fuzhVigMN8%3d

author: Ian.M
author_rank: Super Contributor
timestamp: April 07, 2015, 02:07:09 am
content: Try adding a 0.1uF ceramic at the Vs pin in case the 100uF cap has too much ESRIf you've got a scope, check the PWM signal has nice square edges and is reaching good logic levels, and take a look at the output waveforms and compare with the datasheet.

author: Mechatrommer
author_rank: Super Contributor
timestamp: April 07, 2015, 03:48:00 am
content: Quote from: AcHmed99 on April 06, 2015, 10:52:27 pmbecause i need 4 indepent PWM. at first glance the datasheet i thought the pic can do 4 PWM P1A-P1D it turned out only one, the rest are some kind of compliment for full h-bridgeyea talking about wrong mcu selection here, but thats only in my stock. next move is using external 20MHz crystal (waiting order to arrive), if still not satisfy, move to avr 8 or 16MHz in my stock... just for the fun wasting time...

author: Ian.M
author_rank: Super Contributor
timestamp: April 07, 2015, 04:14:26 am
content: Looking at the datasheetFigure 1 : Typical Saturation Voltage vs. Output Current, you 've got a total voltage drop inside the IC at the 2A stall current of 2.6V (assuming equal current sharing between the paralleled outputs) giving a dissipation of 5.2W and a heatsink temperature rise of about 20 deg C. Presumably you are complaining the chip is getting hotter than that.The first thing I'd do is stick some 0.1 ohm resistors between the sense pins and ground and have a look at the current waveform. As Nuno pointed out earlier, it sounds like I^2*R losses are killing you.The next thing I'd try is pushing the PWM frequency up using the hardware PWM. Its not what you need to control four independent motors, but as everyone seems to think your PWM frequency was at least an order of magnitude too low, it would be worth seeing if increasing it is going to solve your problem before you do a total redesign.Finally, do you have more than one of these motors? If it had a shorted turn on the armature it would explain a lot, so testing a different motor would be worthwhile.I'm assuming its a PM motor not one with field coils. A series wound motor would certainly not be happy with low speed PWM.