Modbus RTU devices connection
-
Hi all,
I am trying to connect RS485 devices to Neuron M203 over modbus rtu protocol.I have started from raspbian kernel and then installed kernel modules from unipi repository: https://repo.unipi.technology/debian/
ending up with kernel:
Linux M203-sn21 5.10.17-v7+then I can see the serial device in: "/dev/extcomm/0/0" ("/dev/ttyNS0")
However, when I switch in my minimal python script from existing serial interface connected to USB (USB<->RS458 converter) to the ttyNS0 device I get timeout error (No communication/answer). The TX light on Neutron blinks once when I send the request.
#!/usr/bin/env python3 import minimalmodbus #instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1, minimalmodbus.MODE_RTU) instrument = minimalmodbus.Instrument('/dev/ttyNS0', 1, minimalmodbus.MODE_RTU) instrument.serial.baudrate=9600 instrument.serial.bytesize = 8 instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN PV = instrument.read_register(4096, 1) print("PV: ", PV, "C")
in Evok I have added the setting for the UART Port:
Could you please advise me how to setup Neuron as a master for RS-485 communication?
Thanks,
Jaroslav -
Hi @padeja,
the /dev/ttyNS* ports are independent of the Evok and you should configure them in Evok in any way, if you wish to access them from your program. Try removing the configuration you did in the Evok.Best regards,
Martin -
Hi @Martin-Kudláček,
thank you for you reply and the important information that the serial device ttyNS* has nothing to do with Evok.
I was actually trying just before installing Evok simply swap the USB-RS485 converter device to the Neuron serial interface in my script, but it didn't work as such. I was testing the connection also from CLI using mbpoll but with the same result - no communication / answer. -
@padeja said in Modbus RTU devices connection:
Hi @Martin-Kudláček,
thank you for you reply and the important information that the serial device ttyNS* has nothing to do with Evok.
I was actually trying just before installing Evok simply swap the USB-RS485 converter device to the Neuron serial interface in my script, but it didn't work as such. I was testing the connection also from CLI using mbpoll but with the same result - no communication / answer.when I look at USB vs Neron serial device configurations using setserial, I receive following:
pi@M203-sn21:~ $ setserial -ag /dev/ttyUSB0 /dev/ttyUSB0, Line 0, UART: unknown, Port: 0x0000, IRQ: 0 Baud_base: 24000000, close_delay: 0, divisor: 0 closing_wait: infinite Flags: spd_normal pi@M203-sn21:~ $ setserial -ag /dev/ttyNS0 /dev/ttyNS0, Line 0, UART: undefined, Port: 0x0000, IRQ: 201 Baud_base: 600, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal low_latency
I would say at least UART type and Baud_base should be configured. Did I miss a step in Neuron configuration?
-
The firmware update from 4.6 to 5.56 made the trick and the /dev/ttyNS0 now works as expected, therefore it can be used as Modbus master as intended.
nipi@M203-sn21:~$ sudo /opt/unipi/tools/fwspi --auto Board on /dev/unipispi firmware=4.6 hardware=0.1 (B-1000) (spi 6MHz) New firmware 5.56 for device id=0 fw=4.6 REBOOTING... Board on /dev/unipispi firmware=4.6 hardware=8.1 (E-16Di_U-14Ro) (spi 6MHz) New firmware 5.56 for device id=1 fw=4.6 REBOOTING...
thanks @Martin-Kudláček for your help!