LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timeout or turn on/off LED

I'm looking for some advice on the best practice to structure this type of operation...

 

I have a main vi that allows the user to select an LED to illuminate (physical LEDs, not virtual).  This will work by the main vi calling a sub vi that is responsible for controlling the LEDs.

 

I want the LEDs to operate in the following method:

1. User selects LED to turn on...that LED turns on

2. LED will turn itself off (timeout) if a period of time passes (time set by user in main vi)

3. If user selects a different LED to illumininate, the previous LED will shut off, and the selected LED will turn on.  I want this to happen even if the timeout of the previous LED hasn't occured yet.

4. Timer resets

5. Rinse and repeat 🙂

 

Thanks! -Mike

Message 1 of 16
(4,378 Views)

If you are using a version of LabVIEW with event structures I would put the LED selection in one loop, the actual LED control in a parallel loop, communcating via queues or functional globals, in a "produceer/consumer" style (look at the built in LabVIEW examples). Then the vi controlling the physical LED can keep track of the timeout, etc. I don't know how you are controlling the LED's, a digital output? The actual controlling vi would probably be a state machine that has states for changing the on/off state of the LED, keeping track of the timeout for the currently on LED, etc.

 

 

Message Edited by LV_Pro on 06-17-2010 10:29 AM
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 2 of 16
(4,371 Views)

I'm using LV2009, so yes, I have access to event structures...

 

Are you saying the main vi would have two parallel while loops?

 

The main vi output a number, which correpsonds to an LED...

 

I'll start on the state machine.  Anyone know of any examples like this?

 

-Mike

Message Edited by KSU Flyer on 06-17-2010 09:35 AM
0 Kudos
Message 3 of 16
(4,365 Views)
How do I get Labview to not wait on the wait function to timeout before it will let me continue?
0 Kudos
Message 4 of 16
(4,346 Views)
Don't use the wait function.  Use the Elapsed Time function.  Put it in a loop.  Use an OR fucntion to stop the loop.  Stop the loop when either the Elapsed Time has expired OR the user presses a button that is supposed to override the timer.
- tbob

Inventor of the WORM Global
Message 5 of 16
(4,326 Views)
I was hoping you would chime in tbob!  You're awesome...working on it now, will let you know how I do.  -Mike
0 Kudos
Message 6 of 16
(4,321 Views)

If you post your code and explain your problem, I'll be glad to help.

 

- tbob

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

tbob wrote:
Don't use the wait function.  Use the Elapsed Time function.  Put it in a loop.  Use an OR fucntion to stop the loop.  Stop the loop when either the Elapsed Time has expired OR the user presses a button that is supposed to override the timer.

Another great use for the elapsed timer function!  But you could improve the code just a bit (to add expandtion capabilities) by adding a third loop and a second queue!

 

I'll post a mock-up in a bit- but I'm thinking a UI loop- firing event driven commands to two consumers> an LED control (simply runs the hardware task) and a timer control loop (start timer- reset timer.  this loop would also enqueue a command for the LED control loop on a when timer expires.-  and you CAN use the TIMEOUT event wnd move the timeout value by adding the timmeout value as a component of the queue

 

Neat?

 

 

Message Edited by Jeff Bohrer on 06-17-2010 12:10 PM

"Should be" isn't "Is" -Jay
Message 8 of 16
(4,299 Views)
Here's a snippet showing an example of the Timer loop and the LED loop- the UI loop is pretty straight forward but I've gotta get to work!two loop timer.png

"Should be" isn't "Is" -Jay
Message 9 of 16
(4,292 Views)

And - just for fun a completed example- just replace the task!

 

Odd- when creating a snippet the cluster elements are deleted!  so no snippet

 


"Should be" isn't "Is" -Jay
Message 10 of 16
(4,269 Views)