20
2.3.2 MODBUS Packet Format - Write
Write to Holding Registers:
GAP = A gap in transmission of 3.5 character frames indicates to the slaves that a new packet
is to follow. No transmission gaps within a packet may exceed 1.5 character frames.
Byte 1 = Device Address: Address 0 is a broadcast address that all units respond to regardless
of programmed address. All other addresses can be programmed and used in this mode.
Byte 2 = Function Code: When writing to holding registers, this byte is “10h”
Data Block = Begins with the number of the first register to be written (two bytes), followed
by the number of registers to be written (two bytes), in either command or response packets.
In a command packet the programming data for the first register will be the next two bytes
followed by programming data for subsequent registers.
Last 2 Bytes = Error Checking CRC – Lo Byte & Hi Byte
Table 2.5 Write Registers Command Format
GAP
3.5
Char
Device
Address
Function
Code
# of First
Register to be
written to Hi
# of First
Register to be
written to Lo
# of Registers
to Write Hi
# of Registers
to Write Lo
Min. 80h 10h 10h 00h 00h 04h
Byte
Count
Program Data for
First Register
Hi
Program Data for
First Register
Lo
Program Data for
Second Register
Hi
Program Data for
Second Register
Lo
08h 00h 01h 03h 60h
……
……
Program Data for
Last Register Hi
Program Data for
Last Register Lo
CRC
Lo
CRC
Hi
…… …… 00 01 xx xx
Table 2.6 Write Registers Response Format
GAP
3.5
Char
Device
Address
Function
Code
# of First
Register to
be written to
Hi
# of First
Register to
be written to
Lo
# of
Registers
to Write
Hi
# of
Registers
to Write
Lo
CRC
Lo
CRC
Hi
Min. 80h 10h 01h 00h 00h 04h xx xx