2.2.1 01 Read Coil Status
Reads the ON / OFF status of discrete outputs (0
x references, coils) in the slave. Broadcast is
not supported. The maximum parameters supported by various controller
models are listed on
page .
Query
The query message specifies the starting coil and quantity of coils to be read. Coils are
addressed starting at zero-coils 1 ... 16 are addressed as 0 ... 15.
Here is an example of a query to read coils 20 ... 56 from slave device 17:
http://www.modicon.com/techpubs/dcon7.html (5 of 36) [1/11/2000 10:41:04 PM]
Response
The coil status in the response message is packed as one coil per bit of the data field. Status is
indicated as: 1 = ON; 0 = OFF. The LSB of the first data byte contains
the coil 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 coil 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.
Here is an example of a response to the query:
The status of coils 27 ... 20 is
shown as the byte value CD hex, or binary 1100 1101. Coil 27 is
the MSB of this byte, and coil 20 is the LSB. Left to right, the status of coils 27 ... 20 is
ON-ON-OFF-OFF-ON-ON-OFF-ON.
By
convention, bits within a byte are shown with the MSB to the left, and the LSB to the right.
Thus the coils in the first byte are 27 ... 20, from left to right. The next byte has coils 35 ... 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 coils 56 ... 52 is shown as the byte value 1B hex, or binary
0001 1011. Coil 56 is in the fourth bit position from the left, and coil 52 is the LSB of this byte.
http://www.modicon.com/techpubs/dcon7.html (6 of 36) [1/11/2000 10:41:04 PM]
The status of coils 56 ... 52 is: ON-ON-OFF-ON-ON.
Chia sẻ với bạn bè của bạn: