How to read COM port data continuously and plot the data live in MATLAB?
126 次查看(过去 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!