LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV7 application running "very slow"

Hello everybody!

I'm reading a lot of posts about applications running "slow". I'm experiencing the same problem but mine is likely to be a code problem, rather than the hardware.

Here's my problem. The attached file has a application that reads data from a WAGO system to control temperature.

I've made the application in my notebook (PIII 900MHz) and the CPU usage is about 70%. But the application is to be applied to a PII 450MHz which obviously boosted the CPU usage to 100% (I see it because of the time display in the application: the clock stops...Smiley Happy)

My question: I know that I use a lot of local variables because a need them and two or three loops, how can I optimize my application without changing the PC.

Thanks in advance
0 Kudos
Message 1 of 6
(3,296 Views)

Put a wait(mS) in the two loops out to the left.  This should improve your CPU utilization.  Frankly I do not see how this application stops, unless you hit the LabVIEW stop key.  Also, depending on the speed of execustion of the primary while loop inside your main loop, you may want to put a wait statement in. 

These should help.  Actually there is a whole lot that can be improved but try putting those two wait statements in and see what happens.


Paul
0 Kudos
Message 2 of 6
(3,288 Views)

I made a small change to your VI.  Utilizing an event structure.  This should improve your CPU usage issue.  Not sure if it will be the cure but it should help.  Additionally, when you hit the exit key, the VI will stop now, however your values will NOT be written to the ini files after that event.  The language issue is hindering my ability to help as I am not sure what everything does, but heck...every little bit helps.

See attached.


Paul
0 Kudos
Message 3 of 6
(3,275 Views)


@nasps wrote:
My question: I know that I use a lot of local variables because a need them and two or three loops, how can I optimize my application without changing the PC.

No, you don't need them!
 
For example, let's have a look at your subVI named carregar dados.vi:
 
 
There is NO reason to have local variables and property writes in this case and the same applies to most of your other code! I Bet that your entire code could be rewritten wuthout using a single local variable.
 
Your code is basically duplicated 7x in many places, it probably could be simplified to fit a single small screen if you would re-use your code.
 
I agree with Paul, that pacing is one of the problems. None of your loops have any wait statement. This means that each loop spins many times until it releases control to another loop, making everything appear sluggish. You need to write all these properties on the right only when the button changes, and not millions of times/second. Proerpty writes are relatively expensive.
 
Let's look at your big loop on the right:
  1. The inner while loop has no function at all, it always stops after one iteration.
  2. All seven calls to save.vi don't do anything, because the boolean input is not wired.
  3. You have major dataflow issues, mostly because of overuse of local variables. For example there is no guarantee that all the clusters are written on the left outside the loop before they are read inside the loop.
  4. ...

Personally, I probably would make one nice cluster corresponding to one of your seven channels, then place it inside an array of size seven. It would really simplify things. Use a shift register to keep the current state.

Message Edited by altenbach on 11-22-2005 09:47 AM

Message 4 of 6
(3,253 Views)
Thank you Paul and Altenbach!

You have been most helpful, because with your tips I've re-designed some parts of the code.
I'm still very "fresh" in LabVIEW programming so I realised that sometimes in programming to go fro "A" to "B" i go to "A1...A2...A3...A4" instead of directly to the problem...Smiley Wink

I'm already working on that.

Thanks for your help. Keep up the good work

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

Very nice Altenbach.

You deserve multiple stars on that one.

Very nice & clean vi.  🙂  ... and right on the $$..

Message 6 of 6
(3,211 Views)