LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labwindows CVI application use 100% CPU?

Hi,

 

I am using Labwindows based application and sharing data in real time Visual studio application. My visual studio application is using CPU less than 2% and I am using 400micorsecond sampling. But when I use timer of  5millisecond, Labwindows use 100% CPU resources. I want to share data from Labwindows application to visual studio at real time, less than 400 microsecond.

 

Could you anyone help me in getting rid of this 100% CPU usage? Any timer timing value below 5millisecond used in Labwindows causes 100% CPU usage?

 

If anyone knows, please reply Urgent..

Umesh

0 Kudos
Message 1 of 15
(4,970 Views)

Hi,

 

two thoughts:

 

- if 400 us sampling cause 2%, it's not surprising that at a sampling rate 80 times higher cpu load will be somewhat higher, too

- what value for sleep-policy have you set? you might try VAL_SLEEP_MORE

 

Hth, Wolfgang

0 Kudos
Message 2 of 15
(4,964 Views)

Hi,

I tried using VAL_SLEEP_MORE. But its not working.

 

Labwindows application use 100% CPU at sampling rate if I keep Timer interval to 0.001 second = 1000 microseconds.


Visual studio based real time application use less than 2% CPU at sampling rate of 400 microsecond.

 

I want to use Labwindows application with sampling rate less than 400 microseconds. But its using 100% CPU at 5 millisecond or less if GUI based Timer is used.

 

Is there any other way to get Labwindows to do data sampling at below 400 microsecond without using 100% CPU?

 

Umesh

0 Kudos
Message 3 of 15
(4,962 Views)

Umesh,

 

Here are some suggestions on improving performance.  This article also talks about processor usage in CVI.

 

Are you seeing a decrease in performance as well as the high CPU usage?

 

Hope this helps,

 

Jen W

Applications Engineer

National Instruments

ni.com/support

0 Kudos
Message 4 of 15
(4,921 Views)

Hi Umesh,

 

Can you tell us a little more about your application?

 

Which timer are you referring to, UI timer or async timer? How do you plan to achieve the 400 microsec period of timer events?

 

Do you have threads other than your "data sharing" operation? If you do, you may try to add a little sleep inside those thread loops, if possible.

 

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 15
(4,909 Views)

Dear Jen,

 

Thanks for the links, I reckon its not much useful.

 

For simplicity and your clear understanding, I am putting my problem in different way,

 

I am using Acquiredata function to collect data (around 70,000 samples). While collecting these samples CPU usage goes to 100%. I also found that, may be because of windows some high priority task, some data is not collected. I miss some of the data and it happens at around equal interval, for example I miss around 10 sample data after approximately every 600 samples data. I dont know why CPU usage becomes 100% when I try to collect 70,000 samples through Acquiredata function?

 

I am writing simple for loop for it, as shown below,

For(i=0;I<70,000;i++){

// my data collection code

}

 

could you please reply with your views.

Thanks,

Umesh

0 Kudos
Message 6 of 15
(4,907 Views)

Hi Eren,

 

I cannot use Sleep, since I share data with one more application which uses RTX and that stops me from using windows based sleep.

I am sure with UI time it is not possible to achieve the 400 microsec period, I am not sure about async timer.

 

I have 2 application, and I am sharing data among those applications by IPC. One application is developed in Labwindows with MX2/PCI/VME on windows and other application is in Visual studio with RTX- windows extension. Both applications are running on same PC and only the problem is when I use Labwindows AcquireData function and tries to write data in share memory for 70,000 samples, it writes for 70,000 samples, but the problem is it uses 100% CPU. and because of that, sometimes I miss some data. Normally I have observed it that after every 600-700 samples I get 10-20 sample missing. I think its windows high priority task may be interrupted and that may be causing data loss.

 

But I am confuse why Labwindows uses 100% CPU when I acquiredata 70,000 samples in for loop?

Is there a better way to acquiredata?

 

Thanks in adavnce,

Umesh

 

 

0 Kudos
Message 7 of 15
(4,906 Views)

Hi Umesh,

 

What type of data are you getting in that loop? Is it a single point acquisition from some other device or from an NI device? If its single point or an on demand style acquisition, you'll have to have a wait of some kind in that loop or else it will use up CPU resources as it tries to run the loop as fast as the CPU can go.

 

Thanks!

Chris T.
0 Kudos
Message 8 of 15
(4,855 Views)

Hi Chris,

 

You are 100% right about my scenario. In my loop, I am writing data to shared memory, which is created in real time system (RTX ). I am just writing one value whose data type is double.

I agree that I need to wait for some time. Could you suggest some quick fix?

 

Sleep is not working as I use RTX, windows sleep will not work so as asynchronous timer.

 

Umesh

0 Kudos
Message 9 of 15
(4,828 Views)

LabWindows/CVI Real-Time Module has a library that includes real-time sleep functions. Check out the SleepUS function in the Real-Time Utility Library.

National Instruments
0 Kudos
Message 10 of 15
(4,786 Views)