12-13-2010 03:26 PM
Simple question (couldnt find an answer )...
I'm gathering continuous data at 500Hz, I need the average of the last 3 seconds in a continuous fashion. That is, I want the average of the last 1500 data points to be diplayed continuously as I'm recording (as if I'm smoothing the data over 3 second averages).
I tried the Mean PtByPt VI, but it seems as if its averaging all the data (from the start) and not just the last 3 seconds, even after I change the sample length.
Any help would be appreciated.
Thanks
Solved! Go to Solution.
12-13-2010 03:40 PM
mean ptbypt should do what you want if you set the sample length to 1500.
Please show us an example VI where you think it does not.
In general, a running average is also easy to implement directly. Just keep a size=1500 array in a shift register and replace the oldest with the newest element at each iteration before taking the mean. Make some minor adjustment for the case where less that 1500 samples have been acquired.
12-13-2010 04:12 PM - edited 12-13-2010 04:14 PM
Here's a quick example comparing the "mean ptbypt" and an explicit implementation for a running average. Both give the same result.
Modify as needed.
12-15-2010 10:31 AM
I tried using the mean ptbypt function, but it doesnt seem to be averaging my last N data points. I tried changing the value range from anywhere from 1 to 1500. For example if I set the value range to 1 then it should 'average' my last data point only and the result should be the same as my actual data, right? but it doesnt do that
Also when I open the saved LVM file, the mean is only recording every 1 second instead of recording at 500Hz.
I'm pretty sure I'm doing something wrong...
Here's my vi
Thanks
12-15-2010 10:45 AM - edited 12-15-2010 10:49 AM
You are using dynamic data. I don't know what it gets coerced to at the subVI.
(Note the red dot, telling you that something gets possibly lost in translation).
Try to use the filter VI from the express palette and select "smooting, running average, rectangular".
(I don't really know the express and dynamic stuff, sorry... ;))
12-15-2010 01:17 PM
How would I use the smoothing vi to get the moving average of the last 3 seconds (ie the last 1500 data points), and display them continuously during my recordings ??
12-17-2010 04:33 AM - edited 12-17-2010 04:35 AM
Hi Sal,
Sounds like to me that you are actually getting 500 points of data every 1 second output from the DAQ assistant module (ie 1 dump of 500 points per second rather then 1 point every 500th of a second), as you dont have a timing vi on your block diagram and you say that you are only logging data every second i would imagine this is the case (Not got DAQmx on my computer so dont actually know if this is the case). If this is the case then you will need to average the data you get every 3 reads. I think it would be something like this:
I think you will need to convert your dynamic data to an array (If i am right i think this will be an array of 500 points). To use the mean ptbypt vi you will then need to add all array elements and set the averaging length to 3.
Not %100 sure if i am right on this but thought it might be worth a go.
Regards,
Lucither.
12-17-2010 09:26 AM
Its not working, I tried this, but I think its adding some values (I dont know which)... Let's say on my recordings I'm getting data in the 210-220 range, the result of the formula you gave me is giving me something like 107000
12-17-2010 10:33 AM - edited 12-17-2010 10:35 AM
The shown code by Lucither is incomplete.
He's adding 500 points before averaging, thus you need to divide by 500 (or whatever the array size is before summing). Voila!
107000/500 = 214. Looks about right. 😉
12-17-2010 10:33 AM - edited 12-17-2010 10:34 AM
(duplicate due to forum error)