From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to use a series of event with "Elapsed Time" VI?

Hello,
I have been trying to build a VI (with LabView 7.0) that allows me to set the amount of time for each event I perform with my equipment. Basically, I need a VI that keeps running for, let’s say 2 minutes while smaller events happen in their own time interval. I am attaching a simple example I created that multiply numbers, in the same logic I am using to control my events with the real equipment. What this VI should do then is:
1. Run for 2 minutes.
2. Meanwhile, another event included in it should happen for 1 minute and pass to the next event (which doesn’t need to be time controlled). This activity should be repeated for the total length of the test, which is the 2 min event. The VI should then stop after 2 min.

I am using the “Time Elapsed VI”, which is working fine for the internal events (smaller time interval) and because I inserted it on a while loop, it keeps repeating itself after event 1 and 2 (see VI, please) happen, what is what I need. But it seems not to be even counting the elapsed time of the whole thing, so these event never stop, when they should do it after the 2 min have elapsed. I might have been using a wrong logic. Could anyone have a look on it and advise, please?
I appreciate the help.
Adriana
0 Kudos
Message 1 of 8
(2,819 Views)
It always good to use the trace execution tool to see what is happening in your loop.
Event 1 occurs as it should for the set amount of time, however, when it finishes, event2 occurs only once then because your events are in a while loop, it starts event1 again. It never breaks out of this loop.
If you remove the while loop sorrounding event1 & 2, your main timer will work. This however gives you another problem that your Main Elapsed timer will only be read at the time when event1 finishes eg once every minute, which will not give you very good resolution.

I would suggest running your events in a state machine structure which allows you to monitor all timers at once and easily switch b/w event 1&2. I modified your vi to demonstrate the idea.

I hope most of this made sense.
Message 2 of 8
(2,810 Views)
Hi David,
Could you please send a jpeg image of your VI. You build it in version 7.1 and I use Labview 7.0, so I was not able to open it.
Thanks
0 Kudos
Message 3 of 8
(2,801 Views)
Message 4 of 8
(2,798 Views)
Thanks David. I will have a look right now.
0 Kudos
Message 5 of 8
(2,793 Views)
David,
Sorry, I might have been a bit confusing on my explanation.
ACtually, event 1 should happen during the set amount of time for it. Then, I should pass to event 2, which should happen after event 1 but has no time limitations, just the need to happen after event 1. Once event 2 has finished, I should go back to event 1, execute again at the set amount of time, pass to event 2 and keep doing this untill the main loop time ends. That is why I was using the loop around those two events and another elapsed time loop on the outer edge. The State Machine seems to follow sequencial events but I don't see exactly how it could be performing the Event 1-Event 2 loop for the main Elapsed time. Could you please give me some light?
Thanks again,
Adriana
0 Kudos
Message 6 of 8
(2,790 Views)
Dependending on how you want event2 to execute, you can determine how you want the sequence to occur. To follow your original example sequence, in the event2 case, change the constant which feeds to the shift register from 1 to 0 (or 2 to 1 can't remember).
This change will cause the sequence to execute event1 for a set time, execute event2 once, then return to event1 and execute it for a set time until the main sequence time is reached. Just ensure that the 'Automatically Reset after time target' option is selected on the Elapsed Time vi in event1.
Message 7 of 8
(2,785 Views)
Got it!
I didn't know the State Machine structure yet. Simple but quite powerful tool.
I will be trying it on with the real thing.
Thanks a lot for the help David.
Adriana
0 Kudos
Message 8 of 8
(2,776 Views)