LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 Channels with DAQ Assistant

 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.

 

Example.png

In this example, I want to perform measurements on two different channels:

  • With the first channel, I want to refresh a waveform graph every time that I measure 8192 samples
  • With the second channel, I want to compute the mean of the samples during the last seconds of measurements

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?

0 Kudos
Message 1 of 5
(5,163 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(5,160 Views)

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 :

  • N samples received from channel 0 => process 1 => restart to wait N samples independently of channel 1
  • M samples received from channel 1 => process 2 => restart to wait M samples independently of channel 0

With M and N than can be any number.

0 Kudos
Message 3 of 5
(5,137 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(5,130 Views)
No. You have a single a/d converter with a single clock. The inputs are muxed so you cannot specify separate rates or separate sample counts. You have to use a single assistant and that will return all samples from both channels. If you want a different number of samples from each channel, then specify the highest sample count you want and remove excess samples from the array of the other channel.
0 Kudos
Message 5 of 5
(5,127 Views)