我在这里有一个python代码来读取输入寄存器并且它正在工作,但它不会在HMI Droid Studio应用程序中显示寄存器。这是代码:
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"
任何帮助表示赞赏 谢谢
答案 0 :(得分:1)
某些HMI默认使用基于1的寄存器号链接到基于0的Modbus寄存器号,请尝试设置/使用寄存器1而不是零