Here is one approach. It separates the
pump sequencing logic from the
physical pump logic.
The FC Run_Sequence block determines which of the four internal bits gbl.runseq1 through gbl.runseq4 are "on,", which bits represent the running state of the "First logical pump to start," through the "Fourth logical pump to start" where "First logical pump to start" may,
or may not, be the physical "Pump 1." FC Run_Sequence implements inter-pump delays both when starting and when stopping the system. If the delays when stopping the system are not desired then eliminate the TOF instructions.
The FC Run_Pumps block maps gbl.runseq1 through gbl.runseq4 maps the logical pump states to the physical pump states, via the mapping array gbl.sequence_array.
The values of elements gbl.sequence_array[1] through gbl.sequence_array[4] are the physical pump number of the first pump to start through the last pump to start. So to start Pump 1, then Pump 3, then Pump 4, then Pump 2:
- gbl.sequence_array[1] = 1
- gbl.sequence_array[2] = 3
- gbl.sequence_array[3] = 4
- gbl.sequence_array[4] = 2
I realized too late that the FCs should be FBs with Start and Stop push buttons as Inputs, and the Run bit as an InOut, to the Run_Sequence*; I need to read that best-practices-programming-with-TIA document. But it works.
* or extract the Start/Stop Circuit pattern entirely and only input the Run bit