Ethernet Communications Modules, 3rd Edition, Rev. D
5-26
Chapter 5: MODBUS TCP for H0/H2/H4-ECOM100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Example Modbus TCP Program
On the following pages is an example RLL program using Device ID 1 from the Peer to Peer
Configuration box. The user could easily add additional IBOXs to implement other devices.
After creating your program, ensure your program has an END statement. Select “Accept”
( F8), and write the project to the PLC (Shift+F9). Make sure after you have written the
project, that the PLC is placed into Program mode, then back into Run mode (many IBOXs
are only processed after a Program-to-Run transition). If everything is correct, V505 ( RX/
WX OK Count) using the Success bit, should be incrementing very fast.
Troubleshooting:
Modbus Addressing: You must know the addressing of your device. Some devices give addresses
in hex values, which can often appear like a decimal value (310 is a valid hex or decimal value).
Asian drives often use hex. You can use Windows calculator “scientific” view to convert the
addresses.
Also, many devices use addresses as “offsets”, particularly Holding Registers. The address
40001 means the first Holding Register, but your device may term this as Holding Register 0
or 1 (the 40000 is assumed). Whether this is actually an address of 0 or 1 is hard to predict.
An excellent method of troubleshooting is to try to only read from the middle of a known
address range, that will have non-zero values. If you know the device has 10 Holding registers
starting at 1, try to read #3, and compare that to the values in the device. If that is one more
or one less than you expect, then that is the offset you will have to use in the DirectLogic
numeric conversion.
• Make sure you can ping your device
• Make sure the PLC has made a Program-to-Run transition
• Make sure the LinkGood light is ON, on the ECOM100 module
• Make sure Dipswitch 7 is ON, on the ECOM100 module
On rare occasions, and almost exclusively with Festo or Numatics devices, their Holding
Registers start at a VERY high number, around 45,000. There isn't an equivalent octal address
to convert that high a value, so a Z constant was introduced that allows the use of a hex
value in the “From Slave Element” field. So a 45,392 address is actually the offset added to
40,000...45,392 = B150 hex, so the entry in the “From Slave Element” field would be ZB150.
There are 3rd party Modbus shareware programs available on the internet, and we have a free
ModbusTCP tester at the link below. You might need to use one of these programs to test to
your device, to make sure they can work successfully to the expected addressing.
http://ftp.automationdirect.com/pub/Modbus_TCP_Master.zip
To read Modbus Input Registers, you must change the number of bytes in any instruction to
the next odd number. For example, if you are reading 16 bytes (8 Registers), then you would
increase the number by 1 to 17 bytes, and the instruction will then be trying to read Modbus
30000 addresses.