UM-0085-B09
DT80 Range User Manual
Page 364
RG
When the channel is executed, the DT80 will send a "read" request to the specified device, wait for its response, do any
requested scaling or statistics on the returned value, then log or return the final reading.
To write a value, an expression is specified, as you would when setting a channel variable. For example,
1MODBUS(...)=1CV*2
will set the required register on the required Modbus slave device (as specified in the channel options) to the value of
1CV multiplied by 2.
Note:
If the value being written is outside the range of the target Modbus register then it will be set to the registers minimum or
maximum value, e.g.
4MODBUS(AD"10.23.0.4",R4:7)=239999
4MODBUS 65535
MODBUS Channel Options
Channel options are used to specify
•
which Modbus sensor to access, i.e. its network address
•
which register(s) to access
•
how to interpret the register value (signed or unsigned? 16 or 32 bit?)
•
how to scale the result into the correct engineering units
•
communications options such as timeouts
Of these, the first two (sensor address and register number) will normally always need to be specified. The remainder are
optional and the default values will be appropriate for many applications.
Address (AD)
For serial Modbus (
1
/
2
/
3MODBUS
), the slave device address is specified using the
AD
n
option, where n is the numeric
slave address (1-247). Address 0 can also be used, which will broadcast a write command to all connected slave
devices. Slave devices never reply to a broadcast request.
For network Modbus (
4MODBUS
), use
AD"
ip-addr
"
, where
ip-addr
is either a numeric address (e.g.
192.168.11.160
)
or a symbolic address (e.g.
myplc.llamas.org
). The address can optionally be suffixed by a port number e.g.
AD"192.168.1.2:5555"
if the default port (502) is not suitable.
Note:
symbolic addresses are resolved when the channel is defined (i.e. when the program is started), not when the channel is
evaluated. Using slave devices with dynamically allocated IP addresses are therefore not recommended, as an error will result if the IP
address changes during operation.
Register (R)
To specify the register number to read/write, use the
R
type
:
num
channel option. That is, the register number is specified
using the "6-digit" notation with a colon (:) separator between the register type (0/1/3/4) and the register number (1-
65536).
For example,
R3:27
specifies the device's 27th input register. (At the protocol level, the DT80 would send a "read
register" command and specify address 26, or 001A.)
A complete channel definition would therefore be something like:
1MODBUS(AD2,R3:27)
which will read register 1:00027 (input register #27) on the device with address 2 connected to the DT80 serial sensor
port.
For 1-bit Modbus registers, i.e. coils (type 0) and discrete inputs (type 1), it is also possible to read/write up to 16 bits at
once. This is done by adding an extra field onto the end of the
R
channel option to specify the number of consecutive 1-
bit registers to pack into one value. The full syntax for this option is therefore
R
type
:
num
:
bits
, where
bits
is a number
between 1 and 16 (default 1). The
:
bits
part is only valid if a 1-bit register
type
is specified, i.e. type is 0 or 1.
For example,
R1:64
will read discrete input #64 and return its value (0 or 1). On the other hand,
R1:64:8
will read
discrete inputs #64 through #71 and return them as an 8-bit bitmask (0 to 255). Input #64 will be the least significant bit
(bit 0), input #71 will be the most significant bit (bit 7).
Data Format (MBx, MEx)
Modbus registers contain 16 bit integer values. By using the following channel options, however, pairs of consecutive
registers can be interpreted as containing a 32 bit integer or floating point value.