Complete newbie here o please pardon my insufficient information.
I am trying to work with a bus coupler module XEL-BSSRT along with an input module XBE-DC08A to read a 24 V photoelectric sensor output. I can see the outputs on the module itself through the LED and also see it on the monitoring tool using XG5000 (PLC Software by the manufacturer).
Now, I am trying to use the pyModbusTCP to access the sensor output and I am lost of which address to use.
There is an addressing tool that gives me addresses in Hex, but that doesn’t seem to deliver the output. Please find the screenshot below:
Here is the Python code I am using:
import time
from pyModbusTCP.client import ModbusClient
# init modbus client
c = ModbusClient(host='192.168.1.101', port=502, unit_id=1, auto_open=True, debug=True)
c.close
c.open
# main read loop
while True:
# read 10 bits (= coils) at address 0, store result in coils list
# coils_l = c.read_coils(0, 6)
coils_l = c.read_holding_registers(2,5)
print(coils_l)
# if success display registers
if coils_l:
print('coil ad #0 to 9: %s' % coils_l)
else:
print('unable to read coils')
# sleep 2s before next polling
time.sleep(1)
I added c.close
and c.open
to make sure the connection stays open.
Here is the output:
Tx
[D0 81 00 00 00 06 01] 03 00 02 00 05
recv error
None
unable to read coils
Tx
[41 CE 00 00 00 06 01] 03 00 02 00 05
recv error
None
unable to read coils
Tx
[CA F6 00 00 00 06 01] 03 00 02 00 05
recv error
None
unable to read coils
Tx
[32 28 00 00 00 06 01] 03 00 02 00 05
recv error
None
unable to read coils
Please let me know where my mistake is and if there is anyplace I can find more information on this, please point me in that direction.
Any help is much appreciated.