Using Modbus with Matlab
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Kamal Baghirli
2023 年 6 月 20 日
Hi, could you solve this problem back then? I have a similar problem.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Modbus Communication についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!