Page 1 of 1

Modbus RTU Master register address

Posted: 12 May 2020, 10:23
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?

Re: Modbus RTU Master register address

Posted: 12 May 2020, 13:30
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?

Re: Modbus RTU Master register address

Posted: 12 May 2020, 14:06
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

Re: Modbus RTU Master register address

Posted: 12 May 2020, 14:22
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

Re: Modbus RTU Master register address

Posted: 12 May 2020, 14:48
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)...

Re: Modbus RTU Master register address

Posted: 13 May 2020, 07:04
by RMeissnerCC
Good morning Dirk,
thank you :)
Does this offset in register address apply to writing to the registers, too?
Best, Robert