Slave address protocol in MODBUS communications

J

Thread Starter

JITENDRA KUMAR DAS

I would like to ask few questions on MODBUS communication protocol. Please provide me the correct answers.

1. What is the maximum number of SLAVE devices can communicate in MODBUS TCP/IP protocol with out any repeater?

2. Why SLAVE address should be from 1 to 247? Why slave address 0, 248 to 255 should not use as slave address in modbus communication?

3. The valid code for FUNCTION is from 1 to 255 decimal but my question why can't it from 0 to 255?

I kindly request you to answer my technical queries.
Thank you
 
> 1. What is the maximum number of SLAVE devices can communicate in MODBUS TCP/IP protocol with out any repeater?

Behind 1 IP address you may have up to 247 slave devices. Imagine a ModbusTCP/RTU Gateway. The TCP message is identical to the RTU message except there is no checksum on TCP. Addresses 248-255 are not specified.

> 2. Why SLAVE address should be from 1 to 247? Why slave address 0, 248 to 255
> should not use as slave address in modbus communication?
Slave address 0 is used for broadcasts.
Addresses 248-255 are not specified.

> 3. The valid code for FUNCTION is from 1 to 255 decimal but my question why can't it from 0 to 255?
Because they have not been specified in the standard.

See:
http://modbus.org/docs/PI_MBUS_300.pdf

I can imagine 2 reasons why the last 8 possible addresses can't be used.

1) Reserved for future extension of the protocol

2) The Modbus header in RTU has 8 byte size and the maximum protocol data unit is 256 byte.

Thus when reading/writing multiple registers the PDU size would not be big enough if you transfer more than 247 data bytes in 1 message.
 
L

Lynn August Linse

Despite the spec saying don't use 248 to 255, any host SHOULD support them, as some slave might require them.

The actual Modbus spec (for example) suggest to use 'unit id' 255 to address a bridge device itself. So unit id 1, 2, 3 (and so on) might be serial RS-485 devices out the serial port, but 255 would be the bridge itself.

I have also seen several companies now use 255 or 254 as the 'default' id. So a new slave device require you to talk to slave address 254 and use Modbus/RTU to CHANGE the slave address to 1, 2, etc.
 
J

JITENDRA KUMAR DAS

Thank you for replying my questions but I am sorry to say that I am still not satisfied with above answers. Could you give me little bit more clear answers to my question which I shall appreciate.
 
Hello,

1. There is no limit. An IP address is the full address (A port number is also used but the IP address gets you to the device.). You said "no repeater", not sure what that means. Repeaters normally are for RS-485. Slave addresses in MODBUS TCP are for gateways as mentioned by pvbrowser or a device that mimics multiple slaves from one IP address.

2. As pvbrowser stated 0 is reserved for broadcast message. If you do not know what that means, look it up. 248-255 are reserved in the specification. Did you read the specification? I have created slave devices and I have supported address 248-255. That does not mean it could not be a problem for some network that is using that address for a specific purpose, as the specification hints about.

3. That was the way the designer of the protocol designed it. For his/her thinking on the subject you would need to ask that person. I have designed a couple of protocols and in many parts of the protocol zero was not allowed. It is a simple way to help validate fields. One field type never allowed was zero for a device address. While code and programmers handle zero most people do not use zero for an address. Have you ever seen a street address zero (0), a building floor zero, etc.? If you want to use zero as a function code for your own devices then that is your call. No other master would know how to use it unless you published the details.

MODBUS is a specification like the alphabet. It works because we agree to follow the specification.

Good luck,

Mark
http://www.peakhmi.com/
 
J

JITENDRA DAS

Thanks for your posting on the Control.com forum -- your participation helps make this forum a useful resource for automation professionals worldwide.
 
Top