필터 지우기
필터 지우기

MODBUS communication error/timeout when trying to read from a MODBUS device over serial port

조회 수: 30 (최근 30일)
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

답변 (1개)

Tristan Yang
Tristan Yang 2018년 1월 2일
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').
  댓글 수: 1
Gareth Jenkins
Gareth Jenkins 2018년 1월 8일
Thanks for the reply. I did try increasing the timeout to 20 secs with the same result. I also tried using 'inputregs' instead of 'holdingregs' with no luck.
One thing which puzzles me is that I can't find any mention in the documentation as to performing either an LRC or CRC (longitudinal redundancy check or cyclic redundancy check).
My device definitely requires LRC but maybe Matlab is doing CRC or something else (or nothing at all)?
Could this be the problem?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by