LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create event driven timer

Hi everyone,

I am having a similar problem creating a event driven timer.  I need to make it so that the timer starts when a specific situation is true and the timer must stop when the same situation is true again (second time). I've attached the statement that must be true for the timer to start and stop (filtered value must be greater than 0.0005). It would also be nice to be able to directly specify how many times this event has to be true after the first one for the timer to stop. It seems like I should be able to mix one of the codes that has been provided for the timer with mine but I'm new at LabView so I'm having a really hard time. I would appreciate your help.

0 Kudos
Message 31 of 56
(3,179 Views)
Use a case structure.  Increment an integer every time the event is called, and set up your cases.  If it may be running for a while, something like divide the counter by 3 and pass the remainder would also work.


Message Edited by JeffOverton on 01-11-2008 01:24 PM
0 Kudos
Message 32 of 56
(3,177 Views)
Wouldn't this add a second everytime my value is above 0.0005? I just need a timer in seconds that starts when the value is above 0.0005 and stops when the value is above 0.0005 again.
0 Kudos
Message 33 of 56
(3,167 Views)

I'm sorry, I wasn't clear.  The incremented counter is to keep track of how many times your value has been greater than .0005.  Then, based on that counter, you can take clock time.  I recommend using Tick Count (under timing) outside the while loop to establish your starting time, and then another Tick Count inside the while loop to show the current time.

And I'm still fairly new, so I may be wrong about this, but LV's case operation operates in fractions of milliseconds, so I don't think you have to worry too much about your accuracy, especially if your other option is a control.

0 Kudos
Message 34 of 56
(3,159 Views)
What if the time is in the order of seconds.. would the tick count still work?
0 Kudos
Message 35 of 56
(3,138 Views)
The tick count returns milliseconds, so if you want 5 seconds to go by, wait until the tick count difference is 5000
0 Kudos
Message 36 of 56
(3,126 Views)
I want to start by thanking your for your help, I really appreciate it. I'm a college student working on my undergrad reseach and it's been really helpful.
 
Anyways, I have the loop working properly. Now the only problem is that the signal I'm getting starts at zero and curves up to a max, stays there for a while and then comes back down and stays at zero untill the next signal. Using my logic of > 0.0005 it keeps on adding  number of sensors it has detected throughout the whole curve instead just taking the whole curve as one single signal. I'm trying to make it so that as soon as it detects an increase in the signal it takes it as one sensor and waits until the next increase in signal to add another sensor. Also, is there a way so that it registers the time at which it went through each sensor? 
0 Kudos
Message 37 of 56
(3,119 Views)
Don't worry about it, I actually just graduated in August, so I know how it is.  The only thing I can think of would be to compare the current and last data point, and if the current point is >= .0005 and the last is < .0005 you know you hit a transition.  Also, look into the Timing Palette for all your timing needs.
0 Kudos
Message 38 of 56
(3,105 Views)

Firstly, you should not have to use the 'Abort.vi'

 (like pressing the abort button).
If that is the only way to stop your vi then you have done something wrong.

From what I can tell, you are only measuring one channel? Is that correct?
So then the labels 'Number of Sensors' & 'Sensor #' are a bit confusing. Perhaps 'Number of Triggers' and 'Trigger #' might be more accurate.

The way that the vi currently functions, every time the last value in the filtered signal is greater than 0.0005, it will increment the count.
This does not seem to be the functionality you desire.

Perhaps one way to get the data you require would be to create an array of time stamps corresponding to the times when the trigger condition is met.
Then you can do what ever you want with all the trigger time data collected. See block diagram below...

This is how you could configure the trigger parameters...



Message Edited by Troy K on 01-16-2008 01:02 PM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Download All
0 Kudos
Message 39 of 56
(3,082 Views)
Can someone tell me what this is and where to find it? (in the attachment)
 
Also, how can i get my array icon to be v32?
0 Kudos
Message 40 of 56
(3,057 Views)