I have a weird problem with multi-master in Modbus TCP/IP. I know that Modbus Serial doesn't support multi master. But when I saw some documents, they said Modbus TCP supports multi master.
I composed three tcp clients as Modbus TCP master and a server as Modbus TCP slave. Each Modbus TCP master requests the Modbus TCP slave to get data at every 2 seconds regularly. And I use Modbus TCP stack for master device, which made by Triangle MicroWorks.
I expected every master could receive data from slave, but actually, one master only communicated well with slave, other masters could not receive data. They only received a return status "3", which means "MBCHNL_RESP_STATUS_CANCELED".
In this composition, is this behavior right? I wonder if "multi-master/multiple same request" couldn't be supported by the stack or there are other ways to behave multi-master.
I found an answer for this problem. In short, masters were too fast and the slave channel was busy. I cannot assure all types of modbus stack behave like this, but it did in this case.
The return message, "MBCHNL_RESP_STATUS_CANCELED", came from the message queue in the TMW stack code, it was caused by some code that checks to make sure it is not processing a duplicate request. So the slave channel couldn't afford to process messages from three masters simultaneously, and then messages of each master remained in their own queue.
I asked Triangle Microworks the same question, I received their response last week. "... You are allowed to have multiple channels (each channel must have a unique ip/port combination). 2 seconds may be too fast for only 1 channel. ... Try changing period to 3 seconds and so on."
I think it is not perfect answer, so I improved my logic for requesting as bellow.
The communication is more fluent than it was. It looks more continuous. Sometimes, masters cannot receive for some seconds, but after a few seconds, the communication is restored.
I know it is not a perfect answer as well. If I find a better one, I'll update.