The ProductBuffer V3 is a Siemens PLC Function Block (FB) designed to track products on a conveyor using an encoder and a start sensor.
It manages multiple products simultaneously and automatically determines when a product has reached the configured trigger distance.
STRUCT ST_Product
Active : BOOL; // Product active in buffer
StartPosition : DINT; // Encoder value at detection
CurrentDistance : DINT; // Distance traveled
Triggered : BOOL; // TRUE once trigger distance reached
END_STRUCT
VAR
ProductBuffer : ARRAY[0..12] OF ST_Product;
END_VAR