Modbus-TCP slave-ID

1,407 views
Skip to first unread message

hdha...@hotmail.com

unread,
Oct 9, 2006, 9:20:33 AM10/9/06
to NModbus
Nice piece of code

But, how can I pass the slaveID (address) using Modbus-TCP.
I don't see a slave-address-parameter.
As I see it, the driver always accesses slave ID 0

Regards

Henk

sja...@gmail.com

unread,
Oct 9, 2006, 3:32:40 PM10/9/06
to NModbus
Sorry if this ends up being a duplicate reply...

Henk,

It is my understanding that when using the Modbus TCP/IP protocol the
slave (server) is addressed by IP, rather than by unit id. See the
following excerpt from the Modbus TCP/IP spec (pg 23)
http://modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0a.pdf

· Unit Identifier
This field is used for routing purpose when addressing a device on a
MODBUS or
MODBUS+ serial line sub-network. In that case, the "Unit Identifier"
carries the
MODBUS slave address of the remote device:
If the MODBUS server is connected to a MODBUS+ or MODBUS Serial Line
sub-network and addressed through a bridge or a gateway, the MODBUS
Unit
identifier is necessary to identify the slave device connected on the
subnetwork
behind the bridge or the gateway. The destination IP address
identifies the bridge itself and the bridge uses the MODBUS Unit
identifier to
forward the request to the right slave device.
The MODBUS slave device addresses on serial line are assigned from 1 to
247 (decimal). Address 0 is used as broadcast address.

On TCP/IP, the MODBUS server is addressed using its IP address;
therefore, the
MODBUS Unit Identifier is useless. The value 0xFF has to be used.
When addressing a MODBUS server connected directly to a TCP/IP network,
it's recommended not using a significant MODBUS slave address in the
"Unit
Identifier" field. In the event of a re-allocation of the IP addresses
within an
automated system and if a IP address previously assigned to a MODBUS
server is then assigned to a gateway, using a significant slave address
may
cause trouble because of a bad routing by the gateway. Using a
nonsignificant
slave address, the gateway will simply discard the MODBUS PDU
with no trouble. 0xFF is recommended for the "Unit Identifier" as
nonsignificant
value.
Remark : The value 0 is also accepted to communicate directly to a
MODBUS/TCP device.

Does this satisfy your needs? If not please tell me the details of
your usage and I'll see if I can adjust NModbus accordingly.

Thanks for the feedback!

Scott Alexander

hdha...@hotmail.com

unread,
Oct 10, 2006, 1:57:27 AM10/10/06
to NModbus
Hi Alexander,

Thanks for your reaction.

I just started experimenting with the EGX400 from Schneider Electric.

http://www.powerlogic.com/literature/litdetails-us.cfm?id=298

This is a Modbus Gateway for Powermeters of the Schneider Range.
The NModbus-TCP driver didn't work on this equipement (who has only 1
IP address).

So I wrote a little piece of code my self (Modbus-TCP isn't very
complex).

Here I had to use the slave-ID to address the individual slaves
connected
on the gateway.

That is my experience.

Regards,
Henk

sja...@gmail.com

unread,
Oct 10, 2006, 9:30:47 PM10/10/06
to NModbus
Henk,

I hadn't thought of that situation. In the latest release
http://www.nmodbus.com/releases/NModbus_0.0.3.zip the Modbus TCP master
contains overloads which include the option for providing a slave ID.

Enjoy and let me know if you have any additional feedback.

Thanks.

Scott Alexander

Reply all
Reply to author
Forward
0 new messages