LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I force a routine every 5 seconds, but still have my event structure available when the routine isn't running??

I currently have an event structure to respond to user input. When the user presses buttons (etc...) it generally sends a signal down the serial line. However, I must force a routine to run every few seconds (it can wait, if necessary, for a function in the event structure to complete). This routine will be using the serial port as well.

Is there a way to have the "focus" on the event structure, but break away every 5 seconds to run a specific function??

Thanks for any help,

Russ
0 Kudos
Message 1 of 8
(5,230 Views)
Couldn't you just use the timeout event with a timeout of 5000 for your function?

(Of course if you constantly press buttons, it will never happen. You could dynamically monitor the elapsed time since last timeout event, then adjust the remaining timeout via a shift register in all non-timeout events. For example if 4 seconds have passed since the last timeout, the timeout for the event structure should be set to 1000, if any other event occurs etc.)

Message Edited by altenbach on 05-12-2005 12:15 PM

0 Kudos
Message 2 of 8
(5,223 Views)
Thank you, altenbach. I didn't even know there was a timeout function available. I'll give it a try!

Russ
0 Kudos
Message 3 of 8
(5,211 Views)
You could also have the serial VIs in a seperate loop and feed it using a queue. Then, have another loop which will insert an element into the queue every 5 seconds. This has the advantage of not having to calculate and not having to handle every case in the event structure.

___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(5,206 Views)
It is probably easier to do the dynamic timeout handling outside the event structure to keep things simple and not clutter every single event case. We also need to make sure that negative timeouts don't occur (e.g. if one of the other events takes a very long time). The attached modification (LabVIEW 7.0) incorporates these changes. 🙂
Message 6 of 8
(5,191 Views)

@altenbach wrote:
It is probably easier to do the dynamic timeout handling outside the event structure to keep things simple and not clutter every single event case.

An updated, even cleaner version has been posted here.

 

altenbach_0-1582145633110.png

0 Kudos
Message 8 of 8
(3,112 Views)