03-12-2021 01:43 AM
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
Solved! Go to Solution.
03-12-2021 06:46 AM
@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.
03-19-2021 04:10 AM - edited 03-19-2021 04:11 AM
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:
03-19-2021 10:54 AM
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.
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.