M1 is an indicator, and its value is fully determined by the code.
The value of the shift register will be retained as long as the VI remains in memory, even if you close the front panel. So, why do you close the VI??
Basically, you need a sure way to programmatically determine the current pump status (on or off) and initialize the shift register with it. That depends on your hardware.
Another possibility would be to write the last value of the shift register to a configuration file when the VI stops, and read it out and initialize the shift register with it when the code starts again. (This is less reliable, because the pump could turn off for other reasons).
In any case, your code is a "head scratcher" What's up with all the hidden wires and unecessary boolean operations? (e.g. the innermost case structure just returns the input wired to the selector, i.e. the same as if you would leave it out and just wire across. What is the point of the inner loop?
The current functionality can be fully done e.g. as follows:
You also need a small delay in your loop. Place an indicator to [i] to see why. 🙂
Message Edited by altenbach on 03-01-2007 12:05 AM