From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
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?

Ed
0 Kudos
Message 1 of 3
(3,325 Views)
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:

http://digital.ni.com/public.nsf/websearch/09D80223FA84113D86256D6A004B97C3?OpenDocument
0 Kudos
Message 2 of 3
(3,321 Views)
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.

Ed
0 Kudos
Message 3 of 3
(3,319 Views)