Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

help needed: Setting up digital io using daqmx in C++

Hello,
I want to set up a test bench in C++ using a dio 6534. I need to read and write simultaniously one I-channels and five O-channels. I would like to use the DMA channels to be as fast as possible. The problem is that I'm not used to handle the DAQmx for this case and I can't find suitable examples. So, would be nice if anybody could help a little. Thanks!
Here is my attempt (which is of course not working...):
 
 
DAQmxCreateTask ("", &taskHandle);
 
DAQmxSetDODataXferMech(taskHandle, "Dev1/port0/line0:4", DAQmx_Val_DMA);
 
->error -200486: Specified Channel is not in the task.
 
DAQmxSetDIDataXferMech(taskHandle, "Dev1/port0/line5", DAQmx_Val_DMA);
 
->error -200486: Specified Channel is not in the task.
 
DAQmxCreateDIChan(taskHandle, "Dev1/port0/line0:4", "", DAQmx_Val_ChanPerLine);
 
DAQmxCreateDOChan(taskHandle, "Dev1/port0/line5", "", DAQmx_Val_ChanPerLine);
 
->error -200559: Task cannot contain a channel with the specified channel type, because the task already contains channels with different channel type.
Create one task for each channel type
 
--->I assume I need to start two separate tasks for read and write? Can I still do both operation simultaniously?
 
DAQmxCfgChangeDetectionTiming(taskHandle, "Dev1/port0/line0:4", "Dev1/port0/line5", DAQmx_Val_FiniteSamps, numSampsPerChanRead);
 
DAQmxCfgOutputBuffer(taskHandle, numSampsPerChanWrite);
 
->error: Specified property is not supported by the device or is not applicable to the task
 
DAQmxCfgInputBuffer (taskHandle, numSampsPerChanRead);
 
DAQmxStartTask(taskHandle);
 
->error -200926: Rising and Falling Edge Physical Channels for Change Detection requested are not supported because at least on of the corresponding channels is not in the task. Ensure all the corresponding are in the task or choose different channels.
 
DAQmxWriteDigitalU32(taskHandle, numSampsPerChanWrite, true , 10, DAQmx_Val_GroupByScanNumber, writeArray, sampsPerChanWritten, reserved);
 
->error -200492: Reserved parameter must be NULL
 
--->reserved was 'non touched' before...
 
DAQmxReadDigitalU32(taskHandle, numSampsPerChanRead, 10, DAQmx_Val_GroupByScanNumber, readArray, arraySizeInSamps, sampsPerChanRead, reserved);
 
->Error of Microsoft Visual C++ Debug Library: Debug Assertion Failed!
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Error at 'delete' operator
 
--->Here the programm kicks me out....
 
DAQmxStopTask(taskHandle);
 
DAQmxClearTask(taskHandle);
 
Thanks for help!
0 Kudos
Message 1 of 2
(4,352 Views)

I modified the routine a bit. I have separate tasks for read and write and so on.

I still get three errors.  Does anybody no why?

 

DAQmxCreateTask ("", &taskHandleRead);
DAQmxCreateTask ("", &taskHandleWrite);
DAQmxCreateDIChan(taskHandleRead, "Dev1/port0/line5:6", "", DAQmx_Val_ChanPerLine); 
DAQmxCreateDOChan(taskHandleWrite, "Dev1/port0/line0:4", "", DAQmx_Val_ChanPerLine);
DAQmxSetDODataXferMech(taskHandleWrite, "Dev1/port0/line0:4", DAQmx_Val_DMA);
DAQmxSetDIDataXferMech(taskHandleRead, "Dev1/port0/line5:6", DAQmx_Val_DMA);
DAQmxCfgChangeDetectionTiming(taskHandleRead,"", "Dev1/port0/line6", DAQmx_Val_FiniteSamps, numSampsPerChanWrite);
DAQmxCfgOutputBuffer(taskHandleWrite, numSampsPerChanWrite);
DAQmxCfgInputBuffer (taskHandleRead, numSampsPerChanRead);
DAQmxStartTask(taskHandleWrite);


->error -200077: Requested value is not a supported value for this property

 DAQmxStartTask(taskHandleRead);


->error -200893: Requested value is not a supported value for this property

DAQmxWriteDigitalU32(taskHandleWrite, numSampsPerChanWrite, true, 10, DAQmx_Val_GroupByScanNumber, writeArray, sampsPerChanWritten, reserved);
DAQmxReadDigitalU32(taskHandleRead, numSampsPerChanRead, 10, DAQmx_Val_GroupByScanNumber, readArray, arraySizeInSamps, sampsPerChanRead, reserved);

-> error: Here the programm kicks me out....

DAQmxWaitUntilTaskDone (taskHandleWrite, timeToWait);
DAQmxWaitUntilTaskDone (taskHandleRead, timeToWait);
DAQmxStopTask(taskHandleWrite);
DAQmxStopTask(taskHandleRead);
DAQmxClearTask(taskHandleWrite);
DAQmxClearTask(taskHandleRead);
 
Thanks for help!

0 Kudos
Message 2 of 2
(4,338 Views)