LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is there a better way to optimize this VI's speed/performance/look?(lots of cases with lots of selects)

Hello all,

 

I have a VI our lab is using to control all sorts of measurement instrument. and the basic way it works is having a huge while loop, and inside, case structure of about 42 different cases. and many more booleans connected to "selects" which select either 0 when that specific boolean is off and select a unique number when it's on. so when i press e.g. "Start Measurement Type II" boolean, it will be the only boolean pressed and sending a number 35 to the case structure and that one is excuted. (i hope that made clear enough sense).

 

so every loop the program needs to look through every single boolean there is and the block diagram is just messy like helll. it works perfectly fine obviously, but just wondering if using something like event structure would optimize this vi? or it'll just be the same idea? btw, the booleans are all latched.

 

 

thank you all!  

Message Edited by northPIG87 on 09-29-2008 02:39 AM
0 Kudos
Message 1 of 7
(4,203 Views)
attached is the screen shot..forgot last time.
0 Kudos
Message 2 of 7
(4,201 Views)

Yes, using a Event Structure will improve your code a lot. It's not so much about performance, but about readability and scalability.

It would be the first todo when I would be handed the code over for whatever...

 

Felix

0 Kudos
Message 3 of 7
(4,175 Views)

thank you felix! one quick question since ive never used event structure: what's the best action to choose for latched boolean buttons? (key down, key up, mouse down..blablabal)

 

0 Kudos
Message 4 of 7
(4,147 Views)

northPIG87 wrote:

 what's the best action to choose for latched boolean buttons? (key down, key up, mouse down..blablabal)

 


Choose "Value Change".

Its the last in the options.

0 Kudos
Message 5 of 7
(4,141 Views)

As said in the post above: Value Changed.

Some more guidlines:

* You should place each Boolean in the corresponding Event

* You can make an Event Case for more than one button using add event (+ Button) in the edit Events Dialog

* The stop button (or whatever) will be wired from inside the Stop button Value Changed Event to the Stop Terminal of the surrounding while loop; the tunnel can be left as 'Use default if unwired from inside'.

* If there is more than one Action performed for one button or there is the same Action repeated for several buttons, but not all code is equal: Consider using a state machine; You could use an event driven state machine, but I think this is a bit of an overkill; You simply put the Event structure in the 'Idle' State and most of the events will directly go in the idle state; some of the events pass through other states, such us 'Update Graphs' for example. If this suggestion raises to many questions for you, skip it, you can give it a try later being more familiar with LabView Events and your program.

* I would replace all property nodes 'Value' with local variables at least, much better is the use of wires though.

 

Felix

0 Kudos
Message 6 of 7
(4,131 Views)
You are trying to put all functionality into one vi.  This is way too much.  Learn how to use subvi's.  Your main vi should have intialization code, an event structure, and cleanup code.  In the event structure, when the user presses a button, that event case should simply call a subvi.  Put the code needed into the subvi.  This would make you code a lot easier to read and understand.
- tbob

Inventor of the WORM Global
Message 7 of 7
(4,073 Views)