drbitboy
Lifetime Supporting Member
Here is my attempt at this problem (RSLogix: .RSS; .pdf); I think it is equivalent, if not identical, to what Tom suggested.
The last two rungs of the MAIN LADder Program File, with six instructions each, implement the desired sequencing.
TL;DR
The MAIN LADder file has three rungs:
The first rung MAIN ladder logic calls the COMMANDING subroutine, which puts one of three values in INTeger COMMAND:
The MODEL_STI routine models (simulates) the process pressure in response both to the number of compressors running, and to whether the "machine" is running. MODEL_STI runs on interrupts at 200ms intervals. MODEL_STI is pure fiction of course but its behavior is similar enough to the process described by the OP that it can show how the MAIN sequencing algorithm would work.
The last two rungs of the MAIN LADder Program File, with six instructions each, implement the desired sequencing.
TL;DR
The MAIN LADder file has three rungs:
- One rung to get the COMMAND via a subroutine call (JSR)
- Two rungs to implement the sequencing
- NEXT_ON - index of next compressor to start
- NEXT_OFF - index of next compressor to stop
- COMMANDED_ON - bit mask of commanded states of the three compressors
The first rung MAIN ladder logic calls the COMMANDING subroutine, which puts one of three values in INTeger COMMAND:
- 0 - do nothing
- 1 - stop a compressor
- 2 - start a compressor
The MODEL_STI routine models (simulates) the process pressure in response both to the number of compressors running, and to whether the "machine" is running. MODEL_STI runs on interrupts at 200ms intervals. MODEL_STI is pure fiction of course but its behavior is similar enough to the process described by the OP that it can show how the MAIN sequencing algorithm would work.