07-18-2019 05:18 AM
HI everybody,
I have a DAQMX analog 12 channels input that feeds me with data with the sample rate of 100k and 1000 sample/channel. I can not increase the sample/channel because we need to save the raw data as is.
I want to do a block average (not running average) where I buffer every 600 data and then average it to get 1 value. I try with data queue but it seems I ended up with the running average.
Can somebody help me with the issue?
Warm regards,
07-18-2019 07:25 AM - edited 07-18-2019 07:25 AM
Add a conditional so that you only do the average every X samples. Quotient & Remainder is good for doing that. You should also store your last calculated average in a shift register for feedback node so you can keep using that value instead of whatever constant you use as the default.
07-18-2019 08:07 AM
@rioriorio wrote:
I can not increase the sample/channel because we need to save the raw data as is.
I do not understand what you mean by this. What does saving the raw data have to do with sample rate and samples/channel? I assume that you are continuously sampling and storing the raw data for some period of time. I would change from 1000 samples/channel to 600 samples/channel. Then you could get an average of the data every time you retrieve data.
07-21-2019 12:37 AM
"I would change from 1000 samples/channel to 600 samples/channel".
I can not temper with this setting, for time being, just consider it as my constraint.
07-21-2019 09:28 AM - edited 07-21-2019 09:32 AM
You haven't provided the code that you use to collect the data, so I don't know whether you are using 2D Dbl Arrays, 1D Arrays of Waveform, or something else. I also don't know if you are using Producer/Consumer Design or trying to do everything in a single loop.
If you had the data as 600-sample "chunks" from a DAQmx Read, the process would be very simple -- every time you get a Chunk, split it, sending one Chunk to the "Save the Data" routine to write to disk, and send the other to the "Average 600 points" to give you your average. With 1000 points, you'd do the same thing, but the "Average 600 points" routine gets more complicated. Here's one way to begin to approach it:
Bob Schor
07-22-2019 01:16 AM
Hi Bob,
This is currently part of the code I am working on. I hope I could find a better way to make the block average. the current method I am using is time-consuming.
07-22-2019 06:25 AM
Your code is very different than what you described. You are not averaging 600 data points. You are taking the average of 1000 data points every 600th reading. Did you even try the code that crossrulz suggested?
07-22-2019 06:42 AM
No. He's taking the average of how many data points happened to have been acquired since the last loop iteration. Then sending that average to the other loop every 600 loop iterations which may or may not represent 600 data points. It is almost certainly not the average of 600 points or 1000 points.
07-22-2019 06:52 AM
@RavensFan wrote:
No. He's taking the average of how many data points happened to have been acquired since the last loop iteration. Then sending that average to the other loop every 600 loop iterations which may or may not represent 600 data points. It is almost certainly not the average of 600 points or 1000 points.
I made the assumption that he was setting Samples/channel to 1000. He's telling the DAQ to wait forever until there are Samples/channel data points and then read those Samples/channel data points, then averaging those data points and sending every 600th average to the other loop.
07-22-2019 07:21 AM
@rioriorio wrote:
"I would change from 1000 samples/channel to 600 samples/channel".
I can not temper with this setting, for time being, just consider it as my constraint.
What else in the system cares about the number of samples you read at a time? We keep harping on this because it is BY FAR the simplest route to get to the requirements you have told us so far.