Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

One time read for many acquisitions

Hi, i need some help for a problem that has bugged me for some time. I have created a Task using DAQmx library, using C# .NET, which contains a few Input channels to read some signals. I've configured the task, started it, called BeginReadMultiSample, passing an async callback function. I'm able to read the data back. The problem is that this takes time (from when i called BeginReadMultiSample to when I received the callback).. I need to run this task several times. Is it possible for me to call BeginReadMultiSample without waiting for the callback, and later on i can just read the buffer once without losing any data? Thanks for any kind help!!!!

0 Kudos
Message 1 of 5
(2,873 Views)

To phrase it precisely: Can you do a back-to-back finite samples acquisition (lets say i want to collect 100 finite sample reads), instead of:

1) Begin - callback (read 100 samples)

2) Begin - callback (read 100 samples)

3) Begin - callback (read 100 samples)

 

Can i achieve:

1) Begin

2) Begin

3) Begin - callback (read 300 samples)

 

Thanks!!

0 Kudos
Message 2 of 5
(2,835 Views)

Hi ardianto.suhendar,

 

The Async Callback function will only execute after the asynchronous read operation is completed. Jon B explains how this operates with the DAQ device quite well in this forum thread. Instead of a back-to-back finite sample acquisition, have you considered using continuous sampling and then analysing the acquired data as a multiple of 100 instead?

 

 

Regards,

Jan Yi

National Instruments

0 Kudos
Message 3 of 5
(2,828 Views)

Hi JanYi,

 

Thanks for your reply.. the problem with continuous sampling is, in between the reads, i need to do some configuration (the time is not fixed), so its preferable to do multiple finite acquisitions without overwriting the buffer everytime and perform a one time read to get all results. I just want to know if there is a way to achieve this.

 

Thanks 

0 Kudos
Message 4 of 5
(2,805 Views)

Hi ardianto.suhendar,

 

If the acquisition is finite (sample mode on the DAQmx Timing VI is set to Finite Samples), by default NI-DAQmx allocates a buffer equal in size to the value of samples per channel. Then once the specified number of sample is collected, it will clear the buffer completely. 

 

Just to be clear on your application, is this the flow work you are looking for?

1. Fill buffer with 100 samples

2. Perform configuration while filling buffer with another 100 samples

3. Then read 200 samples at once

 

You can try to manually set the buffer size using the DAQmx Configure Input Buffer VI as per stated in this KB

 

Regards,

Jan Yi

National Instruments 

0 Kudos
Message 5 of 5
(2,800 Views)