Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DAQmxRegisterDoneEvent() function for digital tasks?

Hello, In one of my VC++ application that makes use of DAQmx driver, I am trying to use event based callback functions. I tried using the sample application that comes with the installer "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Events\Done\Mult Volt Updates-Int Clk-Done Event", where it registers a callback function that gets executed automatically when the analog write operation is done, and it worked fine. In my application there is a need to have a callback function that gets executed automatically whenever the digital write task is done. Since in DAQmx help document it is not mentioned that DAQmxRegisterDoneEvent () API can only be used with analog tasks, I thought it would work the same way with digital tasks as well. When I try setting the clock source using DAQmxCfgSampClkTiming () function for the digital task, it throws the error "Requested value is not a supported value for this property". If I continue executing the remaining statements, everything else gets executed without any error/warning but the callback function does not get called. I am using E-series 6713 DAC instrument. Is there something missing or some bug in the code itself? Code snippet I am using:                 // Call back functionint32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 iStatus, void *callbackData)                {                                status = DAQmxStopTask(taskHandle);                }                                // Main function                unsigned char data[] = {0,0,0,0,0,0,1,1};                status = DAQmxCreateTask ("",&taskHandle);                status = DAQmxCreateDOChan(taskHandle, "Dev1/port0/line0", nameToAssignToLines, DAQmx_Val_ChanPerLine);                               sampsPerChanToWrite = 2;                 // Throws error "Requested value is not a supported value for this property".                status = DAQmxCfgSampClkTiming (taskHandle,"P0.0", 1.0, DAQmx_Val_Rising,                                                                 DAQmx_Val_FiniteSamps, sampsPerChanToWrite);                 status = DAQmxRegisterDoneEvent(taskHandle, 0, DoneCallback, NULL);                 status = DAQmxStartTask(taskHandle); sampsPerChanToWrite = 1;status = DAQmxWriteDigitalLines (taskHandle, numSampsPerChanToWrite, autoStart,                                                                                 timeout, dataLayout, data, &sampsPerChanWritten, NULL); If there is a bug in the above code, please send the correct sequence of apis to use the Done event for digital tasks. Any help would be greatly appreciated.

 

Regards,

Harish

0 Kudos
Message 1 of 2
(2,759 Views)

Please ignore this post since it is in a weird format and visit below link:

 

http://forums.ni.com/ni/board/message?board.id=250&message.id=49782&query.id=20717#M49782

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