Question about Pymodbus read address #953
-
Pymodbus Specific
DescriptionHi all, I'm quite new to pymodbus and I have faced few problems and tried several method but still no solution. So the situation here is I try to read and write data to my IDEC PLC, right now I'm able to write my coil but I can't seem to read the coil. Python error is:
I'm curious about this, if I'm able to write to the correct coil which mean I able to read it right? but why can't I read it. Another question, I read the PLC modbus address, some of them are like 400001, 300001, when I key in those number it show me error. is the maximum is 16 bits?
I used this method with OMRON PLC and it work fine but when I changed to IDEC PLC, it doesn't work. Thank you very much for reading. Code and Logs # code and logs here.
from pymodbus.client.sync import ModbusTcpClient
import time
import datetime
import keyboard
IP_Address = "192.168.1.5"
PORT_NUM = 502
now = datetime.datetime.now()
client = ModbusTcpClient(IP_Address,PORT_NUM)
connected = client.connect()
print(connected)
if connected:
print("PLC Connection Found",IP_Address, "at", now)
while True:
now = datetime.datetime.now()
result = client.read_coils(5,10)
client.write_coil(5,1)
print(result.bits[5])
time.sleep(1)
print('done')
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Please read https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf chapter 4.3 and 4.4 That should help you. |
Beta Was this translation helpful? Give feedback.
Please read https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf chapter 4.3 and 4.4 That should help you.