Acsess Input Data over Modbus RTU
christophebler last edited by tomas_hora
I am trying to setup my UniPi Neuron xS50 using a Neuron S103 as main CPU.
Here are the steps that I have performed:
- Install pymodbus
- Connect the RS485 lines of s103 and xS50
- Turn on the bus terminator on both devices.
- Created the following python script
Set Adress to 0 and rebooted both devices
from pymodbus.client.sync import ModbusSerialClient c = ModbusSerialClient(method = 'rtu',port ='/dev/extcomm/1/0',baudrate=19200) if 1: rs = c.read_holding_registers(2, 1, unit=0) x = float(rs.getRegister(0)) print x c.close()
If I execute this program I get the following error
File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 84, in execute raise ConnectionException("Failed to connect[%s]" % (self.__str__())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[rtu baud]
Does anybody know what I am doing wrong?
I am not sure if pymodbus works well.. But what is more important if everything below is isntalled correctly.
So a few steps (for 1 and 2 I recommend to use the our opensource image):
- What OS are you using?
- How did you install the overlay and neuron TCP server?
- Does the /dev/extcomm/1/0 file exists?
christophebler last edited by christophebler
Thank you for your fast response.
Currently am using the newest Raspian Stretch immage from the official Homepage.
I have cloned the Modbus TCP overlay from github and istalled it.
I am able to controll the onbord IO of th Neuron S103 using the modbus TCP server.
If I run: sudo ls /dev/extcomm/1/ I get 0 as a resault so i assume that the tcp overlay is working.
pi@Device:~ $ sudo ls /dev/extcomm/1 0 pi@Device:~ $ sudo ls /dev/extcomm/1/0 /dev/extcomm/1/0
if pymodbus is not the best choice what woud you suggest instead ?
I woud Prefer python or c / c++ as a Programmin language.
@christophebler Ok, than the serial line works well. But I still recommend using our opensource image because the parameters that can be set using the github version is limited and might cause some troubles which are fixed in the opensource image.
Byt the way, what do you want to do by 'Set Adress to 0 and rebooted both devices'? You can set address only at the slave which is the xS50 and if you set it to 0, than the SW configuration is used (address 15, 19200bps, no parity) and you are opening different device...
Address 0 is not allowed on Modbus, thus the behavior like I described.