11-16-2013 11:29 AM
Attached is a state machine I created to illustrate a problem I am having with a larger program. It doesn't do much but the concept is the same.
I created two program buttons (run & abort). If I abort the count down timer (suspend to idle state) then select run it begins counting down from previous counter value. I need to begin counting down from 1 min.
The shift register of the state machine while loop retains value when last selecting the abort button. I need state machine while loop shift register to be reinitialized each time the run button is selected while in the idle state.
Thx
Solved! Go to Solution.
11-16-2013 11:36 AM
Then feed the constant into the shift register rather than the wire that is going into it now.
11-16-2013 11:54 AM
sorry i dont get it. i think you are saying wire the value from the idle loop ? can you show me what that looks like ?
thx
11-16-2013 12:14 PM
There is no "idle loop". You have an idle case. Instead of wiring through the count from the left side shift register. Just feed a constant to the wire that goes to the right side shift register.
11-16-2013 12:28 PM
Wire the upper shift regsiter also across the inner case structure of the "idle" case and reset it in the true case.
Overall, you should re-think this entire code. It could be made much simpler.
11-16-2013 12:32 PM
ok i got it, thanks.
11-16-2013 12:32 PM
Here's quick cleanup that should give you some general ideas (LV2013). Probably needs a few tweaks.
Of course you could use the high resolution timer to keep track of the countdown clock, eliminating the cntr state entirely.
11-16-2013 12:39 PM
The inner while loop is there so the "facility reg" control gets sampled at a faster rate than one second. Maybe there is another method.
Thanks for the input; I will review. I don't want my code to use excessive cpu resources.
Thx
11-16-2013 12:43 PM
hey thanks for the code, very streamline compared to my code. I will reverse engineer it and hopefully pickup some new techniques.
thx
11-16-2013 12:47 PM
@ggress1 wrote:
The inner while loop is there so the "facility reg" control gets sampled at a faster rate than one second. Maybe there is another method.
Nobody forces you to use an integer for the timer.
altenbach wrote:Of course you could use the high resolution timer to keep track of the countdown clock, eliminating the cntr state entirely.
Attached is what I had in mind. Now the countdown is accurate, because it does not rely on any loop rate. Only two states needed.