UM-0085-B09
DT80 Range User Manual
Page 178
RG
There are, however, a number of options for dealing with data values that cannot be represented by a 16-bit integer
value:
•
the register can be treated as an unsigned 16-bit integer (0-65535)
•
the value can be scaled, typically by a power of ten, to give the required precision or range. For example a
scaling factor of 100 would permit values in the range -327.68 to 327.67 to be returned
•
multiple registers can be combined to return a single larger value, e.g. a pair of registers could return a 32-bit
quantity
Clearly, both the slave device and the client system must agree on how a given Modbus register is to be interpreted. It is
no good if the device encodes the value 40000 as an unsigned 16-bit number (9C40 hexadecimal) but then the client
interprets it as a signed number and displays it as -25536.
The only solution is to explicitly configure the required data types on both the slave and the client. For the
DT80
, this is
done using the
SETMODBUS
command.
The SETMODBUS Command
By default, all CV values are transferred to and from the
DT80
as signed 16-bit integers, with no scaling factor. The
SETMODBUS
command is used to specify alternative data types and scaling factors.
The format of the command is as follows:
SETMODBUS
channels
format
scaling
where:
•
channels
specifies a single channel variable, or a range (e.g.
1CV
or
20..29CV
)
•
scaling
is an optional floating point scaling factor by which the channel value will be multiplied before being
returned. Conversely, when the client writes a value, it will be divided by the scaling factor before being written
to the CV.
•
format
is an optional code that specifies the data type, as follows:
Format code
Data type
Comments
MBI
signed 16-bit integer
Default setting. Returns -32768 or 32767 if the scaled return value is outside the
valid range.
MBU
unsigned 16-bit integer
Returns 0 or 65535 if the scaled return value is outside the valid range.
MBLS
(or
MBL
)
signed 32-bit integer,
standard word order
Upper 16 bits of
n
CV are returned in Modbus register
n
. Lower 16 bits are
returned in register
n
+1. Returns -2,147,483,648 or 2,147,483,647 if the scaled
return value is outside the valid range.
MBLR
signed 32-bit integer,
reversed word order
Lower 16 bits of
n
CV are returned in Modbus register
n
. Upper 16 bits are
returned in register
n
+1. Returns -2,147,483,648 or 2,147,483,647 if the scaled
return value is outside the valid range.
MBFS
32-bit floating point,
standard word order
Returned as a single precision IEEE-754 floating point number. Upper 16 bits of
n
CV are returned in Modbus register
n
. Lower 16 bits are returned in register
n
+1.
MBFR
(or
MBF
)
32-bit floating point,
reversed word order
Returned as a single precision IEEE-754 floating point number. Lower 16 bits of
n
CV are returned in Modbus register
n
. Upper 16 bits are returned in register
n
+1.
If
format
and
scaling
are not specified, the current settings for the indicated range of CVs are displayed.
Any number of these
SETMODBUS
commands can be issued (typically at the start of the
DT80
job) to configure the
required channels.
The
SETMODBUS
command only supports channel variables. However some system variables may have values outside
the range -32768 to 32767, or may have a fractional part. Such SVs can be assigned to a CV, for which an appropriate
data type and/or scaling factor can then be set, e.g.:
SETMODBUS 1CV MBLS
3SV(=1CV)
Example
This example illustrates some of the technicalities relating to Modbus transfers. Consider the following job:
BEGIN"PERCY"
SETMODBUS 7CV MBF
SETMODBUS 9..10CV MBU 100
SETMODBUS 11CV MBL
7CV=23.91 8CV=42 9CV=490.22 10CV=921.0 11CV=75535.9
END