Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Reset device/analog output like meas&autom. tool does

I am programming a NI USB-6211 device using Visual Studio C++ and sometimes the analog output gets in trouble (possibly data underrun) and becomes stuck. A device reset does not clear the proble, nor does restarting my program.


The problem I am seeing is the available space in the analog out buffer comes back as zero from a DMAmxGetWriteSpaceAvail() call.


Running the NI Measurement & Automation tool can clear the condition if I have it write some data to the analog out channel or do a device reset.  What is the M&A tool doing beyond just a device reset to clear the stuck analog out channel and how can I do that in my program?

0 Kudos
Message 1 of 4

Hi Linus123,

Thanks for posting on the forums!  I understand that you are programming your USB-6211 to output an analog signal in Visual C++, and are sometimes getting a "stuck" condition.  Is it safe to assume that you mean the voltage that is output stays the same?  This condition may happen if you are not providing data to the analog output buffer.  Also, if the task becomes stopped or aborted, the device will continue to output the last value written to the buffer.  Calling the DAQmx Device Reset function should be the same as performing a Device Reset in Measurement & Automation Explorer (MAX).  I have a few questions for  you. 


1. Are you manually configuring the output buffer?

2. How many samples are in your data set?

3. Are you performing non-regeneration mode?
4. What rate are you generating at?
5. Are you seeing this behavior when outputting a waveform from MAX?

Also, a good troubleshooting step would be to see if this behavior occurs using one of our shipping examples.  I would recommend the following example.

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Cont Gen Volt Wfm-Int Clk 

Message Edited by RT4CY on 09-04-2009 10:13 AM
Rod T.
0 Kudos
Message 2 of 4

Thanks for the help,


1) I am setting the buffer size manually to 6,000 samples.


2) I am waiting for there to be room for 2,000 samples in the buffer. When I have created a buffer of 2000 samples, I write them to the device in a series of write calls of 500 samples each (total of 4 calls/writes).


3) regen mode is off


4) output rate 30kHz, buffer size 6,000 samples (200 milliseconds to output one buffer)


5) I have not seen this behaviour using MAX, but I may not have programmed it with the same parameters.


 The USB-6211 will also be doing analog input on 3 channels at 400 Hz. but I am seeing this problem with the analog-in task not running.




0 Kudos
Message 3 of 4

Hello Linus123,


Thank you for the reply, and for the additional information!  Is there any reason you need to output the data this way?  If so, could you post back with additional information regarding your application so I can get a better handle on what you're doing, (there might be a better way).  Usually for generations, the amount of data you write before starting a generation determines the size of the buffer. The first call to a Multiple Samples version of the Write function/VI creates a buffer and determines its size.


I would like you to try a few things to narrow down the issue.

1) Ensure that you are in Release mode (not Debug)


2) If possible, try running the application on a different (faster) computer.  I would like to see if we are running into an issue with not being able to write to the buffer fast enough.
3) Try outputting data from your device at 30 kHz under normal circumstances from an example C++ program.  The reasoning behind this is to eliminate the possibility of an issue with either the hardware being used, or the driver software installed on your computer.  If you could, please run the following example


C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Cont Gen Volt Wfm-Int Clk

Message Edited by RT4CY on 09-15-2009 11:47 AM
Rod T.
0 Kudos
Message 4 of 4