# Calculating PWM Duty Cycles

1. Duty Cycle = 255 * (VR / VP)
2. Duty Cycle = 255 * (VR² / VP²)
VR = Voltage Required
VP = Peak Voltage (5v)

I am actually switching a much higher voltage (12v) using a PWM output to turn a power mosfet on and off. This is all working but I was getting strange results. If I used a 50% duty cycle (to simulate 6V), I was consuming twice the amount of power I would have been using a straight 6V supply. Only when I ran a 25% duty cycle did the amount of power I was using match what 6V should have been using. 10 ohm load at 6V should use 3.6W of power. When running at a 50% duty cycle, I’m running the 10 ohm load at 12V for half the time. Now 10 ohms at 12V is 14.4W, so half of the time that reduces to 7.2W which is indeed double what would be used at 6V. So, a “friend” told me to use an RMS calculation to work out the duty cycle, which in this case would be 25%. Only thing is, a volt meter doesn;t agree. When I run a 50% duty cycle a volt meter does report 6V, and a 25% reports 3V, yet the load is performing at 25% like it should do at 6V. I’m just completely confused, can someone clear all this up? I’d be soooo grateful.

Thanks
Dan.

These two formulas refer to the average voltage produced by a pwm output and a low pass filter.

1) calculates the averaged dc voltage at the output of the filter 2) calculates the power produced by the filtered voltage above since P=U^2/R, R being constant.

If you apply the pwm voltage directly to the load (full voltage on, no voltage off) average power will be dutyCylce/255*P

nilton61: These two formulas refer to the average voltage produced by a pwm output and a low pass filter.

1) calculates the averaged dc voltage at the output of the filter 2) calculates the power produced by the filtered voltage above since P=U^2/R, R being constant.

If you apply the pwm voltage directly to the load (full voltage on, no voltage off) average power will be dutyCylce/255*P

So which formula should I use? The PWM output is directly applied to the load (which is a heater). The heater reaches the same temperature at a 25% 12v duty cycle as it does with a constant 6V. So to me that seems the correct formula, but I'm just confused why a volt meter would read 3V it seems to break Ohm's law,

Multimeters normally are designed to read sinuosidal voltages not square waves.
Try using a diode and do a dc measurment.

Or use a movin coil meter not a digital one.

DGlen:
So which formula should I use? The PWM output is directly applied to the load (which is a heater). The heater reaches the same temperature at a 25% 12v duty cycle as it does with a constant 6V. So to me that seems the correct formula, but I’m just confused why a volt meter would read 3V it seems to break Ohm’s law,

• A (normal, non TRMS) voltmeter in DC measurement mode will take a normal average of the input voltage. 12V*0.25 = 3V
• A resistive heater will have a power P=U^2/R. So in order for a given resistor to dissipate 25% of its nominal power the DC voltage should be 12Vsqrt(0.25)=12V0.5=6V.

What happens here is when you apply PWM directly to the load you get P=PndutyCycle because the applied voltage is the full voltage.
If you insert a filter that converts PWM to pure DC you will get P=pn
dutycycle^2.
In your case the filter is applied to the measured voltage, because of instrument acting the way it does, but not to the load.

• A TRMS instrument would show you sqrt(12^2*0.25) = 6V

“When you try to break the laws of nature god will hit you on the head with something hard until you understand”

nilton61: - A (normal, non TRMS) voltmeter in DC measurement mode will take a normal average of the input voltage. 12V*0.25 = 3V

In theory yes. Modern digital multimrters though use sampling. I have found them generally very poor at frequencies beyond 100Hz and anything other than sine wave. Not sure i would trust them even for ball park figures with a square wave.

Boardburner2: . I have found them generally very poor at frequencies beyond 100Hz and anything other than sine wave. Not sure i would trust them even for ball park figures with a square wave.

Sine wave would imply AC measurement

Understood.
Did not think it through , i assumed measurment error rather than understanding.
Even with a dc measurment , i would not trust a dmm to be correct with a square wave into a resistive load.
I have known even fairly expensive ones to be plain wrong or even have wildly jumping values displayed.

I had a well known make with a calibration cert. which did this.

Never really investigated the reasons behind it though, just reached out for the scope.