入力ステータスの読み取り (FC=02)

要求

このコマンドは、アドレス17のスレーブデバイスからディスクリート入力#10197〜10218のオン/オフステータスを要求しています。

11 02 00C4 0016 BAA9

11: The Slave Address (11 hex = address17 )
02: The Function Code 2 (read Input Status)
00C4: The Data Address of the first input to read.
( 00C4 hex = 196 , + 10001 offset = input #10197 )
0016: The total number of coils requested. (16 hex = 22, inputs 197 to 218 )
BAA9: The CRC (cyclic redundancy check) for error checking.

応答

11 02 03 ACDB35 2018

11: The Slave Address (11 hex = address17 )
02: The Function Code 2 (read Input Status)
03: The number of data bytes to follow (22 Inputs / 8 bits per byte = 3 bytes)
AC: Discrete Inputs 10204 -10197 (1010 1100)
DB: Discrete Inputs 10212 - 10205 (1101 1011)
35: 2 space holders & Discrete Inputs 10218 - 10213 (0011 0101)
2018: The CRC (cyclic redundancy check).

上位ビットには、上位の離散入力が含まれます。これは、入力10197がオフ(0)で、10204がオン(1)であることを示しています。要求された入力の数のために、最後のデータフィールド35 は、6つの入力のみのステータスを含む。このデータフィールドの最上位2ビットはゼロで埋められます。