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: 

How to turn off an LED placed inside a loop without initializing the loop

Solved!
Go to solution

Hi, everybody.

 

I am facing a problem and would be glad if anyone could help me.

 

I need to develop a program for data acquisition. In this program there are two LEDs: the Waiting and the Acquiring. When I press the button Start acquisition, the program automatically turns on the Waiting LED to let me know that the software is awaiting for my instruction to acquire data. Then, when I see that the set up is ready for acquisition, I press Acquire next data point button. This command will turn off the Waiting LED and turn on the Acquiring one to let me know that the software is processing the incoming signal. When it is ready to acquire the next data point, it turns off the Acquiring LED and turns on the Waiting one. I can break the acquisition at any moment I feel necessary by pressing the Stop button, which will cause both LEDs to turn off.

 

However, I need both LEDs to be turned off when the software finishes acquisition by itself. I don't know how to do this, since the LEDs are inside a loop that is not initialized at the acquisition of the last data point.

 

I attached a VI with an example of the problem I am facing as well as png file.

 

Thank you!

Download All
0 Kudos
Message 1 of 4
(3,170 Views)
Solution
Accepted by topic author blifo

(posting by phone, just looking at the picture)

 

Your code has way too many stacked layers. All you need is a simple state machine.

Even your sequence structure has no purpose. Also do something about that greedy inner loop.

Message 2 of 4
(3,137 Views)
Solution
Accepted by topic author blifo

You should use a state machine architecture like altenbach suggested. For your application you only need a single loop,  not nested ones.

 

The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.

 

 

All of that being said, a quick fix for you would be local variables to set the LEDs outside of that loop.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 4
(3,119 Views)

Thank you very much!

0 Kudos
Message 4 of 4
(3,084 Views)