True RMS digital measurement & calculation

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
Considering how to measure / calculate RMS power in an AC line I've got the concept: The rms value results from squaring the values over intervals of time, finding their average value, and taking the square root of it.

Thinking of measuring power used by a common appliance connected to 220 V AC monophasic using a PIC for the measurement and calculation, I understand I should do this:

a - Measure V and simultaneously I (well, as close in time as possible to each other!!).

b - Multiply V * I to get instantaneous value of power.

c - Add succesive instantaneous values of power.

d - Calculate the square root of their sum

e - Repeat the process for the next cycle.

My questions:

1 - How many times per full period (or per second) should I measure instantaneous V and I to make this reasonably precise? I could not find a suggested figure in the so many places talking about true RMS.

2 - Is the zero crossing information a must to start counting the above or could I use a precise timer to trigger the next pair of measurements plus the calculation?

2 - Is it wrong to do this kind of measurement/calculation for one of every two full periods? Am I cheating the reasult in that way?

3 - A 10-digits ADC is it enough if taking the output from current / voltage transformers with adequated down scaling?

4 - Even if the above is a yes, could the 18F452 (which I've just started to work with) be useful here? (Quite an improvement over the 16F877!!)
 

Papabravo

Joined Feb 24, 2006
21,159
I'm by no means sure that RMS Voltage, or RMS current are related to the average power described in your calculation. An RMS caculation is an average of non-negative quantities. As such it cannot be zero unless the input is identically zero. The average cannot be negative since the square root would be undefined.

In computing average power by multiplying instantaneous voltage times instantaneous current you will get both positive and negative values, since the current and voltage are not likely to be in phase with each other.

This observation may or may not have anything to do with your ultimate purpose but it seemed like an important point.

RMS Voltage and RMS Current are actually designed to give an idea of power disipation in that they are each non-zero over one period and can be multiplied together to produce a quantity, with units of watts, which is related to the disipation of a resistive element in an AC circuit.

You question about starting the sampling and computation process at a zero crossing is good insight. But which zero crossing, current or voltage. Since they are not in phase the zero crossings for current and voltage occur at different points in time.

You might want to consider measuring RMS voltage and current separately and also computing the phase difference. The cosine of this phase difference is called the power factor and is a measure of how close the load is to being a resistive load.
 

n9352527

Joined Oct 14, 2005
1,198
Originally posted by atferrari@Apr 24 2006, 02:28 AM
Considering how to measure / calculate RMS power in an AC line I've got the concept: The rms value results from squaring the values over intervals of time, finding their average value, and taking the square root of it.

Thinking of measuring power used by a common appliance connected to 220 V AC monophasic using a PIC for the measurement and calculation, I understand I should do this:

a - Measure V and simultaneously I (well, as close in time as possible to each other!!).

b - Multiply V * I to get instantaneous value of power.

c - Add succesive instantaneous values of power.

d - Calculate the square root of their sum

e - Repeat the process for the next cycle.

My questions:

1 - How many times per full period (or per second) should I measure instantaneous V and I to make this reasonably precise? I could not find a suggested figure in the so many places talking about true RMS.

2 - Is the zero crossing information a must to start counting the above or could I use a precise timer to trigger the next pair of measurements plus the calculation?

2 - Is it wrong to do this kind of measurement/calculation for one of every two full periods? Am I cheating the reasult in that way?

3 - A 10-digits ADC is it enough if taking the output from current / voltage transformers with adequated down scaling?

4 - Even if the above is a yes, could the 18F452 (which I've just started to work with) be useful here? (Quite an improvement over the 16F877!!)
[post=16457]Quoted post[/post]​
Just a suggestion, there are ICs that would do all the necessary work (sample, square, multiply, integrate, etc.) and come up with the RMS power.

An example of this is AD7753 from Analog Device. It is able to measure active, reactive and apparent power and also period and RMS power for single phase distribution with different frequencies. This particular IC can be interfaced with di/dt current sensor and has a serial port to control/read the data (particularly useful if you want to interface it to PIC). It is not that expensive, about $4 each.

Analog Device also has several other ICs that would do the same thing with different features and prices. Have a look at its energy measurement page here.
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
Hola n9352527,

Thanks for the link. For the moment I still intend to do it by myself. Since it is for my own education I would like to solve this via the PIC.


Hola Papabravo,

I am in the quest of true RMS power. It is not average power. Since I am no well versed in this I refrain to discuss or just ask too many questions, at least for now.

Still reading on the subject.

Gracias to you both.
 

n9352527

Joined Oct 14, 2005
1,198
In that case, we can go through your questions:

a. Yes, you need to sample both voltage and current as close together as possible. There is error associated with sampling delay, but I suspect it is quite small for 50/60Hz line frequency. You could actually calculate the error from the slope (i.e. changes of respective voltage/current at 50/60Hz) for a given load.

b and d. You need to calculate the square root of the _mean_ _square_ sum. I think you just missed writing these as I see you got the other points right. Square V and I independently first then multiply them together. This would avoid the need to deal with negative values when V and I are not in phase.

1. How many samples per cycle to obtain acceptable accuracy? There is no straightforward answer and number of samples alone is not sufficient in predicting the accuracy because it also depends on the summing method. You might also consider different value as an acceptable accuracy for your application.

Summing the V^2*I^2 is basically an integration of the associated curve, there are various different numerical methods that can be applied to achieve this. Different numerical methods also result in different accuracies. For example, left or right Riemann sums, trapezoidal rule and Simpson's rule to name a few that are simple enough to do. Unfortunately, it is very difficult to calculate the error using these methods accurately, however we can calculate the upper bound of the error or estimate the error.

Have a look at this page for an introduction to numerical method for integration, specifically Riemann, trapezoidal and Simpson and treatment to estimate the error and boundaries.

You could also check your nearest library, most engineering math books treat this subject extensively.

2. I would go with the zero crossing, mainly to avoid dealing with a timer and the associated inaccuracy. It would also benefit if you need to measure power at different line frequency. To avoid difficulty with changing load characteristics, e.g. any combination of resistive and capacitive and inductive, go with voltage zero crossing.

2. (You have two number 2). If you are sure that the power drawn is periodical (i.e. it doesn't vary from one period to another), then it's fine. Otherwise you'd introduce an error by skipping one (or more) period(s).

3. Again, there is a way to calculate the error introduced due to the analogue to digital conversion (sampling resolution, ADC non-linearity, etc.). You could consult any good book on data conversion which should explain this subject in details.

4. I have no idea. I guess it depends on whether you want to use the internal ADC, how accurate do you want the result to be and how fast the micro is. You have to make sure that the micro is capable of performing the necessary calculation within each period. Some hints, defer scaling the sampled values until the end and perform the calculations on the integer values from ADC instead. This is more commonly violated when a C compiler is used instead of assembler (it is easy to write P(float) = V(float)*I(float) in C without appreciating how long it'd take to finish the multiplication).
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
Thanks n9352527,

Little by little I am approaching the goal.

You were clear for me to udnesrtand. And thanks for the link!!

Will revert sooner or later with the outcome.
 
Top