How can I acquire data from a temperature controller using serial comunication?
古いコメントを表示
Hello everyone. I'm using a temperature controller from Ascon Tecnologic to set and read the temperature of a batch. This controller allows Modbus RTU serial communication RS485 to monitor the temperature via PC and I'm using an RS485 to USB converter from Microflex to convert the signal. My purpose is to write a Matlab program that reads the temperature and gives me a plot T versus time but, although the device is connected, I'm not able to read anything from it so I'd like to know if anyone as any hint on what I should do/verify in order to communicate with the controller. Thanks!
回答 (1 件)
Ameer Hamza
2018 年 5 月 16 日
0 投票
Your question description is not enough to reproduce the error or to exactly pinpoint the problem, therefore here are some suggestion:
1) Make sure you are specifying the correct port. You can also use a software such as RealTerm to see if any data is coming over the serial port.
2) Make sure you have specified the appropriate properties to serial() object e.g. Baud rate, Data bits etc.
3) Make sure that you have opened the serial port using fopen().
6 件のコメント
Fabrizio Errichiello
2018 年 5 月 17 日
Ameer Hamza
2018 年 5 月 17 日
What type of error does fopen return? If you can paste all the error message displayed in red by MATLAB. It might be possible to suggest a solution.
Fabrizio Errichiello
2018 年 5 月 17 日
Ameer Hamza
2018 年 5 月 17 日
There can be two possibilities.
1) The serial port is not receiving the data.
2) fget() and fprint() are looking for a terminator character (probably newline). Which your serail port is not sening thus the return empty vector.
After fopen(s), check if any bytes are received by using
s.BytesAvailable
if it is greater then 0 then it means you are receiving the data. Then read the data using fread()
data = fread(s, s.BytesAvailable);
Fabrizio Errichiello
2018 年 5 月 18 日
Ravi Sankar Tamma
2023 年 10 月 30 日
Hello Fabrizio,
I am also fscing the same error in which I am able to write the data. But I am getting the error like "the modbus server returned an invalid address error. address + number of values to write is out of range". How can I rectify it.
カテゴリ
ヘルプ センター および File Exchange で Modbus Communication についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!