Using Modbus with Matlab

2 visualizaciones (últimos 30 días)
Philipp Prünte
Philipp Prünte el 22 de En. de 2019
Comentada: Philipp Prünte el 23 de Jun. de 2023
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 comentarios
Kamal Baghirli
Kamal Baghirli el 20 de Jun. de 2023
Hi, could you solve this problem back then? I have a similar problem.
Philipp Prünte
Philipp Prünte el 23 de Jun. de 2023
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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Modbus Communication en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by