I have a python code here to read input register and it is working, but it doesn't display the register in HMI Droid Studio appliaction. Here is the code:
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
import time
Kanban1 = 0
#Open TCP Port
#client = Modbus ('192.168.43.136')
client = ModbusClient ('192.168.4.189')
client.connect()
rq = client.write_register(0,100)
try:
while True:
rr = client.read_holding_registers(0,50)
print rr.registers
if(rr.registers[Kanban1] < 100):
print "Reading Registers"
time.sleep(1)
except KeyboardInterrupt:
client.close()
print "Finish"
any help is appreciated Thank you
一些HMI默认使用基于1的寄存器号链接到基于0的Modbus寄存器号,尝试设置/使用寄存器1而不是零
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.