Modbus RTU Manster configuration

Topics about the Software of Revolution Pi
Post Reply
cerberus78
Posts: 6
Joined: 06 May 2024, 20:24

Modbus RTU Manster configuration

Post by cerberus78 »

Hello,

i m working on a project where i need to make an app based on an RTU modbus master (revpi)
it will communicate with a slave (1), the configuration is as:
76 input registers
80 holding registers


I need to configure it on pictory, can you tell me what to do ? for exemple
input register :PRESSURE_SURF adress 0x80D0-0x80D1 - float

If I have understood correctly, i need to put
slaveId as 1
Function code: READ_INPUT_REGISTER
Addr do i need to put 0x80D and quantity of registers to 4 ? as it is a float and there is two adresses?


and also how to read device identification (0x2b register), i don't see it.


Thank you for your help

Image
User avatar
dirk
KUNBUS
Posts: 1998
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Manster configuration

Post by dirk »

Hi cerberus78,
nice project, so basically Modbus registers are the smallest addressable data. There are no bytes addressable in Modbus. Each Modbus register consists of 2 bytes. No matter what you store in the register - float, integer, signed or unsigned. If you want to process the content as a float, it is up to you to cast it in your application to work with the values.

Now comes the most annoying part of Modbus - you start counting at 1. Register address 0 does not exist. Historically conditioned.

The register 0x80D0 equals 32976 decimals - I like to use the good old Windows pocket calculator for this "calc":
Windows calculator
Windows calculator
Then you want to use the READ_INPUT_REGISTER function code, so change it.
The quantity of registers is 1 (0x80D1-0x80D0) which is what you have typed correct in your photo - good.

The device information you mentioned - It depends on what the manual for your Modbus device defines. You may find the answer to which function code you are using here. You can watch the video tutorial Modbus RTU Master:
https://revolutionpi.com/en/tutorials/v ... rials#VT21
cerberus78
Posts: 6
Joined: 06 May 2024, 20:24

Re: Modbus RTU Manster configuration

Post by cerberus78 »

The quantity of registers is 2 as:

datasheet mention for exemple
PROTOCOL_VERSION 0x8001 uint
SERIAL_NUMBER 0x8002-0x8003 uint
TIME_CURRENT 0x8010-0x8013 int

so i have changed default Input_Word_1 to PROTOCOL_VERSION
Input_Word_2 and 3 to SERIAL_NUMBER and SERIAL_NUMBER_2
Input_Word_4 5 6 and 7 to TIME_CURRENT TIME_CURRENT_2 TIME_CURRENT_3 and TIME_CURRENT_4

is this right ? i am still confused..

and in pictory i have put
Image

and also how to do User Defined Function sush as
• Read FIFO queue: code 0x42
• Read Clear FIFO queue: code 0x43
• Set File Name: code 0x65
• Get File Info: code 0x66
• Read File: code 0x67
• Write File: code 0x68
• Rename File: code 0x69
• Delete File: code 0x6A
cerberus78
Posts: 6
Joined: 06 May 2024, 20:24

Re: Modbus RTU Manster configuration

Post by cerberus78 »

and also i have seen that with this configuration (for test and integration purpose)

Image

i shoud get register 32768 (PROTOCOL_VERSION) every 800ms but what i see in my receiver log that the msg is received each ~1.6 sec.

instead of receiving the message each 800ms i see x2 that is because there is the SERIAL_NUMBER register wich is 800ms action interval also...

is there something to do to respect the action interval ?
User avatar
dirk
KUNBUS
Posts: 1998
Joined: 15 Dec 2016, 13:19

Re: Modbus RTU Manster configuration

Post by dirk »

Hi, thanks for your detailed bug report.
In mode, the smallest addressable piece of information is a register. The registers start at address 1, not at 0 as is typically the case.
In general, I can recommend you to watch the video tutorials on the subject of Modbus, i.e:
Note the implemented function codes (FC) that are available to you, e.g. Write Multiple Registers, Read Holding Registers, etc.
https://revolutionpi.com/en/tutorials/m ... -verwenden


If you need several registers for information such as the serial number, your procedure is just right. You start with the register address and enter the number of registers with the FC Read Multiple Registers. You can rename the variables according to your choice, as you have already done.

Unfortunately, I didn't really understand your problem with the latencies. Do you want the information you need not to be read or read incorrectly if it is queried too often?
Post Reply