How can I acquire data from a temperature controller using serial comunication?
Show older comments
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!
Answers (1)
Ameer Hamza
on 16 May 2018
0 votes
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 Comments
Fabrizio Errichiello
on 17 May 2018
Ameer Hamza
on 17 May 2018
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
on 17 May 2018
Ameer Hamza
on 17 May 2018
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
on 18 May 2018
Ravi Sankar Tamma
on 30 Oct 2023
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.
Categories
Find more on Modbus Communication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!