Sweet!
TL;DR
It seems odd to see two possible sources of the pulse to the CPS instructions, but I am guessing that Input 27 plus the ONS instruction is the normal pulse source when the motor is running, and the other is to clear out the product ID array when the motor is not running over the course of 5s (500counts * 10ms/count; 10ms = two 5ms executions to toggle ClearArray.CU; 500 steps to turn on ClearArray.DN).
Presumably there is other logic to reset ClearArray.
Note that CPS does not copy arrays
in toto (compare
memcpy(3) with
memmove(3)), but rather is a sequential copy of elements between arrays (cf. Example 5
here), which is why the two CPS instructions using the Conveyor_Swap temporary array is necessary to shift array elements to a higher address in the same array; only one CPS instruction would be needed if the shift were in the opposite direction, but then the element representing the most upstream position on the conveyor would be at offset 499 instead of at offset 0; the logic would work the same way, but would also be slightly more confusing to understand and debug.