The design and implementation of the OptoMMP function blocks are strongly influenced by the following:
- Common Behaviour Model
- Modbus FB Library
Common Behaviour Model
The Common Behaviour Model is a standard means of supporting asynchronous operations within a CODESYS library.
A full implementation is available in the Common Behaviour Model Library.
Modbus FB Library
OptoMMP is quite similar to the Modbus protocol. Both protocols provide an address space, and both have operations for reading or writing one or multiple addresses at a time.
The primary way to use Modbus in CODESYS is with the Modbus fieldbus support, with devices added to the project’s device tree. This is similar to adding groov I/O to the device tree.
The design of the OptoMMP function blocks closely follow the design of the Modbus FB library.
For example, here’s some simple Continuous Function Chart code. A BLINK function block (from the standard Util library) is pulsing the boolean variable named
Here are Modbus FB function blocks that write
xLedOutput to a digital output (coil at address 583). The client connects and will attempt to reconnect if there’s an error and it goes offline. It sends the write request as soon as the previous one is finished.
Similarly, here’s the equivalent OptoMMP code. It also writes
xLedOutput to a digital output (at address 0xF0221240). The client connects and will attempt to reconnect if there’s an error and it goes offline. It sends the write request as soon as the previous one is finished.
Continue to the Hello, world! example.