File Exchange

image thumbnail

Real time Data plot from serial port

version 1.0 (1.99 KB) by

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

117 Downloads

Updated

View License

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.

Comments and Ratings (11)

darshil shah

superb!! it is working great ..

abdo abdou

Hi Moidu I get th error:

 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');

and I do what you said :

comment out,

%voltage(1)=0;
%if (voltage(count)-voltage(count-1)>MaxDeviation)
% voltage(count)=voltage(count-1);
%end

but I have the same error again ?
what should I do ?
thank's

chrt gnnt

If you get,

??? 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 out,

  %voltage(1)=0;
  %if (voltage(count)-voltage(count-1)>MaxDeviation)
  % voltage(count)=voltage(count-1);
  %end

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.

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

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.

antonydublin

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');

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

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.

MATLAB Release
MATLAB 7.8 (R2009a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video