Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Time-out when outputting voltage on PXI-6229

Having an issue writing a voltage value to a PXI-6229 DAQ.  The problem is that the wait for the write task to complete never gets done.  I originally had a time=-1 parameter, and the program would hang on the DAQmxWaitUntilTaskDone statement.  Changed to 0.1 seconds to let the program move on, although with an error.
 
This works (does not hang on the infinite wait) when using the DAQmx simulator, but fails on the real hardware.
 
Here's the routine that writes the value (with the task started by another subroutine prior to this call):
 
void DAQVoltageOut(TaskHandle taskIn, float64 AnalogValue)
{
    int32 DAQmxError = DAQmxSuccess;
    float64 data[1] = {0}; // need pointer to float64 for DAQmx call below
 
    data[0] = AnalogValue; // Put voltage value in array element
 
    // Write the single value to the channel opened in CreateDAQVoltageOut.
    DAQmxWriteAnalogF64(taskIn, 1, TRUE, 10.0,   // TRUE sets autostart
        DAQmx_Val_GroupByChannel, data, NULL, 0);
 
    // Start the task. Wait until the task is done. Stop the task.
    DAQmxStartTask(taskIn);
    // FIXME -- the following fails to complete.  If infinite time, still does not complete
    DAQmxWaitUntilTaskDone (taskIn, 0.1); // Wait 0.1 second
    DAQmxStopTask(taskIn);
}
0 Kudos
Message 1 of 2
(2,911 Views)
Hi Sandia_Mike,

Because you are explicitly setting the autostart parameter to TRUE in the DAQmxWriteAnalogF64 function, the DAQmxStartTask function is not necessary.  In addition, because you are performing an on-demand analog output, the task is considered to be complete after the DAQmxWriteAnalogF64 function has executed.  In general, the DAQmxWaitUntilTaskDone function is only necessary when performing finite (N sample) generations that require hardware timing because the software does not know that generation of multiple samples has completed until the hardware notifies it has (via the Wait Until Done function).

The reason why the simulated device worked and not your actual hardware is
because simulated on-demand and finite tasks are considered done immediately, regardless of timing settings.

Regards,
Andrew W
National Instruments


0 Kudos
Message 2 of 2
(2,890 Views)