01-12-2007 08:50 AM
DAQmxCreateTask("", &taskHandleRead);
DAQmxCreateTask("", &taskHandleWrite);
DAQmxCreateDIChan(taskHandleRead, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);
DAQmxCfgChangeDetectionTiming(taskHandleRead,"Dev1/port0/line0", "Dev1/port0/line0", DAQmx_Val_FiniteSamps , numSampsPerChanRead);
DAQmxSetDIDataXferMech(taskHandleRead, "Dev1/port0", DAQmx_Val_DMA);
DAQmxCfgInputBuffer(taskHandleRead, sampleBuffer);
//DAQmxCfgDigEdgeStartTrig (taskHandleRead, "/Dev1/PFI2", DAQmx_Val_Rising);
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);
DAQmxWriteDigitalU32(taskHandleWrite, numSampsPerChanWrite, false, 10.0, DAQmx_Val_GroupByScanNumber, writeArray, sampsPerChanWritten, reserved);
DAQmxStartTask(taskHandleRead);
DAQmxReadDigitalU32(taskHandleRead, numSampsPerChanRead, 5.0, DAQmx_Val_GroupByScanNumber, readArray, arraySizeInSamps, &sampsPerChanRead, reserved);
DAQmxStartTask(taskHandleWrite);
DAQmxWaitUntilTaskDone(taskHandleWrite,10.0);
DAQmxWaitUntilTaskDone(taskHandleRead,10.0);
DAQmxStopTask(taskHandleWrite);
DAQmxStopTask(taskHandleRead);
DAQmxClearTask(taskHandleWrite);
DAQmxClearTask(taskHandleRead);
01-15-2007 06:45 AM
01-15-2007 09:54 AM
Hi Mona,
thanks a lot for your answer! I can't start the task for 'write' before calling 'DAQmxWriteDigitalU32'. Otherwise I would get error -200462: "Generation cannot be started, because the output buffer is empty.". In my first attempt I did it the other way around, but because of a hint of NI I changed it like it is now.
For my application, programing an SPI bus, in some cases I generate the clock with the 'write' command and use this in parallel for change detection at the 'read' command. Hence I want to use the multithreading capability of the DAQmx driver, similar to traditional DAQ driver. Implementing 'read' and 'write' in a loop would be a sequential procedure.
Regards
Tobias
01-16-2007 07:16 AM
01-16-2007 07:51 AM
Hello Mona!
Thanks for your reply.
I do not see the multithreading in the example. The way I understand the example, syncronising means sycronised by a timer tick of CVI. After a tick the digital and the analog channel are read sequentially. I'm developing my application in .NET 2003/C++. Thus I don't have a timer and I need to apply the onboard clock of the 6534 card for the 'write' functionality. But if I want to use a clock generated by the 'write' for the 'read', it can only work if 'read' and 'write' run in two independed threads!
So, I'm missing this capability I had at the traditional DAQ driver. The description of DAQmx says it's possible. But I can neither find Examples nor any instructions...
Regards Tobias