LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To Reduce execution time of a loop

Hi all,

I am working on a real time application developed using Producer Consumer Design pattern in LabVEW 2013. I am working on reducing the execution time of the application. At present the application is taking a total of 1s consdering all the 4 while loops.  Can anybody suggest me on how to go ahead with the best possible way to reduce it to 10ms?

Regards,
KM
0 Kudos
Message 1 of 11
(4,506 Views)

Hi kamasani,

 

The way to reduce execution time is to use Timed Loop VI using deterministic configurations. 

 

Please attach your screenshot so we can help identify how you can reduce the time.

 

157+ CLDs & 9 CLA Trained
LabVIEW Training resources
0 Kudos
Message 2 of 11
(4,498 Views)

Hi Ram,

Thanks for your valuable feedback,due to security  reasons i cannot attach the screenshots at the moment. To brief you about the application, I am using 4 while loops, and im using queues for passing data b/w the loops, each loop takes its own time for execution. Should i go ahead by replacing all the while loops with timed loop? I am confused, since i am a beginner with LabVIEW.

I need your valuable inputs on this.

 

 

Thanks,

Manjunath Kamasani

Regards,
KM
0 Kudos
Message 3 of 11
(4,482 Views)

Hi Kamasani,

As I assume, you are talking about the user interface VI in desktop computer rather than RT VI.

 

Do you have any timing VIs such as Wait (ms) or Wait until Next ms Multiple in any of the loops?

 

In RT systems, you usually need Wait (ms).VI only in a monitoring loop which reads data using the shared variables into the user interface VI from the RT VI.

 

Connect the 10 to the wait (ms) as you require as this will ensure that the monitoring loop will not use maximum resources of the CPU.

 

Remove all other timing VIs. You do not require timing in other loops other than monitoring loop.

 

 

 

157+ CLDs & 9 CLA Trained
LabVIEW Training resources
0 Kudos
Message 4 of 11
(4,473 Views)

This really is impossible to help with without seeing your code.

Replacing while loops with Timed Loops will not help. Timed Loops are used for slowing while loops down in a controlled manner. You would use them to synchronise with a clock rate, and can set other parameters for priority and CPU allocation etc. These will not likely help to reduce your execution time.

 

If you are seeing code execution of 1 second then you will need to optimise your code to reduce the execution time. There are LabVIEW guides on how to improve your code execution time, just search around for them.

 

Also try using the Profiling tools to learn which VIs (I presume your code is componentised and each while loop contains subVIs?) are hogging the most CPU time.

 

If you cannot share your VI then there it is very hard to know where your code execution bottlenecks are.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 11
(4,456 Views)

To add: you should not use queues on RT except you dont need determinism.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 11
(4,435 Views)

WIth no code to see the following can be advised in general ...

 

 

 

IF your app is displaying any data to the front panel from inside the loops it will be slowed down considerably.

 

IF any of your loops depend on I/O from hardware (DAQ  SErial, USB, etc) the timing of it will alter the loop interval.

 

Any file reads or writes will slow loops to a crawl compared to being outside the loop and done at the end.

 

Any large data transfers especially string reads or concactenations (excuse mispelling)  will slow things down.

 

You can get some idea of execution time for each loop using simple wait mS timing functions Take a mS timer output before the loop than aftet eht loop and subtract them to find delay in mS.

 

 

 

 

 

0 Kudos
Message 7 of 11
(4,407 Views)

Also, are there any subVIs in common between the loops?  If so, you need to make those subVIs re-entrant otherwise they will execute one after the other.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 11
(4,375 Views)

Hi all,

Thanks for your valuable inputs,

I apologize for not being able to share the code with you guys.

To make it clear:

I am talking about the UI developed on a desktop computer

USB data acquisition mode is being used for acquiring spectrometer data into the LabVIEW platform

Wait(ms) is used in all the loops to calculate the execution time.

Data is displayed on the front panel from inside the loops.

Queues are used for transfer of data btw different loops.

Multiple VIs are being used in all the while loops.

 

I will look into the LabVIEW guidelines for improving the execution time and i will use the profiling tools to know about time consumption.

 

Apart from this if there is anything i need to do to improve the performance. Please do help me:)

 

 

 

 

Regards,
KM
0 Kudos
Message 9 of 11
(4,360 Views)

Wait(ms) pauses execution. It does not calculate execution time.

0 Kudos
Message 10 of 11
(4,343 Views)