CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Ac meter with 16F877

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
goyoko



Joined: 08 Jan 2004
Posts: 2

View user's profile Send private message Send e-mail

Ac meter with 16F877
PostPosted: Tue Feb 01, 2005 10:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 01, 2005 11:02 am     Reply with quote

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








PostPosted: Tue Feb 01, 2005 2:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 01, 2005 4:21 pm     Reply with quote

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
PostPosted: Wed Feb 02, 2005 6:25 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 03, 2005 7:11 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group