Showing results for 
Search instead for 
Did you mean: 

high processor utilization during DAQmxReadCounterF64

Hardware: PCI-6220
Software: C++ 6.0
Driver: NI-DAQmx 7.3

This is a typical function call to get an encoder reading that is sampled on a 60Hz clock:
lStatus = DAQmxReadCounterF64(m_hEncHandle, 1, 0.25, dEncData, BUFFER_SIZE, &lEncPtsRead, NULL);

No problem getting the data. But while it is waiting for the 60Hz clock I get almost 100% processor utilization. My expectation of how this should work - my thread calls this function and it blocks releasing the processor to perform other functions until a sample clock event or .25 seconds expires (error condition). Any idea why the processor is being hogged at this point and is this the way it should act?

0 Kudos
Message 1 of 3
Hi Ed,

What you are seeing is a known feature of NI-DAQmx. DAQmx uses all available processor power to ensure that you get the BEST data acquisition performance. However, the DAQmx driver was written so that if ANY other application requests to use the processor, DAQmx will release it to the other program. This way DAQmx uses all of the processor unless something else needs it.

Check out this KB:
0 Kudos
Message 2 of 3
OK, I was not expecting this behaviour. This doesn't seem efficient so I will have to use Win32 thread synchronization objects to wait until the expected sample clock has expired. Thanks for the link.

0 Kudos
Message 3 of 3