I read that you have a considerable distance between your controller and your IO.
What you could do, that is use remote Modbus IO using the RS485 on your Mega.
RS485 is the way industrial remote IO buses are built since decades (Profibus, with millions of nodes worldwide is in fact based on RS485, modbus RTU also runs on this hardware layer).
There are many Modbus modules available that can be used for this (Chinese and others). A more simple solution, but more expensive in hardware could be to buy a second Controllino with RS485 port and use it as a remote IO.
One remark though:
The standard support RS485 as supplied with your Controllino is not the right way to go in your case.
What is the problem: the problem is that as long as the cpu is sending traffic, it loops until all characters are sent out and then it disables /RE on the SN65HVD08 RS485 controller. (in a solution where you need to have full duplex communication between the controllers. This is the case in most cases.)
The better way to do this is to let the interrupt hander that manages the serial IO manage this direction control as well. I have written the code to do this, and if interested, I will be happy to support you free of charge in this.
You can do in fact the same using udp messages over Ethernet. UDP is also blazing fast, the disadvantage however is that Ethernet is more destined for HMI or data logging. Udp also runs over a separate processor, so there I would not be to afraid of delays if code is handled properly.
This reply was modified 1 year, 8 months ago by Johi.