How to read COM port data continuously and plot the data live in MATLAB?
126 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
ROWSHON ARA MUNNY
il 2 Ott 2018
Commentato: Oscar Green
il 16 Mag 2019
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 Commenti
Amélie Serrano
il 10 Mag 2019
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
il 16 Mag 2019
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 .
Risposta accettata
Brian Hu
il 4 Ott 2018
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!