LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed time reset in producer consumer loop

Solved!
Go to solution
Highlighted

Hi, everyone!

 

 

I have a producer(event handler) and consumer(state machine) structure. One of my states says: display message, then wait 5 sec, then display something else, then wait 3 sec, etc, so I have 5 timers with countdowns using the Elapsed time vi. 

I also a have a function which is supposed to start this state all over again, so all the timers need to start at the initial time.

For some reason, this is not working, although I am using the reset function on the elapsed time.

 

Has someone done this before and now how to reset the timers in a producer consumer loop?

 

Best regards

 

 

0 Kudos
Message 1 of 13
(441 Views)
Highlighted

Perhaps if you included your code it would be more clear what you are trying to do. It sounds to me like you're wanting to start multiple timers simultaneously, but I may be misunderstanding. If this is the case perhaps you need to build your own elapsed time code - it's really simple.

0 Kudos
Message 2 of 13
(420 Views)
Highlighted

Hi, 

 

I want the timers to execute one after another, see attached VI and then reset.

 

 

 

Best regards

 

 

0 Kudos
Message 3 of 13
(413 Views)
Highlighted

Hi, 

 

I want the timers to execute one after another, see attached VI, and then reset.

 

 

 

Best regards

 

 

0 Kudos
Message 4 of 13
(412 Views)
Highlighted
Solution
Accepted by topic author mirelche

What is going on here? Why the Producer/Consumer architecture? Is this part of a larger program?

 

 

countdown.png

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 5 of 13
(387 Views)
Highlighted

Your queue utilization is a COMPLETE mess and you therefore have race conditions and circular code.  You need to implement a proper state machine in your message handling loop.  DO NOT LET THE PRODUCER DIRECTLY SET THE STATE.  A little trick I do here is to use the queue timeout.  You can store the timeout in shift register so you can change it.  Set it to -1 to wait forever or some other value.  On a timeout (ie, you did not get a message), you perform the next state in your state machine.  If you got a message you handle it.  Use another shift register to set whether or not to reset your timers.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 6 of 13
(361 Views)
Highlighted

All you probably need is an single while loop containing a case structure (or maybe an event structure containing a case structure in the timeout case).


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 7 of 13
(323 Views)
Highlighted

Yes, it is part of a larger program, where I need the producer consumer.

0 Kudos
Message 8 of 13
(316 Views)
Highlighted

I thought this is what I do with the timeout case in the event structure by enqueing the Wait state there...

0 Kudos
Message 9 of 13
(315 Views)
Highlighted

See if this can give you some ideas. (i.e. how to switch states after some time).


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 10 of 13
(308 Views)