Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx input buffer and breakpoints

When I start an analog read task, set a breakpoint and wait for a while, the next read will throw due to the input buffer being full.  I can increase the input buffer size to buy more time, but on resuming I will be acquiring the data that was put into the buffer.  This essentially delays real time acquisition by however long I waited at the breakpoint.  

 

How can I handle this?  I don't care about the data the DAQ acquired while I waited at the breakpoint.  There doesn't appear to be a way to clear the input buffer.  I could have the software grab the data faster than the DAQ produces it to consume the buffer, but that introduces a dependency that should not be necessary.  I tried setting SampleTimingType to OnDemand, but that slowed acquisition down to around 10Hz.

 

I'm using a cDAQ 9174 with a 9201 input module.  Sampling at 1 kHz, setting the SampleClockRate to 1000 to achieve this.

0 Kudos
Message 1 of 4
(2,134 Views)

Hi joeylaabs,

 

The issue here is that a breakpoint stops the code from executing on your PC, but the actual data acquisition is controlled by the DAQ device and doesn't depend on your code. Once your code tells it to start, it's just gonna keep going even if the code hangs up.

To get around this, you'll need to actually stop the DAQmx task before your breakpoint, then restart it after the breakpoint.

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 2 of 4
(2,090 Views)

I understand that is the issue, thanks for writing it more clearly than I did.

 

Is there really no other way around this?  It seems like a common enough use case that I hoped there would be a better solution.

0 Kudos
Message 3 of 4
(2,085 Views)

Since the root cause is that the DAQ device is incapable of knowing that you've set a breakpoint in the PC code, there's not much else to be done.

I can tell you some options for clearing the buffer, but they also involve stopping the task:

Unreserving the device by using the Task.Control() method will clear out the buffer.
Changing the buffer size by using the InputBufferSize() property will clear out the buffer

For output tasks, changing the regeneration mode will clear the output buffer.

However, the first item will stop the task in order to perform the unreserve action, and the other 2 require the task to be inactive beforehand.

NickelsAndDimes
Product Support Engineer - sbRIO
National Instruments
0 Kudos
Message 4 of 4
(2,078 Views)