10-08-2014 06:32 AM
I would like to perform measurements on two channels of the same DAQMX with a DAQ assistant and I would like to process the measured data of the two channels asynchronously.
The example showed on the figure hereunder does not show what I want to do with measurements but it is representative of my problem.
In this example, I want to perform measurements on two different channels:
So, I expect that the graph is updated more or less 51200/8192= 6.25 times more regularly than the indicator that show the mean.
But in practice, the DAQ assistant wait that the mean computation process is finished before updating the Waveform Graph. More, it provides an error dialog box that indicates that some measurements have been lost.
I've tried to use two parallel channel of processing but, it requires two DAQ assistants which provides an error because the two DAQ assistant call a task on the same DAQMX
Is there a possibility to desynchronize the processing on the measurements of two physically different channels in the code?
10-08-2014 06:41 AM - edited 10-08-2014 06:45 AM
Hi Fred,
having that wait function in your inner loop does not what you want…
To calculate the mean of the last second of data you need to collect 51200 samples (according to your sample rate). You can collect data using shift registers and BuildArray function!
Using the sampleclock of your DAQ hardware is much more accurate than any wait function on a standard Windows PC…
To simplify things you could also read 5120 samples per iteration. Then you need to calc the mean of each data block and then average the last 10 mean values.
Or you stick with 8192 samples per iteration and average over 6 iterations, resulting in the mean of 49152 samples or 0.96s…
10-08-2014 08:18 AM
Hi GerdW,
Thanks for your answer.
The mean computation part of the example is given for the example. In practice, the computations performed with these measurements take a lot of time. It can last more than 10s. But the computation based on the first sensor shall be performed every 0.125s.
So, maybe I wasn’t clear enough, but the two measurements from the channel 0 and 1 should be treated separately and in asynchronously.
Is it possible to do something like :
With M and N than can be any number.
10-08-2014 08:30 AM
Hi Fred,
when ai0 and ai1 are on the same DAQ device you will have to put them into one DAQmx task. So you need to read samples for both channels synchronously.
But you can process seperately: most often a producer-consumer scheme is used for this. Send your data to parallel running loops using queues.
When you need to process different sized data blocks you need to buffer your data to collect all needed samples…
10-08-2014 08:37 AM