User manual
Modbus RTU 3MN744
Coils (Modbus 0xxxx Reference Set)
Coils are read/write control bits. They provide control, source and command features of the Modbus interface.
The following standard Modbus functions codes are supported.
Read Coils (Function Code 01)
This function code is used to read the status of from 1 to 2000 contiguous coils in a remote device. The Request
PDU specifies the starting address, ie the address of the first coil specified, and the number of coils. Coils are
addressed starting at zero. Therefore, coils 1-16 are addressed as 0-15.
The coils in the response message are packed as one coil per bit of the data field. Status is indicated as 1= ON
and 0= OFF. The LSB of the first data byte contains the output addressed in the query. The other coils follow
toward the high order end of this byte, and from low order to high order in subsequent bytes. If the returned
output quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeros (toward
the high order end of the byte). The Byte Count field specifies the quantity of complete bytes of data.
Request PDU
Function Code 1 Byte 0x01
Starting Address 2 Bytes 0x0000 to 0xFFFF
Quantity of Coils 2 Bytes 1 to 2000 (0x7D0)
Response PDU
Function Code 1 Byte 0x01
Byte Count 1 Byte N*
Coil Status n Byte n=N or N+1
*N = Quantity of outputs/8, if the remainder is different of 0⇒ N=N+1
Error
Error Code 1 Bytes 0x0000 to 0xFFFF
Exception Code 1 Bytes 1 to 2000 (0x7D0)
Example of a request to read discrete outputs 20-38:
Request Response
Field Name (Hex) Field Name (Hex)
Function 01 Function 01
Starting Address Hi 00 Byte Count 03
Starting Address Low 13 Output Status 27-20 CD
Quantity of Outputs Hi 00 Output Status 35-28 6B
Quantity of Outputs Lo 13 Output Status 38-36 05
The status of outputs 27-20 is shown as the byte value CD hex, or binary 1100 1101. Output 27 is the MSB of
this byte, and output 20 is the LSB. By convention, bits within a byte are shown with the MSB to the left, and the
LSB to the right. Thus, the outputs in the first byte are `27 through 20', from left to right.
The next byte has outputs `35 through 28', left to right. As the bits are transmitted serially, they flow from
LSB to MSB: 20 . . . 27, 28 . . . 35, and so on.
In the last data byte, the status of outputs 38-36 is shown as the byte value 05 hex, or binary 0000 0101. Output
38 is in the sixth bit position from the left, and output 36 is the LSB of this byte. The five remaining high order bits
are zero filled.
Address Hi Address Lo
Outputs Value Hi Outputs Value Lo
Hex:
Binary:
C
1 1 0 0
Coil: 27 26 25 24
D
1 1 0 1
23 22 21 20
0
0 0 0 0
35 34 33 32
1
0 0 0 1
31 30 29 28