Page 7 / 15
PV500-67 03/17
3.2 WRITE SINGLE COIL (0x05):
Write to a single Coil. For multiple coils, use multiple commands. You SET (1) the coil by sending 0xFF00 in the Data
field. You RESET (0) the coil by sending 0x0000.
3.2.1 MASTER COMMAND TO WRITE SINGLE COIL (0x05):
Slave Address:
(1 byte): Device address that receives the command. Range: 1-247.
Function Code:
(1 byte): Code = 0x05 (Read Output Coil).
Coil Address:
(2 bytes): The address of the first coil to be read, reading multiple registers is sequential.
Data:
(2 bytes): 0x000 will RESET (0), and 0xFF00 will SET (1) the coil.
CRC:
(2 bytes): CRC calculated for the frame data received and is used to verify the integrity of data received.
3.2.2 SUCCESSFUL RESPONSE, WRITE SINGLE COIL (0x05):
Slave Address:
(1 byte): The address of the slave responding. Same as the address in the initiating command.
Function Code:
(1 byte): Code = 0x05 Echo from the initiating command.
Coil Address:
(2 bytes): Echo from initiating command.
Data:
(2 bytes): Echo from initiating command.
CRC:
(2 bytes):
3.2.3 EXCEPTION RESPONSE, WRITE SINGLE COIL (0x05):
Slave Address:
(1 byte): The address of the slave responding. Same as the address in the initiating command.
Exception Response:
(1 byte): Code = 0x05 Echo from the initiating command plus high bit 0x80 = 0x85.
Exception Code:
(1 byte): Defines the number of bytes followed minus the CRC. See Table 1 for explanation of
exceptions.
CRC:
(2 bytes):
Slave
Address
Function
Code 0x05
Coil
Address
(MSByte)
Coil
Address
(LSByte)
Data
(MSByte)
Data
(LSByte)
CRC
(LSByte)
CRC
(MSByte)
Slave
Address
Success
Echo
Code 0x05
Coil
Address
(MSByte)
Coil
Address
(LSByte)
Data
(MSByte)
Data
(LSByte)
CRC
(LSByte)
CRC
(MSByte)
Slave
Address
Exception
0x05 + 0x80
Error: 0x85
Exception
Code
see list
CRC
(LSByte)
CRC
(MSByte)