Modbus TCP: Read successful, write unsuccessful

10 ビュー (過去 30 日間)
Kamal Baghirli
Kamal Baghirli 2023 年 6 月 21 日
回答済み: Amir Tairi 2024 年 1 月 30 日
Hi all.
I have connected a PC to a Bachmann M1 Controller using Modbus tcp/ip connection in MATLAB. Now I want to read/write variables from/to a Simulink model which is deployed and running on the controller. So I have created variables in Simulink using SVI-SW blocks (provided by Bachmann M-target), and mapped those variables to holding registers and given them indexes of 0 and 100.
When I try to read those variables from MATLAB command line, it returns correct value. But when I try to write, it returns invalid address error.
Reading:
>> b = read(m, 'holdingregs', 1, 1, 'double')
b =
0
Writing:
>> write(m, 'holdingregs', 1, 89, 'double')
The Modbus server returned an invalid address error. Address + number of values to write is out of range.
The variable at address 1 is an input to the Simulink via SVI block, and can be read and written to. And the address 1 should not be out of range as I have defined variable in that address and it can be read successfully.
Does anyone have an idea of what might be wrong?
Thanks :)

回答 (2 件)

Sanjana
Sanjana 2023 年 8 月 24 日
Hi Kamal,
I understand that you are facing an issue with the “write” operation performed over a “Modbus TCP/IP” connection.
This is an externally reported bug, and since you are using “R2021b” MATLAB Version, please install “Update 5” for the “R2021b” MATLAB Version, as mentioned in the bug fixes.
Please refer to the following link, for further information.
Hope this helps.
Regards,
Sanjana.
  1 件のコメント
José Rudiney De Sousa Miranda Júnior
編集済み: José Rudiney De Sousa Miranda Júnior 2023 年 11 月 12 日
I have the same problem, but i connect a Mitsubishi Q03UDE to PC, I can read but I cant write. and I use "R2023b"

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


Amir Tairi
Amir Tairi 2024 年 1 月 30 日
Hello,
I recently encountered a similar issue and found a solution that worked for me. I simply incremented the coil or register address by 1. For instance, if the documentation indicates that the write address is 402, you should actually use 403. This adjustment resolved the problem in my case.

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by