A four-input factory alarm that escalates
A factory alarm system has four danger inputs. When only a single input is active, nothing happens. When any two inputs are active, the Red Pilot Light is activated. Any three active inputs trigger the SIREN. When all four are active together, the Fire-Department alarm is triggered. Treat every input as a Normally Open contact.
ShowHide worked solution
The simplest approach is to count how many inputs are active and act on that single number. A small ADD chain pushes the count into N7:0; then three equality comparators light the three outputs.
Rung 1: |---[ ALWAYS ]----(MOV 0, N7:0)----| reset count each scan Rung 2: |---[ I1 ]----(ADD N7:0, 1, N7:0)----| Rung 3: |---[ I2 ]----(ADD N7:0, 1, N7:0)----| Rung 4: |---[ I3 ]----(ADD N7:0, 1, N7:0)----| Rung 5: |---[ I4 ]----(ADD N7:0, 1, N7:0)----| Rung 6: |---[ N7:0 = 2 ]----(RED_LAMP)----| Rung 7: |---[ N7:0 = 3 ]----(SIREN)----| Rung 8: |---[ N7:0 = 4 ]----(FIRE_DEPT)----|
Count register N7:0 carries the number of active inputs; equality comparators drive each escalation level.
A pure-Boolean version would enumerate every C(4,2) pair for the red lamp and every C(4,3) triple for the siren — same behaviour, far more rungs.