01-10-2010 03:30 PM
Hello,
I am trying to do the following:
1. I will sampling data from a 3 kHz sine wave of varying amplitude. Sample Rate: Above 10kHz.
2. I would like to take compute the RMS value for every couple of cycles of the sine wave. For argument's sake, let's say compute the RMS every ~100 cycles of the input sine, or 33 milliseconds.
3. I do not want this RMS to be a streaming value, but an "instantaneous" value. That is, I'll essentially be downsampling to get the RMS, and each RMS computation will not include any data points from the previous one.
4. I've been trying to do this through initializing an array and inserting values, but this only works at low sampling rates. The problem is, with my data acquisition setup, I only insert values into the array based on the loop count, which, is based on the standard sample rate and number of samples to read set up.
I've posted the code, which hopefully isn't too convoluted to follow.
Any suggestions would be warmly welcomed.
RTom.
P.S. I know of the RMS computation, but I prefer to do it numerically. Thanks!
01-11-2010 05:10 PM
Hey R Tom,
What do you mean it only works at low sampling rates? What is it doing at high sampling rates? Why exactly is your method not working? Is the raw data at high sampling rates correct? Could you expand on the problem of inserting values into the array based on loop count?
For a side note: as a general programming practice it is better to use wires instead of local variables when possible.
Kristen H.