LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple LED question from a beginner.

Solved!
Go to solution

I have two identical while loops in series.  Each as a timer and a timer-expired LED indicator.  When I run, the first LED lights and then the second LED.  When I re-run, the first LED resets and the second LED stays lit.  Once the first while loop completes, then the second LED resets and eventually times out and lights.  How can I get both LEDs to reset immediately at run time?

0 Kudos
Message 1 of 19
(4,891 Views)

For the second led create a local variable, change it to write, place it before both while loops and wire a false (booleon) to it.21932iBDFC3215F8C126E5

0 Kudos
Message 2 of 19
(4,885 Views)

Hope this helps

-------------------------------------------------------------
kudos welcome
0 Kudos
Message 3 of 19
(4,858 Views)

Having while loops in series is often a sign of poor program design. Better would be a single loop designed as a state machine. Now none of this extra code is needed.

 

Can you show us your program?

0 Kudos
Message 4 of 19
(4,835 Views)
Solution
Accepted by Dark Hollow

 


@Dark Hollow wrote:

How can I get both LEDs to reset immediately at run time?


There is also an execute option called "clear indicators when called". That might be all you need.

 

Message 5 of 19
(4,832 Views)

Using Local Variables is BAD ADVICE.

There is no need for it.

 

As Altenbach suggested, using a state machine with shift registers is the appropriate way to go.

There are plenty of examples on this forum that shows what you want to implement.

Some of these examples were written by the top contributors to this forum and show appropriate implementation of the code.

 

The state machine would have a reset state that resets all LED values at once.  The new values would be written to the the wire (which is the variable in LabVIEW) and passed to the beginning of the next iteration through the shift register (right click on edge of loop and select it).  You can update the display immediately after the state completes at the right of the Case Structure, or if you want to get fancy, you can have a refresh display state that is triggered by time or other events and you can refresh the display after several states have been executed.  There is no limit to how creative the code can be, as long as it is done right.  😉

0 Kudos
Message 6 of 19
(4,809 Views)

 


@omprakash wrote:

Hope this helps


 

What the heck is this?  This is not a solution for what the person is asking?  Why have a loop if it either stops at the first iteration if LED is FALSE?  And once you set the value for LED2 it will not reset unless you stop and run the VI again.  Nevermind the fact that the second loop will also stop as soon as it is FALSE, which is what the value will be when the first loop ends.  Did you try running your example?  It's really useless..  Try running it.  Learn from it and try to understand the dataflow by first running it and repeating the execution with highlight execution turned ON.

 

 

Message 7 of 19
(4,807 Views)

Lots of great ideas.  Thanks to all.  This one is the best for my application.

0 Kudos
Message 8 of 19
(4,803 Views)

By "this one," I meant the "clear indicators when called" option.  Simple and direct.  Thanks.

 

FYI, my application is not using serial while loops.  I just used that as a simple example to demonstrate the LED reset issue.

0 Kudos
Message 9 of 19
(4,794 Views)

@Ray.R wrote:

Using Local Variables is BAD ADVICE.


I agree that it's bad advice in general. However, Viper's idea is a valid one - in general - maybe not for this application. One of the (few) appropriate uses for Locals are at the beginning of a program for initialization. I still would not advise the use of Locals, the same way I would not advise my son to drink beer, even though I do.

Richard






0 Kudos
Message 10 of 19
(4,772 Views)