
Modbus RTU Function Codes
02/13 Modbus® RTU Serial Communications User Manual 13
3.1 Function Code 01 – Read Digital Output Status
Description
Function code 01 (0X references) is used to read a Digital Output’s (DO) ON/OFF status of the slave device
in a binary data format. All binary data transferred using function code 01 is mapped into bytes.
The specific number of Dos available in an instrument or available via one Function Code 01 message is
instrument-model specific.
Broadcast is not supported.
Query
The query message specifies the starting DO and the quantity of coils to read. Dos are addressed starting at
zero: DO 1 through 16 are addressed as 0 through 15 respectively.
Query message format for function code 01
Slave
Address
Function
Code
Starting
Address
High
Starting
Address
Low
Number
DO
High
Number
DO
Low
CRC CRC
Example:
Read Dos number 1 to 7 from slave at address 02.
02 01 00 00 00 07 CRC CRC
Response
The DO status in the response message is packed as one DO per bit of the data field. Status is indicated as: 1
= ON; 0 = OFF. The LSB of the first data byte contains the DO addressed in the query. The other Dos
follow toward the high order end of this byte, and from low order to high order in subsequent bytes.
If the returned DO 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 data bytes
returned.
Response message format for function code 01
Slave
Address
Function
Code
Byte
Count
Data Data … CRC CRC
Example:
Dos number 2 and 7 are on, all others are off.
02 01 01 42 CRC CRC
In the response the status of Dos 1 – 7 is shown as the byte value 42 hex, or 0100 0010 binary. DO 8 is the
MSB of this byte, and DO 1 is the LSB. Left to right, the status of DO 7 through 1 is: ON-OFF-OFF-OFF-
OFF-ON-OFF. DO #8 was not requested and so bit #7 or the MSB was padded with a 0.
Comentários a estes Manuais