How to read COM port data continuously and plot the data live in MATLAB?

217 次查看(过去 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
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
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by