LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine Timer

Solved!
Go to solution

Hi,

 

I have minor problems with the state machine timers. I want the timers to control the end of the while loop, moving to the next state. The states will be repeated during the program. 

 

But why does state Timer 1 not start counting down from the beginning? State Timer 2 works the way I want. I've tried to change Elapsed Timers Reset and Auto Reset booleans, but this has not remove the problem. 

 

What kind of timer should I code if this does not work with the Elapsed Time

 

Thanks in advance,

-Richard

 

0 Kudos
Message 1 of 4
(1,626 Views)

@proprogrammer wrote:

What kind of timer should I code if this does not work with the Elapsed Time


We might be able to fix the problem in your example, but it's not clear (to me) what you're trying to do. 

 

But most likely, the problem is that the two timers don't share any information. Both work PtByPt, so both have their own state. You might have luck passing the start time.

 

If you'd ask me, a class based timer, or at least a timer that works by wire (e.g. a cluster) would make life a lot easier.

 

I'd recommend learning about shift registers before you dig yourself in any deeper.

0 Kudos
Message 2 of 4
(1,579 Views)

Hi, hope this can help you

 

Example Input:

[User input] Time Target(s) = 00:00:10

[User input] Timer = 00:00:05

 

Expected Output:

State = Timer 1→Elapsed Time (s)= Time Target(s) = 00:00:10 → State = Timer 2

→ Elapsed Time (s) 2= Timer = 00:00:05 → State = Timer 1 →Elapsed Time (s)= 00:00:10

 

Error Output:

State = Timer 1→Elapsed Time (s)= Time Target(s) = 00:00:10 → State = Timer 2

→ Elapsed Time (s) 2= Timer = 00:00:05 → State = Timer 1→Elapsed Time (s)= 00:00:05

 

 

 

SUSPECT:

The data is not cleared when Timer finish counting.

 

SUGGESTION/SOLUTION:

yikhengyong_0-1616144973702.pngyikhengyong_1-1616144983939.png

 

 

0 Kudos
Message 3 of 4
(1,492 Views)
Solution
Accepted by topic author proprogrammer

So we can simplify a lot iin your simple code. You need to look into using shift registers. Take a look at what I did. It will make you code easier to read and take care of. Example.png

 

If you write your code this way you also do not get caught in the state while it is waiting to time out. If you hit the stop button on my code you will come out of the loop immediately no matter what your timeout is.

Tim
GHSP
0 Kudos
Message 4 of 4
(1,478 Views)