nmambre
Hi,

I see from the getting started docs that the softplc use the blank driver, and it can be accessed with Modbus TCP. I haven't downloaded and tried it yet, but I want to know if it is possible (or will be in the future) to use the soft plc to communicate to Modbus Slave devices, in TCP and RTU.

Nelson
Quote 0 0
thiagoralves
Hi nmambre,

This is totally possible. Currently the OpenPLC itself is a Modbus Slave device, so you can access it to turn on and off the virtual I/O. However, it is possible to write a driver to talk to other devices so that these "virtual I/O" can get transmitted to external devices to actually turn something on or off.

OpenPLC is coded in a very simple way, with lots of comments on the code. So, in order to add new drivers for it, it's just a matter of creating more hardware layers. The hardware layer is some type of I/O driver for the OpenPLC. Every cycle, the OpenPLC asks for the hardware layer to read it's I/O. Then the result is given to the processing core that performs the logic. When the processing core is done, it gives the output back to the hardware layer to write to it's I/O. The blank hardware layer doesn't have anything on it, so the requests for reading inputs and writing outputs just do nothing. Therefore, just by writing a hardware layer that communicates with other devices over Modbus is enough to have these I/O exported to other Modbus devices.

Inside the core folder in the OpenPLC project, there is a folder named hardware_layers. Anyone can use the blank.cpp driver as an example to create a hardware layer for any peripheral they want to add to the OpenPLC.

If nobody does that, I might create myself a Modbus Master driver for the OpenPLC in the future. I think it might be very useful. However, right now I have some other priorities in mind.


Quote 0 0
mikronauts
Thank you for porting this to RPi.

A Modbus Master driver would be fantastic! (ideally, RTU and ASCII, as well as Modbus/TCP)

Quote 0 0
thiagoralves
mikronauts wrote:
A Modbus Master driver would be fantastic! (ideally, RTU and ASCII, as well as Modbus/TCP)

I finished writing a Modbus Master driver for the OpenPLC. Please check the News & Announcements page for details
Quote 0 0