# Sample rate and RMS

Discussion in 'Homework Help' started by PonkPonk, Jan 24, 2013.

1. ### PonkPonk Thread Starter New Member

Sep 11, 2012
7
0
Consider that I measure a 60hz sine wave with an RMS of lets say 220 volts (peak amp ≈ 220*√2). Now I measure it with a sample rate waay above 60hz (sample rate of above 6000 S/s).

The question is, how will the sample rate impact on the RMS? Will RMS be affected as I slow down the sample rate / speed up the sine wave?
I've played in MATLAB, and of course the whole thing goes bananas the closer the signal frequency gets to sample rate.

Aside from Nyquist rate and similar, the RMS measurement shouldn't be affected as long as the sample rate > 2*B . Below that, anything can come out but generally lower. Is this a valid statement?

What are your thoughts on this? I appreciate any comment and suggestion about where I should look further, because I really want to understand this thing.

Thanks for the great forum!

2. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
The RMS value is determined through your samples, so the more samples/information you have, the more accurate your results will be, however, there comes a point where an increase in samples is a negligible increase in accuracy, dependent on your requirements.
The RMS is based off of the waveform sampled. It isn't directly determined by your sampling frequency. Your sampled signal's representation, and therefore the RMS value, however, does rely of your sampling frequency, so it's no wonder you wouldn't find anything of substance. If your sampled signal no longer looks like the original, then your RMS value will be inconsistent with the original.

Not quite, what you are experiencing is called aliasing and the result is dependent on the frequency components of your signal and the sampling frequency of your signal. It could be anything...

3. ### crutschow Expert

Mar 14, 2008
13,515
3,386
For a pure sinewave of frequency f you only need to sample slightly above 2*f to get true RMS. If you need the true RMS of a distorted sinewave or a sinewave with harmonics then you need to sample at >2*f where f is the highest Fourier component of interest in the waveform. But for ease of processing it's desirable to sample at well above twice the highest frequency of interest.

4. ### WBahn Moderator

Mar 31, 2012
18,093
4,918
Another thing to consider is that, while it may be true that sampling at just over 2*f is sufficient in theory, it can take a really, really long time to collect enough data to make the computation good enough; you're not going to just take data for one cycle and get a decent result.

5. ### PonkPonk Thread Starter New Member

Sep 11, 2012
7
0
Thank you all for your tips and insights!

I've played some more with MATLAB during the couple of days and here's where I've gotten to. Ok, I plotted the sine wave in accordance with the sampling rate AND plotted the RMS (which is a straight line).

Now, however, when I increase the frequency of the sine wave with one Hz and keep the sampling rate constant (6000 S/s), the RMS curve goes down (with 0.5 volts). Conversely if I decrease the sine wave frequency with one Hz (to 59 Hz) the RMS goes up!

Exactly why does the above happen? The RMS is itself a square root of an integral divided by the period the signal is measured. How can one Hz affect the RMS value so much? Is this connected to the sampling rate?

I attack this problem from many angles but I want to understand how is the RMS being affected by this change...

6. ### crutschow Expert

Mar 14, 2008
13,515
3,386
It shouldn't vary that much. Are you sure your math is done correctly? You would take the measurement over the number of samples for one cycle and then divide by that number of samples.

What is the value you are measuring?

7. ### WBahn Moderator

Mar 31, 2012
18,093
4,918
It took a while to figure out what you were trying to say (and I'm not sure I've got it right, yet). In particular, I had no idea what you meant by things like "increase the frequency of the since way with one Hz". What I think you meant is "by one Hz". Similarly, I'm assuming you mean that your computed RMS decreased by 0.5V (from 220V) when you increased the frequency of the waveform by 1Hz from 60Hz to 61Hz.

It's pretty much impossible to tell why you are seeing what you are seeing when what we aren't seeing is what you are doing! We need to see your work!

If you are averaging over one cycle, then the number of samples used in your summation decreased from (6000Sa/s)/(60cyc/sec)=100Sa to (6000Sa/s)/(61cyc/sec) = 98.3Sa (probably to 98Sa), or about a 2% decrease. Your RMS result decreased by about 0.5V/220V=0.2%. A good portion of that could be nothing more than differences in roundoff error. Another thing to keep in mind is that you are sampling at a difference set of points on the waveform and that will result in some differences.

If you sample a sine wave at evenly spaced intervals over one period (i.e., so that the sampling rate is an integer multiple of the frequency), then if you shift the sampling points back and forth your RMS value won't change. But if your sampling rate isn't an integer multiple of the frequency, then as you shift the sampling points back and forth your RMS value will change by some amount. The higher the ratio of the sampling rate to the frequency of the waveform being sampled, the less this change will be.

Imagine (or do the simulation) sampling at ten evening spaced points along a sine wave starting at t=0.00T and ending at t=0.90T, where T is the period. Now imagine repeating the experiment but shifting everything so that your first sample is at t=0.05T and the last sample is at 0.95T. If you calculate the RMS values of those ten points in those ten sets, you won't get the same answers.

8. ### Tesla23 Active Member

May 10, 2009
323
67
No, you can work out the RMS value of a sine wave by sampling at almost any frequency. It's safe to use any frequency > 2F, but as long as you avoid subharmonics, F and 2F, you can use any other frequency.

If you are sampling >2F and you sample an exact whole number of cycles (N) then your measurement should be exact. If you have a part of a cycle left over (say r with 0 < r < 1) then the accuracy will be of the order r/N. Making N large is important.

If you are sampling near one of the bothersome frequencies I mentioned, you can work out the aliased frequency of your samples, and count the cycles of that sinusoid to estimate the accuracy. If you sample very close to F for example, the alias is a very low frequency and you have to sample for a very long time to get lots of cycles.

9. ### PonkPonk Thread Starter New Member

Sep 11, 2012
7
0
Thank you all for your inputs! I really appreciate it!
(Note to myself for future: post a picture, then state the problem)

WBahn
I think you explained this very well, and by your tips I think I got it. The problem lies in the fact that the sampling rate is NOT an integer multiple of the frequency, AND by changing the frequency of the sine wave (while keeping the sample rate constant) the RMS is calculated on different values (while the period it is calculated on stays the same). That's why the RMS keeps changing.

Again, many thanks to all of you, as the tips about Nyquist theorem will come very handy to me!

10. ### WBahn Moderator

Mar 31, 2012
18,093
4,918
The period on which it is calculated should change as well since it needs to be an integer number of cycles of the waveform for best accuracy. When you have multiple signals at many frequencies or you don't know what the input frequencies are, then you need to average over a long enough period of time that the error for incorporating only a fraction of the final period is small compared to the average itself.