Application note
Integrated Modbus support
AN00198
ABB Motion control products
14
new.abb.com/motion
Check boxes are provided to configure the byte and word order of the Modbus data (set to Big Endian by default for
compatibility with other ABB products supporting Modbus RTU operation).
Note:
Support is included for broadcast write functions (i.e. to node ID 0) so node ID 0 should be avoided unless broadcast
functions are intended.
Example Mint Code
For operation as a Modbus RTU/TCP Server no Mint code is required. The Client device will access Netdata via the Modbus
register mappings detailed in the previous section.
The configuration process allows the user to define whether Modbus function code 03 or 04 is used by the Client when reading
data from another Modbus TCP device. The Modbus TCP Client always uses function code 16 to write to Modbus data on a
connected Server device (even when accessing a single register).
For operation as a Modbus TCP Client the Mint keywords MODBUSTCP16 (to access a single 16 bit Modbus register),
MODBUSTCP32 (to access a pair of 16 bit Modbus registers) and MODBUSTCPFLOAT (to access a single 32 bit floating point
Modbus register) are used.
Example 1:
Client e180 wishes to take data from a local integer variable and write this to Netinteger(3) on a MicroFlex e190 via Modbus
TCP. The MicroFlex e190 has IP address 192.168.0.11 and is configured as Server
ID 4 in the list of connected devices…
Dim nValue As Integer
MODBUSTCP32 (4, 6) = nValue
Example 2:
Client e180 wishes to read data from a remote NETFLOAT location 2 on another MotiFlex e180 via Modbus TCP. The MotiFlex
e180 (Server) has IP address 192.168.0.2 and is configured as Server ID 1
in the list of connected devices…
Dim fValue As Float
NETINTEGER(999) = MODBUSTCP32 (1, 4)
fValue = NETFLOAT(999)
Because all Modbus data is transferred as an integer note the use of a local (unused) Netdata location (999) in this example to
perform the “conversion” between a 32 bit integer representation of the floating point value (IEEE format) and the actual floating
point value stored in the variable ‘fValue’.
However, to avoid this additional processing a dedicated Modbus Client function, MODBUSTCPFLOAT is provided. This allows
the user to read 32-bit floating point data from a Server and transfer this directly to local data. Using the same example above
the code using MODBUSTCPFLOAT becomes…
Dim fValue As Float
fValue = MODBUSTCPFLOAT(1,4)