How to read COM port data continuously and plot the data live in MATLAB?
118 ビュー (過去 30 日間)
古いコメントを表示
Using UART of my microcontroller (MSP430) I am sending data from MCU to the serial port of my PC. I can watch the data continuously in Teraterm. Now I would like to plot the data in MATLAB. So, how can I continuously read a COM port in MATLAB and plot the data?
Thanks, Row
2 件のコメント
Amélie Serrano
2019 年 5 月 10 日
Hello Row,
I have exactly the same question as you, did you manage to display the results from the UART obtained on a Matlab interface ?
Thank you,
Amélie
Oscar Green
2019 年 5 月 16 日
For continuous monitoring of the COM port, it will be possible to try https://www.com-port-monitoring.com/. The software is free so it's worth a try.
I didnt tested this option yet, but I use bunch of other options such as scripting, macro definition, TCP/UDP .
採用された回答
Brian Hu
2018 年 10 月 4 日
Hello Row,
It seems like there are two separate angles to address with your implementation using MATLAB to read COM port values from your microcontroller: reading values from the serial COM port and getting a continuous stream of data. In order to give a thorough response, I will address both these approaches sequentially.
You can import data into MATLAB through a COM port by creating a serial device in MATLAB that acts as a communication channel. In order to create this serial object and read and write data, please refer to the details in the documentation page below.
There are several additional steps you can take in order to receive a continuous stream of data. First, you will want to set the 'IsContinuous' property of the serial object you created in the first step to 1, allowing a nonstop flow of data. If you are interested in plotting the data and having it update continuously, you would want to create a callback function which uses the 'BytesAvailable' property of the serial object to update your plot after a certain amount of data has been registered in the serial buffer. The first link I attached below goes over the valid callback properties of serial objects, while the second is a general overview of callback functions and their implementations.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!