Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI DAQmx 8.3 and CPU usage

I have similar problem as described on page http://forums.ni.com/ni/board/message?board.id=250&message.id=23831
but have solution and some reflections.
first of all, about system
system use 2x PCI-6143 and take data from 16 channels with maximum rate (250 kS/s)
program was created about year ago (with LV 7.1.1, DAQmx 7.4) and on PC with PIV (3.2 GHz) processor and 1 Gb of RAM work properly (CPU usage less 30%).
Now I've recompile program with LV8.2 and update drivers to DAQmx 8.3. now program can't work properly because CPU usage 100%

I create test VI for research this problem.
First version (daq_test1) - simple code - configure daqtask and get data.
I found:
if sample rate less or equal 90 kS/s (on PCI-6143) CPU usage less 5%, but when rate more 95 kS/s CPU usage jump to 60% (for one or more channels on one or two devises).
Then I create simulated devise PCI-6143 in MAX and the same vi (daq_test1) require not more than 5-10% of CPU.
also I have examine devise 16E-4 and find the same problem: if samle rate more than "boundary" rate, CPU usage is too much (50-70%).

Then I add configure parameters (daq_test2) - add manualy DMA "on". There are no effects (CPU usage jump to 60% on "fast" rates)

Then I  "play" with WaitMode (daq_test3). There are no effects (even if WaitMode=Sleep and SleepTime>1s CPU usage about 60%)

Finally I create vi (daq_test4), where "manually" check AvailableSamplesPerChannel and call DAQmx Read only when bufer has more samples, that I need.

So I'd wound solution, but think driver MUST check available samples carefully (also, why DAQmx 7.4 can fast scan, but  DAQmx 8.3 can't do it at least the same way as previous version).
0 Kudos
Message 1 of 6
(3,755 Views)
Artem,

Thank you for contacting National Instruments support.  This is expected behavior. When the wait mode is set to Sleep, DAQmx will only sleep if and only if there is no data available to process. So, for example,  at 200 kS/s, data is filling up the buffer fairly quickly and should always be available to read, which means that the process will not sleep at all. When data is always available, the CPU is going to handle it as quickly as possible and thus the CPU will appear to be running at near 100%.

Specifying a wait mode of Sleep is really only beneficial when the acquisition is running slowly enough that a lot of time is spent in DAQmx Read waiting for the data to arrive. In the past, the CPu was maxed out even at extremely slow sampling rates.  Sleep mode alleviates this problem by putting the process to sleep when no data is ready for processing; however, if data is available, it will be handled immediately and no sleeping will occur. If data is constantly available for processing, the CPU is expected to deal with it right away and the usage will appear to be high.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 6
(3,724 Views)

Hello,

I just try to set up my system so that I get 1000 samples/s, always the actual aquired values, and without high CPU usage. Quite a simple task.

On the schreenshot you can see how I set up my channels. With this setup I get the values at low CPU usage. It is cool! But I just don´t understand what WaitMode=Sleep and SleepTime mean? In the helpfile stands: "Check for available samples once per the amount of time specified in SleepTime".

Does it mean, if I query a read from my task, it will pull the data only once a second? If I set SleepTime=0, I get the same (I hope the same...) data as at SleepMode=1sec, but the CPU usage is 100%.

So can anybody describe, how does WaitMode=Sleep work?

Thanks in advance

MB

0 Kudos
Message 3 of 6
(3,445 Views)
MB,
 
Your definition of wait mode is correct, if sleep is set as the wait mode then the DAQmx Read will check for available samples once per the sleep time.  As Kenn N. had stated in his post, this sleep mode will only function if there are no samples available in the buffer.  I would recommend looking at Kenn's post again if you have further questions about this.  For example, if you are filling the buffer continuously at a high rate, the sleep will never take effect because there are always available samples.  I have attached a piece of sample code which utilizes this wait mode for a finite acquisition.  If you change the the sleep time on the block diagram, you will notice that the samples take longer to graph due to the wait.  Basically, if no samples are available then the Sleep will take effect and the process will be put to sleep for a specified amount of time.  Hope this helps! 
0 Kudos
Message 4 of 6
(3,414 Views)

Hi,

I would accept your explanation, but if I set SleepTime=0.1, then the CPU usage is low. When SlepTime=0, then 100%...

This is what I don´t understand.

regards

MB

0 Kudos
Message 5 of 6
(3,401 Views)

MB,

By placing SleepTime as 0 this means that the process will not sleep at all. This implies that the CPU is going to handle the data as quickly as possible and the usage will appear to be 100%.  By having some kind of sleep value (.i.e. .1) you will have given the CPU a chance to rest or process other tasks. 

0 Kudos
Message 6 of 6
(3,376 Views)