Modbus TCP: Read successful, write unsuccessful
조회 수: 10 (최근 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 :)
댓글 수: 1
답변 (2개)
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
2023년 11월 12일
편집: 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
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!