I am connecting a Modbus gateway to an RTU acquisition system. I am using a MOXA Gateway MB3480 with a RS485 (2 wires) connector. The thing is that I can't read the data all the time; I receive a time-out error.
My settings:
- Port in RTU slave mode, baudrate 9600, parity none. I have tried it with and without a resistor in the bus.
What I have tried:
- Request data with QModMaster, most of the times the result is: time-out error.
- Request data with Python. Same result. Code:
from pymodbus.pdu import ModbusRequest
from pyModbusTCP.client import ModbusClient
import time
c = ModbusClient(host="192.168.88.4", port=502, unit_id=2, auto_open=True, auto_close=True)
while True:
try:
regs = c.read_holding_registers(6, 1)
b = regs[0]/1000.0
a = round((b-4)/0.16,2)
print(a)
except:
print("Read error")
time.sleep(3)
I have tried an USB adapter and with a Raspberry Pi running Modbus RTU, it works; I can read the data. After changing the wires to the Moxa's gate, it only works sometimes. I have got the GND signal connected too.
I have tried sniffing the traffic with Traffic Monitor from Mgate Manager. I can see illegal packet (CRC) in the comments.
- I have tried updating the firmware.
Where can the problem come from?