Go Down

Topic: Reading DC rms/average voltage from a pwm signal (Read 12410 times) previous topic - next topic

raschemmel

#15
Sep 18, 2014, 10:29 pm Last Edit: Sep 18, 2014, 10:37 pm by raschemmel Reason: 1
This is what he said. Show me where it says "rms".

Quote
Hi, in one part of my project, I'm switching an N channel mosfet via digital pin PWM.  It's adjusting power from two 3.7v batteries in series to a load.  I need to be able to read the average voltage on the load side, but it's pulsing. I'm trying to figure out what the best way to achieve this is.  Thanks!  



Quote
It's a resistive load being powered by batteries.  I'd really like to get the actual voltage somehow, since battery sag/voltage drop will play an issue. I found more info here.


The above are the OPs only two posts.
I don't see anything about rms


I agree it is in his post title but he never said anything about it after that when asked for clarification. I don't think he knows the difference and thought they were the same. The fact that he lumped two different parameters together suggest that because if he was interested in one , he would not be interested in the other and vice versa.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

polymorph

Oh, come on! It is in the title. He typed the title.

Yes, if he doesn't know the difference, isn't it important to educate him about that difference? Perhaps he says average in his message, but really wants to know the RMS, but doesn't know until he finds out what RMS voltage is.

Again, please tell me why it is necessary to waste extra parts and an extra pin just to find out what you can find with one equation. I'm just not getting it.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

#17
Sep 18, 2014, 11:22 pm Last Edit: Sep 18, 2014, 11:35 pm by raschemmel Reason: 1
Quote
Yes, if he doesn't know the difference, isn't it important to educate him about that difference? Perhaps he says average in his message, but really wants to know the RMS, but doesn't know until he finds out what RMS voltage is.  


Now we're getting somewhere.

Now we just have to find our which parameter he really needs. I think you already showed him how to convert from one to the other.

I maintain that by adding the RC LP filter and using an analog pin, he can measure the value.
In defense of my point , I submit that the OP's words indicate he is looking for a measurement and not a calculation:

Quote
I need to be able to read the average voltage on the load side,


You point is he should just add a line of code.  (which I submit is not a measurement)

I think that about sums it up.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

vffgaston

Quote
My apologies, RMS and average are -not- the same thing here.

Average voltage is just.. an average of the voltage. If 5V is On 25% of the time, the average voltage is 1.25V. Whereas the RMS voltage would be 5*(0.25^0.5) = 2.5Vrms. IE, the voltage that would cause the same power dissipation in the load as 5V that is on 25% of the time.


You shoudnt apologise: We are here just to interchange ideas (and/or certainties; nevertheless I would prefere doubting on everything  :smiley-roll-sweat:).

The product of the high voltage by the duty cicle has physical significance, as long as it is the DC value that a RC low pass filter will show: Is it correct to call it "average" (I wonder: belive me, I'm honest)?.

Regards

polymorph

As long as the drive to the RC filter is symmetrical in nature and a square wave, then the smoothed DC output will be the average voltage

What do I mean by "the drive ... is symmetrical in nature"?

I mean that it must charge and discharge it equally well.

So let's say you had a single-ended drive, maybe a low side driver such as a MOSFET with an On resistance of 50mOhms. But the load is only 1k. You then have a 3.3k resistor and a 100uF capacitor RC filter.

When the MOSFET is On, the total resistance discharging the capacitor is through the MOSFET. 3.3k + 50mOhm = 3.30005K.

When the MOSFET is Off, the total resistance charging the capacitor is through the load resistance. 3.3k + 1k = 4.3k.

So the voltage across the capacitor will NOT be the average voltage. It will be quite a bit lower.

But let's make the ratio between the smoothing resistance and the other resistances much greater.

MOSFET 50mOhm
Load 10 Ohm
RC  100k and 3.3uF (same time constant as above)

Now the discharging resistance is 100.010K, charging resistance 100.00005k. Very little difference, so the smoothed voltage will only be very slightly lower than the actual average voltage.

Again, this is only true for a square wave.

Well, to be clearer, it -will- work for a pulsed sine wave or other waveform, but ONLY with symmetrical drive. In other words, the waveform must be coming from something like an Op Amp that can source and sink to maintain the waveform.

Clearly, a power supply with a transformer and rectifier diodes is not averaging the voltage with its capacitor. It is smoothing to the peaks, because the diode only sources current.


Still, if the PWM is coming from the same Arduino that is "measuring" the average voltage on the load, why not just calculate it from the PWM?
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

I don't think your calculations are correct . Are talking about the arduino PWM output pin that is connected to the input of the RC LP filter ?

The average of a 25% duty cycle PWM is 25% of the Vcc voltage which in this case is 5V. If you are trying to correlate the average of the PWM pin using the LP filter to the average of the H-Bridge which always has two devices on, I think the conclusion is the same.
I think the averaging of the PWM pin using the LP filter accurately reflects the averaging of the power applied to the motor load.
I don't have any calculations to prove that but that is my conclusion.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

vffgaston

Quote
I think the averaging of the PWM pin using the LP filter accurately reflects the averaging of the power applied to the motor load.


Unless the "thing" connected to the PWM (with or without a H bridge) sinks constant DC current (i.e. not dependant on the DC voltage) the power is not proportional to the voltage (so the term "average" is misleading).

Regards

raschemmel

The "thing" the RC LP filter would be connected to is the PWM pin and when it is LOW it sinks current. When it is HIGH it sources current. In the case of the H-Bridge , connected to a motor load, when the signal is HIGH, the motor current passes through one transistor or mosfet to get to the motor and then through the motor and then through another transistor or mosfet to get to ground. When it is LOW, both devices are OFF and there is no path to ground and the voltage ACROSS the motor goes to zero.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

polymorph

The Arduino pin should be a symmetrical drive, and so should not be a problem.

I have seen people here try to generate something like a 0-10Vdc signal by using a high side PNP switch with an RC network after to smooth it out. It never quite works because of the effects of assymetrical drive currents.

If it is the output of an H-bridge, that should also work as it is a symmetrical drive.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

polymorph

vffgaston is right, power is not proportional to voltage. Hence all my futzing about to calculate RMS voltage.

But the original poster has still not told us if he's figured out yet if he means RMS voltage, or average voltage.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

vffgaston

Quote
vffgaston is right, power is not proportional to voltage. Hence all my futzing about to calculate RMS voltage.


Thanks: I was questioning my basics  :smiley-roll-blue:.

Regards

rmetzner49

P=I*I*R, so it is a second order effect.  If you DOUBLE the voltage you will QUADRUPLE the power.

2V/1ohm=2A      Since P=I*E  power=4W
4V/1ohm=4A     Since P=I*E  power=16W

polymorph

Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

Go Up