Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with 'DAQmxWriteDigitalU16'

Hello there,
 
I have a problem with the following routine, because after the successful execution of the 'DAQmxWriteDigitalU16' function, the programm doesn't go on with the next line 'DAQmxStartTask'.
I do not get back any error message.
 
DAQmxCreateDOChan(taskHandleWrite, "Dev1/port2", "", DAQmx_Val_ChanForAllLines);
 
DAQmxSetDODataXferMech(taskHandleWrite, "Dev1/port2", DAQmx_Val_DMA);
 
DAQmxCfgSampClkTiming (taskHandleWrite, "OnboardClock", clockRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, numSampsPerChanWrite);
 
DAQmxCfgOutputBuffer(taskHandleWrite, numSampsPerChanWrite);
 
DAQmxWriteDigitalU16(taskHandleWrite, numSampsPerChanWrite, true, 10.0, DAQmx_Val_GroupByScanNumber, writeArray, sampsPerChanWritten, reserved);
 
DAQmxStartTask(taskHandleWrite);
 
DAQmxStopTask(taskHandleWrite);
 
Does anybody know, what's wrong?
Thanks in advance for your help!
 
Tobias
0 Kudos
Message 1 of 2
(3,411 Views)

As the third parameter of your function DAQmxWriteDigitalU16 is set to "true" (PrameterName: Auto Start?) the task starts automatically with this function, so you don´t have to call StartTask after that function.

 

Either switch the trid parameter to false, or remove the StartTask function. As the Datageneration is finite, you do not nedd to call StopTask either, because the task will stop automatically, when all data is generated. What you should do is, call ClearTask at the end of your application, so that all resources are cleared.

0 Kudos
Message 2 of 2
(3,392 Views)