MODBUS communication error/timeout when trying to read from a MODBUS device over serial port
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi
I am trying to connect Matlab to a detector which uses the MODBUS protocol over a serial port. I can connect via a terminal program and read and write commands manually (e.g. :000301020002f8 will read register address 258) and I can also do this in Matlab using the instrument control toolbox to open a serial port connection in the same way.
I then try to create a modbus object using the MODBUS command: m = modbus('serialrtu','COM13','Baudrate',57600) which seems to work.
However, I can't read any data from it. e.g. read(m,'holdingregs',258,1) will give the error: A communication error occurred while reading from the Modbus server: Timeout occurred waiting for a response.
I am a Matlab and MODBUS novice so it is possible I have fundamentally misunderstood something but I can't find any clues in the documentation.
I just want to make a simple script to control the detector and had hoped the MODBUS support would simplify this effort (e.g. so I don't need to calculate the LRC each time) but maybe it is not so straightforward?
Any help or advice would be much appreciated.
Best regards
Gareth
0 comentarios
Respuestas (1)
Tristan Yang
el 2 de En. de 2018
Hi Gareth,
The syntax of the usage seems to be right. Please try to set the timeout to a longer period and make sure the target area argument is setting correctly ('inputregs' vs. 'holdingregs').
Ver también
Categorías
Más información sobre Modbus Communication en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!