LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ read in a loop with finite samples

Solved!
Go to solution

Thank you very much for your input. I think that I understood the idea and I am trying to adapt the suggested example to my case. However, I still have a problem which is presumably related to the way the buffer is read. It seems that I read both old and new values. I tried to add this VI before the reading step but could not find the right settings. Do you know if there is a way to clear the buffer before each reading?

 

Thanks,

Bernard 

0 Kudos
Message 11 of 15
(1,411 Views)

"...It seems that I read both old and new values..."

 

It just seems like that, but it's not possible from the driver itself. When DAQmx overrides samples you get an error, when you try to read samples which are not available yet, you get a timeout error.

 

Just implement the retriggerable AI example as it is.

 

 

Christian

0 Kudos
Message 12 of 15
(1,402 Views)

Thanks Christian. You are right this was not a problem of buffer.

 

However I had to specify the number of samples to be read to really get it synchronized.

 

DAQmx_read.png

 

Now it works pretty fast (around 15ms per iteration to read 8 AI channels instead of ~ 200ms before). However  roughly half of the time the number of available samples is below the specified number and nothing is read. I guess this is due to the time it takes to actually read the data or do you think it can be improved?

 

Many thanks for all these crucial inputs.

Bernard 


0 Kudos
Message 13 of 15
(1,396 Views)

Great!

 

If you don't specifiy a number of samples the DAQmx Read.vi, reads all available samples in the buffer.

But when you need the same amount of samples with everytime you call the VI, you need to wait until theese samples are available.

 

 

Christian

0 Kudos
Message 14 of 15
(1,390 Views)

Thanks again!

 

I changed the wait mode to sleep using 1 ms as sleep time and now the DAQmx Read.vi waits for the samples to be available as wished. Using "sleep" option instead of "poll" or "yield" reduced the demand on the CPU. 

 

wait_mode.PNG

Bernard 

0 Kudos
Message 15 of 15
(1,386 Views)