1
votes

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.

1

1 Answers

2
votes

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 doing like this, but it did in that case.

The return message, "MBCHNL_RESP_STATUS_CANCELED", came from the message queue in the TMW stack code, it because there're some code for checking to make sure this is not a duplicate request. So the slave channel couldn't afford to process messages from three masters simultaneously, and then messages of each masters remained in their own queue.

I asked Triangle Microworks same question, I received their opnion 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 logic for requesting as bellow. - Send per 2 seconds, but if I only received response.

The communication is more fluent than it was. It looks more continuous. Sometimes, masters cannot receive some seconds, but after some seconds, they communicate well again.

I know it is not a perfect answer as well. If I found a better answer, I'll write it again.