LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple independent timer objects

Solved!
Go to solution

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

0 Kudos
Message 1 of 10
(5,283 Views)

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

 

Message Edité par tinnitus le 12-26-2008 11:46 AM
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 2 of 10
(5,281 Views)

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.

Download All
0 Kudos
Message 3 of 10
(5,265 Views)

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

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
Message 4 of 10
(5,250 Views)
Hi, sorry I have version 8.2 and it won't let me open your VI. Is there a way you could save it for an earlier version? Otherwise, could you please post a screenshot of the block diagram? Thanks lots.
0 Kudos
Message 5 of 10
(5,248 Views)

Sorry :

 

in 8.2

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 6 of 10
(5,246 Views)
Solution
Accepted by ntictac
To use a VI in multiple places in an independent manner then you need to make the VI reentrant. Thus, if you make the CSec VI reentrant it should solve your problem.
Message 7 of 10
(5,241 Views)

Yes, that was it tinnitus! Thanks.

 

Also, thank you smercurio_fc. Your instruction was also very useful!

 

Thanks a lot both.

 

 

Message Edited by ntictac on 12-26-2008 05:24 PM
Message 8 of 10
(5,223 Views)

This:

 

 

is simply silly. This can be done with 2 Boolean operators. 

Message Edited by smercurio_fc on 12-27-2008 09:21 AM
0 Kudos
Message 9 of 10
(5,195 Views)

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

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 10 of 10
(5,168 Views)