Modbus RTU Master config

Topics about the Hardware of Revolution Pi
Post Reply
JuggeW
Posts: 7
Joined: 11 Feb 2025, 19:22

Modbus RTU Master config

Post by JuggeW »

Hi! Novice Pi:er here :)

Im trying to read from modbus rtu slave on RS485 but cant get any data from the device.
I have followed all the instructions and tried so many things but all fails.

This is my setup, RevPi connnect4, P terminal on RevPi is connected to B on flow meter and N terminal on RevPil is connected to A on flowmeter. Flowmeter address i 098.

Flowmeter manual say: White=Modbus B, Green Modbus - A, so I assume that A is negative.

Manual say: 9600-N-8-1
And:
Address
HEX DEC Data type Description Reading HEX Command Respond Unit
0000 0 INT32 Pos acc energy 0000000D 01 03 00 00 00 02 C4 0B 01 03 04 00 00 00 0D 3B F6 kWh
0002 2 INT32 Neg acc energy 00000024 01 03 00 02 00 02 65 CB 01 03 04 00 00 00 24 FA 28 kWh
0004 4 INT32 Temperature sensor Red 0000096C 01 03 00 04 00 02 85 CA 01 03 04 00 00 09 6C FC 4E 0.01 °C
0006 6 INT32 Temperature sensor Blue 00000970 01 03 00 06 00 02 24 0A 01 03 04 00 00 09 70 FD 87 0.01 °C
0008 8 INT32 Temperature difference 00000009 01 03 00 08 00 02 45 C9

I want to read addres 0 and 8.

I have tried to read address, 1, 2, 3, 4, 5, 6, 7, 8, 9 but all fails with the same info:
modbus rtu action device: /dev/ttyRS485, slave address: 98 function: 0x03, address: 4 failed -1/110/-112345568

I have set values in PICtory as:
piModbusMaster OUT Master_Status_Reset 0 BYTE

MEM device_path /dev/ttyRS485 STRING INFO: value modified to adapt base device type

MEM baud_rate 9600 DWORD

MEM parity None BYTE

MEM data_bits 8 BYTE

MEM stop_bits 1 BYTE


When I read piTest I get this:
pi@RevPi136442:~$ piTest -v Input_Word_4
variable name: Input_Word_4
offset: 243
length: 16
bit: 0
pi@RevPi136442:~$ piTest -r Input_Word_4
2 Byte-Value of Input_Word_4: 0 dez (=0000 hex)
2 Byte-Value of Input_Word_4: 0 dez (=0000 hex)
2 Byte-Value of Input_Word_4: 0 dez (=0000 hex)
^C
pi@RevPi136442:~$

Can someone give me some advice on how to get this to work on Connect4, all the info and guides are for older RevPis. To me its unclear if I need to terminate the terminals on RevPi (have tried with and without external 120 ohm resistor) and if I need to terrminate the flowmeter (have tried with and without resistor). I have the flowmeter attached directly to the RevPi connect4 with a short cable (2 m). No other devices are attached.

Thank you :)
JuggeW
Posts: 7
Joined: 11 Feb 2025, 19:22

Re: Modbus RTU Master config

Post by JuggeW »

No ideas from the forum?
User avatar
dirk
Posts: 2271
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Master config

Post by dirk »

What is in the various status registers, i.e. Master_Status, Action_Status_1 ...

Follow the steps in these helpful checklists, which have been created with great attention to detail:
Visualize communication with an oscilloscope or with a logic analyzer such as Saleae

Alternatively, try with a USB-RS485 interface without RevPi

[youtube_be]https://youtu.be/gaJ6-D4Vd6A?si=vNLgnhn11ikgiFod[/youtube_be]
JuggeW
Posts: 7
Joined: 11 Feb 2025, 19:22

Re: Modbus RTU Master config

Post by JuggeW »

Hi Dirk,

There is no file called resistor.c on the revPi.

Is there an instruction that is tailored to Connect 4 because the GUI is not the same as in the guides so its hard to follow the guides?

Br,

Jörgen
JuggeW
Posts: 7
Joined: 11 Feb 2025, 19:22

Re: Modbus RTU Master config

Post by JuggeW »

Hi again Dirk, I have tried to follow all the guides and tutorials that you posted but it doesnt work.

Obovously I dont want to add a USB RS485 because the Connect 4 have onboard RS485.

Have no more ideas right now..
User avatar
dirk
Posts: 2271
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Master config

Post by dirk »

Hello Jörgen, thank you for your patience. Here I have a Python script created with love from the development, which switches the terminating resistor. It works like this:

Code: Select all

pi@RevPi136828:~$ python3 rs485-termination.py /dev/ttyRS485-0 off
Termination disabled on /dev/ttyRS485-0

Code: Select all

pi@RevPi136828:~$ python3 rs485-termination.py /dev/ttyRS485-0 on
Termination enabled on /dev/ttyRS485-0
We are discussing the next steps, but the aim is to integrate the whole thing better, e.g. via the cockpit.
Attachments
rs485-termination.zip
(835 Bytes) Downloaded 1705 times
JuggeW
Posts: 7
Joined: 11 Feb 2025, 19:22

Re: Modbus RTU Master config

Post by JuggeW »

Thanks Dirk.

It would be nice to have integration in Pictory as you said :).

Br

Jörgen
Post Reply