How to write to PLC input registers using pymodbus

user3053231 picture user3053231 · Aug 10, 2015 · Viewed 11.3k times · Source

I want to write to PLC input registers using pymodbus. I am able to read them :

from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('10.10.10.32')
client.connect()
reg = client.read_input_registers(1,5)
print(reg.registers)

But I still did not found any way how to write any value to them. I appreciate any help. Thanks.

Answer

Ronaldo picture Ronaldo · Aug 10, 2015

Input registers are read-only. You can write to holding registers, using Modbus functions Write Single Register or Write Multiple Registers (ModbusTcpClient.write_register or ModbusTcpClient.write_registers in pymodbus).