Solved! Go to Solution.
How fast is not fast enough?
Overall, it looks like you've built the statemachine so it executes in the timeout case about every 50 msec. However, if you are in Sequence 1 or Sequence 2, you have an internal while loop in those cases where each iteration will take X seconds depending the values in time 1 or time 2.
Your i=0 condition is kind of odd also. The first iteration of the loop will always be i=0 and thus the loop will stop after that iteration and it will continue to the next the next sequence once the X seconds have passed.
I'm not sure exactly how you want to sequence things, but I would recommend you use some elapsed time functions that determine when the X seconds have passed and execute the relay change accordingly. Get rid of the inner while loops (which only run once) and the wait timers. Now the outer while loop will continue to be your master state machine and the pacing of the loop will be controlled by the timeout timer on the event structure.
Your current time is being fed into the shift register on every iteration and becoming the new start time for the next iteration. If you change states, then feed your current time into the shift register for the new start time. Otherwise feed the existing start time into the shift register.
I am adding the finished vi here in case anyone would benifit from it.
Thanks Ravens Fan, I took your tips and incorporated them into the program and added a feature that allows the user to enter zero in the number of cycles and it will cycle continuously.