View previous topic :: View next topic |
Author |
Message |
goyoko
Joined: 08 Jan 2004 Posts: 2
|
Ac meter with 16F877 |
Posted: Tue Feb 01, 2005 10:54 am |
|
|
Hello. I need some help about AC signal meassurments. I wanna calculate the RMS Value without external devices, it's mean, only using C code.
How can I do it?
Thanks in advance. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Feb 01, 2005 11:02 am |
|
|
What do you need to know?
RMS stands for Root of the Mean Square. You take your readings, square them, average them, and take the square root. If you are measuring 50Hz or 60Hz AC you should average over an integer number of cycles. Averaging over 1/10 sec will cover both 50Hz and 60Hz without having to know which you have or where the cycles start. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Tue Feb 01, 2005 2:47 pm |
|
|
Do you mean that I can take som samples numbers per cycle the same way that I get the RMS value in analog signal.
I got one expression to obtain the RMS value but I don't know that if it's right. It's 1.1*(1/n)*(n1+n2+...+n)
But the PIC can calculate this value? Is this done by DSP or not?
Thanks |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Feb 01, 2005 4:21 pm |
|
|
1.1*(1/n)*(n1+n2+...+n) ???
That looks like 1.1 times the average. That has nothing to do with RMS. RMS would be
sqrt((n1^2+n2^2+n3^2......nn^2)/n).
How much processor speed it needs depends on how fast you are sampling and what resolution you need. If you are measuring AC power line frequencies at reasonable sampling rates you should be able to do it easily in a PIC.
To read the first three harmonics of 60Hz you need to sample at at least 360Hz (60Hz * 3 * 2) so you have almost 3ms per sample <snore>. Averaging over 1/10 second is 36 samples. Store the squares in a circular buffer and keep a sum. Each sample you add the newest and subtract the oldest from the buffer and from the sum. Then take the square root of the sum and you have your RMS.
If you want to measure higher frequency AC, like audio, you will have to sample much faster and your PIC might start working hard. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
JPA Guest
|
RMS |
Posted: Wed Feb 02, 2005 6:25 am |
|
|
If my memory is good, the 1.1 coefficient is only valid for sinusoidal waves. In fact 1.1 is the factor between the RMS value and the mean value of a sinusoidal rectified wave.
The term 'TRUE RMS' for voltmeters comes from this difference ('TRUE RMS' volmeters really comptute the real RMS value; others just multiply the mean value by 1.1). |
|
|
goyoko
Joined: 08 Jan 2004 Posts: 2
|
|
Posted: Thu Feb 03, 2005 7:11 am |
|
|
Then, if I want get the TRUE RMS value I need use the RMS expression and apply in each sample. I have a question about de cycle. Do you have some information about the circular buffer or when I must to use the expression. I need syncronize with zero cross detector?
Somebody have an example algorithm ?
Thanks |
|
|
|