UM-0085-B09
DT80 Range User Manual
Page 363
RG
DT80 #1 is set up as a Modbus client, or master, device. It has no physical sensors of its own connected (although it
could have); its job here is to retrieve measurements from the four slave devices and log them. There also happens to be
a Modbus HMI (Human-Machine Interface) device connected. This is also a client/master device, which, like DT80 #1,
regularly scans the sensors. It then presents this data as a mimic display. Unlike a serial Modbus network, there is no
problem having multiple master devices on a TCP/IP Modbus network.
There is no particular configuration required to enable the DT80 to operate as a Modbus client. Unlike a serial Modbus
network, with TCP/IP many different protocols can be used on the network at the same time so there is no need to set
the "function" of the Ethernet port. However, some configuration of the DT80 may be required in order for the DT80 to be
able to "see" the various Modbus server devices. Depending on how the network is set up, you may need to set:
•
DT80 IP address (
PROFILE ETHERNET IP_ADDRESS=
...)
•
subnet mask (
PROFILE ETHERNET SUBNET_MASK=
...)
•
gateway address (
PROFILE ETHERNET GATEWAY=
...)
•
DNS server address (
PROFILE NETWORK DNS_SERVER_1=
...)
You may also need to configure the Modbus sensor devices themselves.
Reading Data from Modbus Devices
Modbus Registers
As described in The
, a Modbus slave device makes available the following resources:
•
an array of single bit
coils
(digital outputs), numbered from 0:00001 to 0:65536.
•
an array of single bit
discrete inputs
(digital inputs), numbered 1:00001 to 1:65536
•
an array of 16-bit
input registers
, numbered 3:00001 to 3:65536
•
an array of 16-bit
output registers
(a.k.a
holding registers
), numbered 4:00001 to 4:65536
As can be seen, the first digit of the register number indicates the type of register – 0, 1, 3 or 4 for coil, discrete input,
input register or output register respectively. This usage is, however, just a convention. This digit is not part of the actual
address transmitted in the Modbus message.
The documentation for the slave device will describe the function of each register. Bear in mind, however, that there are
a few different ways of specifying Modbus register numbers:
•
6-digit notation, as used in this manual. The first digit specifies the type of register, then there are five decimal
digits to specify the register number (00001-65536). In this manual, a colon (:) is used to separate the register
type and number. In reading Modbus device documentation you may also see an 'x' character used, or no
separator at all.
•
5-digit notation. This is similar except that only four digits are used for the register number (0001-9999)
•
protocol address. This is a decimal number 0-65535 or hexadecimal 0000-FFFF. The type of register would
need to be indicated in the text accompanying the register listing.
For example, "3:00043", "3x00043", "30043" and "input register address 42 (002Ah)" are all different ways of referring to
the same input register.
Interpreting Register Values
The Modbus protocol is just a way of transporting 16-bit (or 1-bit) values from A to B. It is up to the master and slave
devices to agree on how these values are to be interpreted.
By default, each register is normally taken to hold an independent signed integer value in the range -32768 to 32767. For
many applications this range is quite adequate, especially if a fixed scaling factor is also applied (for example a device
may return a temperature in tenths of a degree).
However, various schemes have been developed in order to allow higher precision values to be returned via Modbus.
These involve joining adjacent registers together to allow 32-bit values to be returned. These 32-bit quantities may then
be interpreted as long integers or floating point values.
The DT80 provides options to support many of these methods. It should be stressed however that sending 32-bit
quantities over Modbus is not standardised, so you will need to carefully match the DT80's settings with the specific
device that you wish to read.
Using the MODBUS Channel
To poll a Modbus slave device, you use the
n
MODBUS
channel type. As mentioned above, the n specifies the physical
DT80 port: 1, 2 or 3 for a serial Modbus connection via the serial sensor port, host RS232 port or USB port respectively,
or 4 for network Modbus over TCP/IP (generally using the Ethernet port).
To read a single value, you simply define a
MODBUS
channel and specify appropriate channel options, as described
below. This definition is placed in a schedule, as you would for any other DT80 channel type.