Commit 380aca41fc7c6dbe9b5b2cf1d4d24467bf7b7e1a
1 parent
aa8d24dc
Update protocol.md
Showing
1 changed file
with
25 additions
and
0 deletions
documentation/protocol.md
| ... | ... | @@ -242,3 +242,28 @@ specifies the quantity of complete bytes of data. |
| 242 | 242 | |
| 243 | 243 | #### Error |
| 244 | 244 | |
| 245 | +| Description | #Bytes | Value | | |
| 246 | +|---|---|---| | |
| 247 | +| Function Code | 1 Byte | <strong>Function code + 0x80</strong> | | |
| 248 | +| Exception Code | 1 Byte | 01, 02, 03 or 04 | | |
| 249 | + | |
| 250 | +Here is an example of a request to read discrete output 20-38: | |
| 251 | + | |
| 252 | +|Request | ++ | Response | ++ | | |
| 253 | +|--------|----|----------|----| | |
| 254 | +| Field Name | (Hex) | Field Name | (Hex) | | |
| 255 | +| Function | 0x01 | Function | 0x01 | | |
| 256 | +| Starting Address Hi | 0x00 | Byte Count | 0x03 | | |
| 257 | +| Starting Address Lo | 0x13 | Outputs status 27-20 | 0xCD | | |
| 258 | +| Quantity of Outputs Hi | 0x00 | Outputs status 25-28 | 0x6B | | |
| 259 | +| Quantity of Outputs Lo | 0x13 | Outputs status 38-36 | 0x05 | | |
| 260 | + | |
| 261 | +The status of outputs 27–20 is shown as the byte value CD hex, or binary 1100 1101. Output | |
| 262 | +27 is the MSB of this byte, and output 20 is the LSB. | |
| 263 | +By convention, bits within a byte are shown with the MSB to the left, and the LSB to the right. | |
| 264 | +Thus the outputs in the first byte are ‘27 through 20’, from left to right. The next byte has | |
| 265 | +outputs ‘35 through 28’, left to right. As the bits are transmitted serially, they flow from LSB to | |
| 266 | +MSB: 20 . . . 27, 28 . . . 35, and so on. | |
| 267 | +In the last data byte, the status of outputs 38-36 is shown as the byte value 05 hex, or binary | |
| 268 | +0000 0101. Output 38 is in the sixth bit position from the left, and output 36 is the LSB of this | |
| 269 | +byte. The five remaining high order bits are zero filled. | |
| 245 | 270 | \ No newline at end of file | ... | ... |