I'm writing a PLC program (Q Series Mitsubishi PLC, GXWORKS 2 Software) for a package sorting machine. The logic of the machine is the following:
Packages are induced in the conveyor. A barcode reader scanner gets the package barcode.
Barcode is send to our SMS (sorting management system), it calcules the exit and send it back to the PLC.
Package travels to the calculed exit, then is derived into the chute.
The tracking of the products is done by an encoder and a shift register. This means that every memory address represents a physical position in the conveyor. Then, the shift register move the bits representing the packages along the memory buffer, till the bit arrives to an address that represents an exit, so the package can be derived.
My problem is not the tracking of the product, but the product ID tracking:
When a package enters in the conveyor, an ID is set for that product (1,2,...,n). The idea is that this ID is used to track the state of that package, for example if the package was derived in the correct exit, if it has a damaged barcode, etc.
My question is, how can I track this ID along in an efficient way. I was thinking in use the same shift register not moving a sole bit, but moving a larger number for example |1|0000011|, where the first bit acts like a flag that represents the existence of a product and the rest of the numbers is the product ID. When the flag gets to the exit address I can substract 10000011 - 10000000 = 00000011, to get the product ID.
Is any more efficient way to do this ?