Calculate True RMS Value

The RMS (Root Mean Square) value of a set of values (or a continuous-time waveform) is the square root of the arithmetic mean (average) of the squares of the original values (or the square of the function that defines the continuous waveform). The RMS over all time of a periodic function is equal to the RMS of one period of the function. The RMS value of a continuous function or signal can be approximated by taking the RMS of a series of equally spaced samples. Additionally, the RMS value of various waveforms can also be determined without calculus.
Measuring the true RMS value of a waveform is not easy. Inexpensive AC voltmeters simply rectify the waveform (by passing it through a diode, for example), measure an average value of the rectified waveform, and apply a correction factor (assuming a sine wave). Such meters, therefore, are only accurate for sinusoidal waveforms. They do NOT accurately measure any other waveform shape. So-called “True” RMS meters in the past have depended on some sort of power measurement to derive the correct RMS value. Now that calculation power is so much more economically available, meters can analyze a waveform’s shape and actually mathematically calculate the correct RMS value. In general, if an AC meter does not explicitly say it gives a “true” RMS reading, you can assume that it is accurate only for a sinusoidal waveform.
To calculate true RMS, we must do the following equation.




That equation can be used for any periodic waveform, such as a sinusoidal or saw tooth waveform, allowing us to calculate the mean power delivered into a specified load. To do that, we must follow several steps.
1. Take the waveform and divide it into a “large” number of individual increments.
2. For each sample, square the voltage value.
3. Sum these squared values over all samples and then calculate their mean value.
4. Take the square root of this mean.
It is also possible to calculate the RMS power of a signal. By analogy with RMS voltage and RMS current, RMS power is the square root of the mean of the square of the power over some specified time period. This quantity, which would be expressed in units of watts (RMS), has no physical significance. However, the term "RMS power" is sometimes used in the audio industry as a synonym for "mean power" or "average power".
 


This application use ATmega8535 AVR microcontroller to sample two lines voltage that fed to channel 0 and 1 of its ADC. We use 3.2 kHz of frequency sampling generated by timer 1. So, at 50Hz power line input, we get 64 samples per period. Each sample saved at SRAM then multiplied and summed. After we calculate the mean, then a special routine will calculate the square root to find the RMS value of each voltage.

The maximum voltage can be applied to ADC input is 2.5 Vpp with +2.5 VDC offset. For 2.5 V DC or -2.5 V DC input, the output display must show the 2.50 value. To do this, we multiply the result by 100/512. So to calibrate the calculation, the above equation can be changed to:



The rms value of v0 and v1 in 8-bit hexadecimal and 3-character ASCII (X.XX volt) format are stored in following location:
Hexadecimal ASCII
v0 v0_rms v0_rms_ASCII
v1 v1_rms v1_rms_ASCII

The 1*64 elements array represents v0 during one period is stored at v0_data_index_start to v0_data_index_start+64; and the 1*64 elements array represents v0 during one period is stored at from v1_data_index_start to v1_data_index_start+64. They can be sent to PC via serial port (USART). From them, we can build a graph represents two voltages in one period like a PC-oscilloscope that show two channels waveform.
Please fetch them carefully, and make sure all data have been updated.

Note:
The result has 0.78% accuracy, so we must be care about the least significant digit; the result is suggested less than 2.25 digit format.


See also Measure true-RMS of Voltage and Current Grid
 
Download .asm and hex code


What’s next?

You can make a precise period of sampling and schedule when it happen...

What shall we do to make it more accurate? We can make it more accurate by making the sampling interval more precision (like making precision frequency generator).
We could increase the sampling frequency or increase the data length of data from 8-bit to 10 or 12 bit.

click here for more information

2 comments:

  1. hello Fredy i liked your post really and found it really informative so i have featured it at my website Genius Devils. hope you have liked it..
    keep posting such great content...

    ReplyDelete
  2. here in the above formula 16 is there in the denominator so i think this will be a time period but it came. please explain me in my project this is major part.

    ReplyDelete