Maximum number of registers

38 views
Skip to first unread message

Wo0Zzz

unread,
Jan 27, 2021, 9:06:06 AM1/27/21
to libmodbus
Hello, 
I'm currently working on a project that is functioning as a sort of gateway. 
I'm reading out a bus and the data is stored as a .txt file on my raspberry. 
The next step is to make this data available for Modbus to readout. 
I'm using the libmodbus library and a example file that I've edited to my needs. 
Everytime there is a data request, it reads all the different .txt files and stores the data in the modbus registers. 
To make it clear I wan't to use different ranges of registers (e.g. a bunch of data on 0x0000 - 0x0010 and 0x1000 - 0x1050 and so on).
Currently I'm only using holding registers, because it only has to store data and don't need to change it. 
I discovered that the max of registers I'm able to create is 125. If I make it bigger i'm getting an error saying, for example: Illegal data address 0x7F in read_registers. And the application is also giving an error: Failed to execute read. 
Is it possible to create more registers, because with my knowledge it is possible to create at least 9999 (and I'm not sure 10000) registers. 
I posted the code on: https://codeshare.io/G7RXdY (only 24Hr available)

I hope you can help me, otherwise I'm limited to only 124 registers.

Thanks in advance,
Jelle

Chuck Watson

unread,
Jan 27, 2021, 9:25:13 AM1/27/21
to libm...@googlegroups.com

From web search:

 

According to the Modbus specification, the limits for one request are:

- read 125 registers

- write 123 registers

- read 2000 bits

- write 1968 bits

 

You just need to do multiple read/write requests to get over these numbers.

 

Chuck Watson BS, CEM, CMVP

Direct USA 724-799-1529

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/769af197-21e2-452f-a376-c0012ea521fan%40googlegroups.com.

image001.gif

Wo0Zzz

unread,
Jan 27, 2021, 10:17:29 AM1/27/21
to libmodbus
Hi, 

Thanks for your reply. :-)
I was already aware of that. 
That's not my question/issue. 
I do need more registers, if I'm requesting a register in the range of 0 to 124 there is no issue, but if I'm requesting a single register above the 124 'limit' I get this error.
So i'm not requesting more than 125 registers, but need to use more than 125 register slots
Is there a limit in the libmodbus library or is there an issue in the particular example I used?
In case of the last, how can I fix that?

Thanks!

Op woensdag 27 januari 2021 om 15:25:13 UTC+1 schreef wat...@gmail.com:

Wo0Zzz

unread,
Jan 28, 2021, 9:14:57 AM1/28/21
to libmodbus
Well,
Problem solved, in the original code I used, on line 82, the code creates the number of registers.
Here the author linked to the MODBUS_MAX_READ_REGISTERS, in the modbus.h file it is stated as 125.
That's the reason I couldn't request a register above the 125 limit. Now I used my own number and I can request a register above the 125 limit.
Hope it will help someone else as wel.
Thanks for the help so far.

Jelle

Op woensdag 27 januari 2021 om 16:17:29 UTC+1 schreef Wo0Zzz:
Reply all
Reply to author
Forward
0 new messages