Effacer les filtres
Effacer les filtres

Modbus TCP: Read successful, write unsuccessful

13 vues (au cours des 30 derniers jours)
Kamal Baghirli
Kamal Baghirli le 21 Juin 2023
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 :)

Réponses (2)

Sanjana
Sanjana le 24 Août 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 commentaire
José Rudiney De Sousa Miranda Júnior
Modifié(e) : José Rudiney De Sousa Miranda Júnior le 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"

Connectez-vous pour commenter.


Amir Tairi
Amir Tairi le 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.

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by