Modbus TCP: Read successful, write unsuccessful

10 Ansichten (letzte 30 Tage)
Kamal Baghirli
Kamal Baghirli am 21 Jun. 2023
Beantwortet: Amir Tairi am 30 Jan. 2024
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 :)

Antworten (2)

Sanjana
Sanjana am 24 Aug. 2023
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 Kommentar
José Rudiney De Sousa Miranda Júnior
Bearbeitet: José Rudiney De Sousa Miranda Júnior am 12 Nov. 2023
I have the same problem, but i connect a Mitsubishi Q03UDE to PC, I can read but I cant write. and I use "R2023b"

Melden Sie sich an, um zu kommentieren.


Amir Tairi
Amir Tairi am 30 Jan. 2024
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.

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by