Using Modbus with Matlab

조회 수: 2 (최근 30일)
Philipp Prünte
Philipp Prünte 2019년 1월 22일
댓글: Philipp Prünte 2023년 6월 23일
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
Kamal Baghirli 2023년 6월 20일
Hi, could you solve this problem back then? I have a similar problem.
Philipp Prünte
Philipp Prünte 2023년 6월 23일
Hi, unfortunately I was not able to solve my issues. I then stayed with Python as it worked quite fine and I had no further issues I was not able to resolve.
Kind regards,
Philipp

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Modbus Communication에 대해 자세히 알아보기

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by