Code covered by the BSD License  

Highlights from
Real time Data plot from serial port

4.0
4.0 | 4 ratings Rate this file 243 Downloads (last 30 days) File Size: 1.99 KB File ID: #28941 Version: 1.0
image thumbnail

Real time Data plot from serial port

by

 

It plots real time data from serial port. It can use for any serial port device.

| Watch this File

File Information
Description

real time data plot from a serial port
This matlab script is for plotting a graph by accessing serial port data in real time. Change the com values and all variable values accroding to your requirements. Do not forget to add terminator in to your serial device program.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
30 Jun 2015 Ted Doykos

I'm trying to use this code to get the real time data from a Pixy camera. The camera is connected to an Arduino and then running through the com port into Matlab. I've never used Arduino before and have no idea what to do about the terminator. In Matlab it says that the terminator for the comport is LF, but that isn't even an option for the serial monitor for the Arduino. Thanks for any help.

Comment only
06 Mar 2015 want2know

Hi,

I am able to read data from FPGA to Nios processor, then transmit this data to Uart component created in Qsys using direct register method (IORD_ALTERA_AVALON_UART_STATUS (UART_BASE);
IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, txdata);etc).

I stuck at the point that I want to plot graph to Matlab real time, I found this link , I assume that the data that I transmitted to Uart will be available at the serial com port, so I just need Matlab coding to read this data and plot the graph, am I right?

Can I ask one silly question, I still do not understand why do I need USB-to-Serial interface to the board such as FTDI UM245R module?

Without FTDI UM245R module, I thought MATLAB can still talk to serial port, isn't it?? Please correct me if this is wrong.

Thank you

Comment only
16 Feb 2014 warut Phothiphan  
10 Aug 2013 antonydublin

Recently I’ve found this script «Real time Data plot from serial port» back from 2010 on MathWorks blogs. Just want to say thanks, it is simple and helpful example. In other words, this not sophisticated code easy to understand and change in any way. To Dimit: you must add terminator (0x0D, 0x0A) after each value of data in your transmission, in basic terminal programs this means to turn on «Send line feeds with carriage return» (or CR=CR+LF). Also could be helpful any “Virtual Serial Port” while debugging without external device.

Comment only
10 Aug 2013 antonydublin  
16 Jun 2013 dimit

dimit (view profile)

Hi,

When I run this code I get the following error. What should I do ?

??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> real_time_data_serial at 80
voltage(count) = fscanf(s,'%f');

Comment only
10 Dec 2012 farrukh sabir

wow! it works perfect. thanks a lot. i just set com port number and sent serial data via PIC mcu and it worked fine for me.
have a look at my post
http://www.facebook.com/groups/picMicrocontrollers/permalink/256677191081931/

thanks again Moidu Thavot

04 Oct 2010 Sean de

Sean de (view profile)

This really should be a function with everything that needs to be changed as input variables. It could then have defaults if the variables aren't entered. The author should also take heed to MLINT.

Contact us