Modbus RTU Master register address

Topics about the Hardware of Revolution Pi
Post Reply
RMeissnerCC
Posts: 58
Joined: 03 Dec 2019, 10:29

Modbus RTU Master register address

Post by RMeissnerCC »

Dear all,
I use a RevPiCore 3+ with a USB-2-RS485 adapter to read modbus signals from a sensor. According to the sensors manufacturer, the registers I want to read are 8 and 9. If I set these up in the virtual Modbus RTU Master in piCtory and read them with piTest I saw mainly zeros. Only when I startet to look at the process image more broadly with, e.g. "piTest -r 326,10", with 326 the address of register 8 which I received from "piTest -v REGISTER_8", I saw the correct value for register 8. I played around with rebooting the revpi after changing the pictory configuration, checking with my old application, unplugging the usb connector, etc. etc. until I found out that if I read register 9, I get the value for register 8. If I read register 10, I get the value for register 9.
I double checked with the manufacturer and my own program that these registers are correct.
What am I doing wrong? Is there a bug in piCtory?
What kind of data do you need to be able to follow my explanation better?
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Master register address

Post by dirk »

Hr RMeissnerCC, the question is how the Extended Data configuration of the Modbus Master looks like?
Have a look at the tutorial How to Use RevPi Core as Modbus TCP Master.
Instead of using a real Modbus Slave you could use i.e. ModSim32 (please don't be alarmed by the 90s layout of the website).
Could you be so kind to share your PiCtory configuration file "/etc/revpi/config.rsc" with us?
RMeissnerCC
Posts: 58
Joined: 03 Dec 2019, 10:29

Re: Modbus RTU Master register address

Post by RMeissnerCC »

Hi Dirk,
I used your youtube tutorial to setup the Modbus RTU Master.
I also attached the config.rsc as zip. Is the file correct?
Best, Robert
Attachments
config.zip
(5.95 KiB) Downloaded 561 times
RMeissnerCC
Posts: 58
Joined: 03 Dec 2019, 10:29

Re: Modbus RTU Master register address

Post by RMeissnerCC »

Hi Dirk,
I guess the solution was that the manufacturer starts the address at 0. You have written that in the How to Use ... tutorial. Unless you find something in the config I deem this post as answered.
Best, Robert
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Master register address

Post by dirk »

Hi Robert, this is a common problem as Modbus registers by definition start counting from 1 instead of 0. But to address them i.e. with a 16Bit variable you usually switch to the offset 0 for being able to to address them from (2^0) to (2^16 - 1)...
RMeissnerCC
Posts: 58
Joined: 03 Dec 2019, 10:29

Re: Modbus RTU Master register address

Post by RMeissnerCC »

Good morning Dirk,
thank you :)
Does this offset in register address apply to writing to the registers, too?
Best, Robert
Post Reply