smartDEN IP-16R-XX User Manual
13 Apr 2021
10.2.1.1. Write Single Coil
This command will turn single relay output to ON or OFF.
Request
The Write Single Coil request specifies the address of the coil to be forced:
Address: 0x0000 (Relay 1) to 0x000F (Relay 16)
A value of 0xFF00 requests the coil to be ON, a value of 0x0000 requests the coil
to be OFF, and a value of 0xFF02 toggles the coil state. All other values are illegal
and will not affect the coil state.
Note: If the address exceeds 16, an error response will be returned.
Request example: Write Single Coil 2 (Relay 2) to ON:
Table 10.13. Write Single Coil request
Response
The response indicates the new state of the relay.
Response: Write Single Coil 2 (Relay 2) to ON:
Table 10.14. Write Single Coil reply
Error
The possible error responses for function code 0x05 are:
Function Code (1 byte): 0x85 (0x80 + 0x05)
Exception Codes (1 byte):
- 0x01 – Function code not supported
- 0x02 – Incorrect relay address
- 0x03 – Illegal relay value
Error response example: