Revision 1.1
WebSwitch™ Users Manual
3.4.4 Write Single Coil (Modbus Function Code 05 (0x05))
This function allows you to turn Outlets 1 and 2 on and off, one at a time.
Request
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length (2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x05 (write coil)
Outlet address (2 Bytes): 0x0000 or 0x0001 (outlet 1 = 0x0000, outlet 2 = 0x0001)
Outlet value (1 Byte): 0xff - turn outlet on, 0x00 - turn outlet off
Padding (1 Byte): 0x00
Character String Example:
char write_coil_mb_request[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06,
0xff, 0x05, 0x00, 0x00, 0xff, 0x00};
Response
Modbus/TCP:
Transaction identifier (2 Bytes): 0x0001
Protocol identifier (2 Bytes): 0x0000
Length(2 Bytes): 0x0006
Unit identifier (1 Byte): 0xff
Modbus:
Function code (1 Byte): 0x05 (write coil)
Outlet address (2 Bytes): 0x0000
Outlet value (1 Byte): 0xff - outlet on, 0x00 - outlet off
Padding (1 Byte): 0x00
Modbus Error:
Function code (1 Byte): 0x85
Exception code (1 Byte): 0x01 or 0x02
Exception Codes:
0x01 - Function code not supported.
0x02 - Incorrect starting address / quantity of outlets combination.
Character String Example:
char write_coils_mb_response[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x06,
0xff, 0x05, 0x00, 0x00, 0xff, 0x00 };
Xytronix Research & Design, Inc.
80