12-26-2008 11:38 AM
Hi all,
I'm working on a VI for monitoring and control of several sensors/actuators, which of course is included inside one large while loop that keeps it running permanently. I've attempted to create multiple independent timers, each of which should latch upon a "TRUE" pulse (may only last for 1 second or so) and stay on during X seconds. After that, the timer should reset and await for the next "TRUE" pulse, which is given by the user at irregular intervals
The problem I've encountered is keeping the value of the start time. I realize one typically uses swift register in combination with a while loop to retrofeed such value. However, this seems to halt the execution of the rest of the VI (while the timer-while loop is running) until the timer expires. Furthermore, I'd like to put the timer in a sub-VI or similar in order to use multiple copies (use LVOOP maybe?).
Any help would solving the while-loop problem or creating a timer-class would be much appreciated.
ntictac
Solved! Go to Solution.
12-26-2008 11:43 AM - edited 12-26-2008 11:46 AM
Hello,
if precision could be >= 1s
you could tried to use elapsed time counter in time palette,
else there is solution but with little bit more work
could you attach a simplified vi of what your are trying to do
Best regards
Tinnitus
12-26-2008 01:46 PM
Thanks, tinnitus, for your response. I've attached 3 screenshots of my example VI and sub-VI...
So as you see, I have 3 buttons and 3 LED's. each is connected to its own copy of the "CSEC" subVI, each of which are "meant" to act as independent timers. Upon pressing each button independently, the corresponding LED should swich on for 10, 15, or 5 seconds respectively.
Looking at the CSEC subVI, you'll notice I obtain the seconds and centi-seconds of the current time as a 4 digit number (from another subVI). I mean to retain the start value when the button is pressed (hence timer started) and compare the current value with the start time plus timer duration. Ideally, the output of the selection function would feed back the "false" input, such that the start time is _not_ updated. However, this gives me a problem because "the wire becomes a member of a cycle." So instead, I mean to retain the start time in an indicator and feed the "false" input of the selector by reading out from the variable "InitTime1" which references the previsouly mentioned numeric indicator. This works fine at first, but of course, I have 3 instances of this subVI in my main VI. Therefore, when one timer switches on, the other two copies of the subVI CSEC read the value of InitTime1, etc... To sum up, the 3 timers are not independent.
I could use a different name for this "storage variable" in each VI, say "InitTime1" "Inittime2" "InitTime3", but I was hoping I could find a way to properly design this and reuse the "timer object" in multiple instances independently.
Thanks a lot for your help.
12-26-2008 03:28 PM
Hello ntictac,
i wrote a draft, let know if it match with behavior you are waiting for
I think this vi respond on paper but , it sould be necesseray to implement that in statemachine structure,
we will see later
@+
Tinnitus
12-26-2008 03:40 PM
12-26-2008 03:45 PM
Sorry :
in 8.2
12-26-2008 03:57 PM
12-26-2008 05:23 PM - edited 12-26-2008 05:24 PM
Yes, that was it tinnitus! Thanks.
Also, thank you smercurio_fc. Your instruction was also very useful!
Thanks a lot both.
12-27-2008 09:19 AM - edited 12-27-2008 09:21 AM
This:
is simply silly. This can be done with 2 Boolean operators.
12-27-2008 04:12 PM
smercurio_fc a écrit:This:
is simply silly. This can be done with 2 Boolean operators.
Message Edited by smercurio_fc on 12-27-2008 09:21 AM
hello,
yes you're right ,
this because i started on state machine at beginning
i forgotto simplify at the end
@+
Tinnitus