From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code optimization

Hey guys,

 

So i have this super simple code to time 3 led in sequence. I am quite sure that there is a much simpler and elegant way to do it. 

 

your suggestions are much appreciated.

 

0 Kudos
Message 1 of 3
(2,538 Views)

Are you teaching yourself LabVIEW?  [I'm guessing this is the case, as you (a) use a Frame Sequence structure, almost never necessary, (b) use three separate indicators instead of an Array,  and (c) don't use an Event Sequence to handle the button pushes and (optionally) the timing.

 

Note that it takes a long time to react to the Stop button -- it can take more than 10 seconds (quiz yourself to figure out why).

 

I strongly urge you to spend several hours with the LabVIEW tutorials, including those that I think are listed the Getting Started With LabVIEW box on the first page of the LabVIEW Forums.

 

Bob Schor

0 Kudos
Message 2 of 3
(2,532 Views)

You have four states: all LEDs off, LED1 on, LED2 on, LED3 On.

 

Transition between states depend on the state of the start button, the current state, and the elapsed time in the current state. All you need is a very simple state machine. No need for sequence frames and absolutely no need for value property nodes.

 

Make sure that the program can instantly react to user input at any time, so don't trap it inside long sequences.

 

See how far you get.

0 Kudos
Message 3 of 3
(2,494 Views)