Introduction
Control Works implemented a solution for sorting products into the correct bin on a conveyor based on a barcode. The bin locations were based on data sent to a local REST API from an external system. Each product was scanned in a camera “tunnel” to ensure all sides were captured, and additional bar codes were used to store product data in a SQL database.
Solution
B&R & Cognex
A B&R PPC2100 with B&R Hypervisor was used for this application to allow both Automation Runtime and Windows 10 to run on the same device.
The system sorts products based on EAN-13 (13 digit) and UPC A (12 Digit) codes. As the conveyor runs, a sensor is used to trigger the action of the cameras. Four cameras are arranged to capture the codes with the product at any orientation. Each camera triggers in a sequence of approximately 4 milliseconds apart; this is done to avoid interference from one flash into the directly opposed camera.
When the camera is finished processing the images, the position is captured from the encoder feedback. The distance from the proper gate is then determined and that value is used to open and close the gates. A custom JavaScript function was used in the Cognex system to send multiple barcodes on each product to the PLC to be stored in a SQL database.
REST API
Control Works created a REST API using C# based on a specification from the client. Several POST, GET, and DELETE methods were implemented to add recipes, get the status of each job, clear alarms and unmatched items, and much more.
This REST API, running on the Windows side of the B&R PPC, connects to the Automation Runtime via Automation Net/PVI.
Below is example of a GET request:
curl -X GET http://localhost:9002/api/sorting/v1/recipes/active
{ "status": 200, "data": { "bins": [ { "sortingBin": 0, "reference": "abc-3", "description": "recipe description", "items": [ { "id": "item 4", "quantity": 3, "specification": "specification 1", "quantity-scanned": 0 }, { "id": "item 5", "quantity": 1, "specification": "specification 2", "quantity-scanned": 0 }, { "id": "item 6", "quantity": 1, "specification": "specification 3", "quantity-scanned": 0 } ] } ] } }
Since the REST API was developed in C# and exists on a B&R PPC, there is no licensing cost to running this software. Configuration files were created to account for any change in endpoints or database configuration.
Conclusion
This ultimately resulted in a completely automated system in which products could be placed on a conveyor and each product would be sorted to the correct bin as determined by the recipe sent to the REST API.
The project was completed a couple of years ago. B&R cameras can now be used to create a more integrated system, and the REST API can communicate to Automation Runtime via OPC UA, a more widely used communication protocol.