Modbus/TCP & Modbus RTU Function Codes
Function Codes 16 (10h) - Preset Multiple Registers
32 HC900 Hybrid Controller Communications User Guide Revision 4
9/03
4.9 Function Codes 16 (10h) - Preset Multiple Registers
Description
Presets values into a sequence of holding registers (also refered to as 4X references). The HC900 does not
support Broadcast. The register assignments specified in Section 6 with an access type “W”, can be written
to via Function Code 16 (10h).
Writing to half of a digital variable will be accepted. A non-zero write to either register will result in a
floating point 1 to be written to the variable. Writing a zero to either register will result in the variable
being set to 0.
Query
The query message specifies the register references to be preset. Registers are addressed starting at zero:
Register 1 is addressed as 0.
Example:
Preset Rack #1, Variable #1 (address 18C0h) to 100.0 in the controller at slave address 1.
Query message format for function code 16 (10h)
Slave
Address
(00 for
TCP)
Function
Code
Start
Address
High
Start
Addres
s Low
Number
Addresse
s High
Number
Addresses
Low
Byte
Count
Data CRC
(RTU)
CRC
(RTU)
TCP
Example
00 10 18 C0 00 02 04 42 C8 00 00
RTU
Example
01 10 18 C0 00 02 04 42 C8 00 00 CRC CRC
Response
The normal response returns the slave address, function code, starting address and the quantity of registers
preset.
The floating point values require two consecutive addresses. A request to preset a single floating point
value must be for two addresses. The byte order of the floating point number is determined by the setting
of the byte swap configuration value. In this example the byte swap order is FP B. Refer to subsection 1.3.
The first 16 bits of the response contain the IEEE MSB of the float value. The second 16 bits of the
response contain the IEEE LSB of the float value. The Byte order is configurable See Subsection 1.3. If
the master station requests only one address at an address of a floating point value the slave will respond
with an illegal data address exception code (See Section 5).
Example:
Response from presetting Rack #1, Variable #1 (address 18C0h) to 100.0 from the controller.
Response message format for function code 16 (10h)
Slave
Address
(00 for
TCP)
Function
Code
Start
Address
High
Start
Address
Low
Number
Addresse
s High
Number
Addresses
Low
CRC
(RTU)
CRC
(RTU)
TCP Example 00 10 18 C0 00 02
RTU Example 01 10 18 C0 00 02 CRC CRC