As part of OSIE project (Open Source Industrial Edge) we needed a way to implement an industrial line which we could control using entirely open source technologies. In a pure automation world this is usually done using PLC (Programmable Logic Controller) units. Nexedi, being a software company is still far away from the automation world, but one of our OSIE partners (Olimex) was already producing boards that could work together and control electrical circuits. All we needed was to provide an abstract layer of technology so that any automation engineer could use the already existing PLC languages of his choice (ST, Ladder Logic, etc).
Luckily of us Beremiz was already around and it could provide us the PLC control we needed. Thus all we had to do was to hook all together - which is what this article is all about.
Below the first design of the coupler as it was created by Nexedi.
This coupler consists of the A20-OLinuXino-LIME2 (top) and MOD-IO (bottom) board which are connected over UEXT cable.
The coupler (A20-OLinuXino-LIME2 board) has following characteristics:
The coupler (MOD-IO) has following characteristics:
And both boards are completely open source (incl. schematics).
Our design had to meet several criteria from the start:
After initially trying with ProviewR we discovered that it is a monolithic product which is quite hard to break into stand-alone components. We continued our search and we found Beremiz
Right from the beginning we knew that we need to expose a Modbus interface to the MOD-IO's relays which we wanted to control. Luckily for us using pymodbus and pyA20Lime2 we could provide a Modbus server running on the coupler fairly easy. Still, as a PLC has a deterministic nature where each cycle has a fixed execution interval and where the runtime needs to acquire Modbus status variables over the network from the coupler's Modbus server, we quickly discovered that both network latency and modbus's server implementation overhead can add sometimes significant lags to PLC's program execution - in some cases this leads to Modbus read requests timeouts after more than 30 ms. This finding quickly showed us that we need to spend time to work on improving TSN support for lime2 and improve (if possible) modbus python implementation. For a quick overview of our TSN efforts one can read our report here.
Once we had a Modbus server exposing relays of MOD-IO it was time to write our first "Hello world!" PLC program - a simple program which switches ON / OFF the existing 4 relays and resets internally some counter values. We used Beremiz in the following setup:
Below you can see the source code of our first PLC program:
Below it's a screen shot of the program running inside the IDE itself with real time values.
And finally one can see the video of the coupler being controlled remotely from the runtime.
As part of OSIE project and the optical (formerly cherry-picking machine) we build there (see here) we will soon use the coupler in a real conveyor belt based machine which should be able to track movements of conveyor belt objects and perform a real-time classification on them to decide whether to select an object or not.
All the selection will be done using machine learning inference algorithms which should run on a close-by powerful server running Wendelin Big Data Platform.
With current coupler we now have the building blocks to finish our production line.
Our proof of concept showed that the existing tools allow us to have a complete open source based system which is not at all vendor locked and free to use.