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
댓글 수: 0
답변 (1개)
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').
참고 항목
카테고리
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!