From 08:00 PM CDT Friday, August 12 - 01:00 PM CDT Saturday, August 13, ni.com will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write and read on PCI-6509 ( C++ )

Hi !
I'm using NI DAQ mx Driver with a pci-6509 board.
I'm able to read or write on port lines ( using change detection ), but when i do this, I use 100% of my CPU ressources !!!

This is my C++ code :

DAQmxCreateTask("",&taskHandle);
DAQmxCreateDIChan(taskHandle,"Dev1/port0/line0","",DAQmx_Val_ChanForAllLines);
DAQmxCfgChangeDetectionTiming(taskHandle,"Dev1/port0/line0","Dev1/port0/line0",DAQmx_Val_FiniteSamps,1);

DAQmxStartTask(taskHandle);
for (;;)
{
data[0] = 0;
DAQmxWaitUntilTaskDone (taskHandle, -1);
ii = DAQmxReadDigitalLines (taskHandle,1,DAQmx_Val_WaitInfinitely,DAQmx_Val_GroupByChannel,data,sizeof(data),&numRead,&bytesPerSamp,NULL);
etat = data[0];
DAQmxStopTask(taskHandle);

}
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);

Is this the correct way for perform change detection, and why I use 100% of CPU time when I read line state ??

Any help would greatly be appreciated.
Thank you for your reply !
Val
0 Kudos
Message 1 of 2
(2,332 Views)
Sorry for my stupid question !
-> In fact, the task must be started before read or write operation and stoped after !
Now, I use less than 3% CPU ... Enjoy 😉
0 Kudos
Message 2 of 2
(2,332 Views)