Using Modbus with Matlab
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I am currently trying to communicate with a Modbus Slave using Matlab, but I am having difficulties with the results returned. I am trying to read holding registers from a battery inverter (SMA Sunny Island 4.4M), but I am getting an error or undesired/wrong result.
I used to read the registers using a python script before. For example if I want to read register 30053 to find out the device type with a battery inverter using the IP adress 134.28.124.133 and port 502 I am using the following code:
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
client = ModbusClient('134.28.124.133','502')
client.read_holding_registers(30053,2,unit=3).registers
The result I am getting is [0 9332] which is - according to the documentation - a Sunny Island 4.4M.
I am now trying to read the same register using Matlab. The code I am using is as follows:
client = modbus('tcpip','134.28.124.133','502')
read(client,'holdingregs',30053,2)
I am getting the error message: The Modbus server returned an invalid address error. Address + count is out of range.
If I use the register number 0053 instead of 30053 (I read some vendors use the 3 as the first digit altought it might not be necessary) I get the result: [65535 65535].
Does anyone know what I am doing wrong or why I am not getting the same results as in my python script? I did not find out how to define the unitID with Matlab Modbus, can you also help me with that please?
Thank you very much in advance,
Philipp
2 commentaires
Kamal Baghirli
le 20 Juin 2023
Hi, could you solve this problem back then? I have a similar problem.
Réponses (0)
Voir également
Catégories
En savoir plus sur Modbus Communication dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!