LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use Timer as an event

Solved!
Go to solution
I have an event structure in labview 8.2 where when a value is changed, elapsed time begins counting and a command is sent to open a shutter via a serial connection. When this countdown timer gets to zero i want it to close the shutter. The event structure I have is attached but I know it isnt working because the timer is only recognized when there is a value change. This is a bit confusing to describe so I have attached my VI. To recap, basically I want a timer to start when a button is pressed, so its put in an event structure and then I want another event to execute when the timer hits zero. I know why my code wont work, I just don't know exactly how to fix it 🙂 Help is much appreciated.
0 Kudos
Message 1 of 11
(10,151 Views)

Put the elapsed time Vi in the Timeout event case.

 

It might be better to use a Producer/Consumer (events) structure if you may be adding more features and events to your program.

 

Lynn 

Message 2 of 11
(10,143 Views)
If i put the countdown timer it in the timeout case, wont it start counting down whether or not there has been a value change to the exposure time boolean? I only want the countdown timer to start after there has been a change to the boolean. Also, sorry for the bad code, i open my visas in the while loop 😞 but its not worth uploading again.
0 Kudos
Message 3 of 11
(10,116 Views)

Code up your own timer.  Put close time in a shift register when the boolean changes.  At each pass through the timeout case compare the current time to the close time.  If current time is greater than or equal to the close time, close the shutter.  You need to think about what it does before the  shutter is opened.  Perhaps track the shutter state and only do the time check if the shutter is open.

 

This involves polling rather than an event, but it consumes very little CPU time.

 

Lynn 

0 Kudos
Message 4 of 11
(10,111 Views)
Solution
Accepted by topic author GregFreeman
Would the attached vi work for you?  It uses the Timeout case as your elapsed timer.
Randall Pursley
0 Kudos
Message 5 of 11
(10,104 Views)
Added a timer in a seperate VI, see the attached. Many ways to do this depending how you want it your final result.
0 Kudos
Message 6 of 11
(10,099 Views)
thanks rpursley. I think your solution is what I need. And thanks to everyoen for the quick responses. These forums are great 🙂
0 Kudos
Message 7 of 11
(10,096 Views)

Btw, for Pursley case and yours other Events would cause the event structure to fire (should you add anymore event cases) and cause the timer to reset...the countdown.

 

My case the timer runs exclusive of events once an event is fired. Two out the many ways to do this....

Message Edited by richjoh on 10-28-2008 02:28 PM
0 Kudos
Message 8 of 11
(10,059 Views)
Thanks Rich, I actually noticed this too and I will be adding other events so I will try your solution also. I did get something to work myself using an event structure with a countdown timer in a case structure after it so when the booleans true it runs the timer but I am always looking for cleaner options as mine is a bit messy. I will try it when im at work tomorrow. Thanks.
0 Kudos
Message 9 of 11
(10,052 Views)

richjoh wrote:

Btw, for Pursley case and yours other Events would cause the event structure to fire (should you add anymore event cases) and cause the timer to reset...the countdown.


You can easily code around that. See my old example from mid 2005 (original thread)

0 Kudos
Message 10 of 11
(10,033 Views)