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: 

Force timed loop to execute on button press

Solved!
Go to solution

I have a timed loop which is set to execute once every hour. I would like add the option to force the loop to execute on a button press, and then reset the timer to an hour from when the button was pressed. I can't seem to find any way to make the timed loop do this, though. Obviously I could just copy the contents of the loop into a separate event structure, but there must be a more elegant way. Can anyone give me a hand?

 

Thanks.

0 Kudos
Message 1 of 5
(2,860 Views)
Assuming this code is running on a PC (which it must be if you're worried about buttons) there is no point in using a timed loop. So lose the timed loop and go with a straight-forward event-driven design.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 5
(2,852 Views)
Solution
Accepted by topic author leumg

What happens inside the timed loop?

 

You need to have another loop that will allow the timed loop itself to repeat.

 

Normally, you'd have code inside a case structure that executes whenever it gets a True from something like the Elapsed Timer Express VI.  You would just need to OR that with the button you are pressing to force the timed loop code to run early.

 

 

Post your VI so we can see what you are doing.

Message 3 of 5
(2,849 Views)

If you are in Windows, you should not be using a Timed Loop anyways.  Too much overhead for very little in return.

 

If you do not want to add the code to your event structure, then make a seperate loop with a Queue.  The timeout for the Dequeue should be your 1 hour.  Your normal event driven loop and enqueue an element to tell this other loop to run.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(2,848 Views)

Thanks all, this solved my issue.

0 Kudos
Message 5 of 5
(2,830 Views)