Modbus RTU Write Simulink Block error

Hi community,
I am starting with the setup of a modbus RTU communication between my matlab simulink model and some surrounding devices. Using the new simulink block "modbus client read", I can read the register of my external device, which shows me, that I've created a stable communication. However, if I want to write a register on the device, using the block "modbus client write", I get the following error:
Error:An error occurred during simulation and the simulation was terminated
Caused by:
MATLAB System block 'untitled/Modbus Client Write/internalModbus' error occurred when invoking 'stepImpl' method of 'icomm.system.ModbusWrite'. The error was thrown from '
'C:\Program Files\MATLAB\R2024b\toolbox\icomm\modbus\modbus\modbusblks\+icomm\+system\ModbusWrite.p' at line 0'.
The Modbus server returned an invalid address error. Address + number of values to write is out of range.
The config of the write-block is pictured:
As aforementioned, it's the same connection as used for the reading process. The model is quite simple and broken down to the minimum, but I get the error anyway:
Now I am struggling how to proceed with this error. Maybe someone can help me out!
Best
Marco

1 件のコメント

Marco
Marco 2025 年 1 月 30 日
note: I am very sure, that the register number 55 is right, because with other software (comTestPro) I can easy write the register.

サインインしてコメントする。

回答 (1 件)

Pramil
Pramil 2025 年 2 月 3 日
編集済み: Pramil 2025 年 2 月 3 日

0 投票

Hi Marco,
I faced a similar issue in MATLAB R2024b.
The issue was with the input data type of the signal going into "Modbus Client Write" block which has to be "double" otherwise it will result in an error.
As seen in the following documentation as well, the "Data type" for the "Reg_x" input to the "Modbus Client Write" should be a "double":
Hope this resolves your issue.

3 件のコメント

Marco
Marco 2025 年 2 月 3 日
Thanks for your answer Pramil, but sadly this helps not. Even if I change the data type to double. Somehow there is a problem with the modbus register address I am trying to write in, but I am totally sure, that it's the right number.
Pramil
Pramil 2025 年 2 月 3 日
Hey Marco, can you try incementing the register address by one, so instead of using "55" try with "56" and let me know if you get the same error.
Marco
Marco 2025 年 2 月 3 日
Finally, it works! Thanks!

サインインしてコメントする。

カテゴリ

製品

リリース

R2024b

質問済み:

2025 年 1 月 30 日

コメント済み:

2025 年 2 月 3 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by