modbus_object.WriteSingleRegister Method

Writes a single holding register value to a MODBUS slave.

modbus_object.WriteSingleRegister(register, value)

Prerequisites

None

Parameters

register

A required Integer expression that specifies the number of the holding register to be written.

value

A required Integer expression that determines the output to be written to the holding register.

Remarks

This method issues a MODBUS/TCP Write Single Register request (function 6). The holding registers are 16-bit unsigned integer values. Only the low 16-bits of value are used. No error is reported if value is too big to fit in 16 bits. If more than one register is to be changed, it is much more efficient to use the WriteMultipleRegisters method than multiple WriteSingleRegister methods. A new connection to the MODBUS slave is made if none currently exists. If any network errors occur, this method throws an exception.

Examples

Dim ep As New IPEndPoint("192.168.0.150")
Dim mb As New Modbus(ep)
mb.WriteSingleRegister(1, 123)

See Also

Modbus Class |modbus_object.WriteMultipleRegisters