Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plot a real time graph from serial port input

Subject: Plot a real time graph from serial port input

From: Khairi Ismail

Date: 20 Jul, 2008 11:32:02

Message: 1 of 4

Hi,

I would like to know whether it is possible to plot a real
time graph from serial port input.

I have written the code, but it seems the data is not
plotting real time. I understand that the data is stored in
inputbuffer before it is being taken out by matlab to read.
Is it possible for matlab to constantly check the
inputbuffer instead of waiting for timeout to occur then
read the data.?

Subject: Plot a real time graph from serial port input

From: Sachitha Obeysekara

Date: 21 Jul, 2008 08:11:02

Message: 2 of 4

"Khairi Ismail" <khairi.ismail@srilanai.com> wrote in
message <g5v7ni$1ec$1@fred.mathworks.com>...
> Hi,
>
> I would like to know whether it is possible to plot a real
> time graph from serial port input.
>
> I have written the code, but it seems the data is not
> plotting real time.

a pause(0.01) just after plot seemed to do the trick, but
obviously, it reduces the speed of your program....

 
> inputbuffer before it is being taken out by matlab to read.
> Is it possible for matlab to constantly check the
> inputbuffer instead of waiting for timeout to occur then
> read the data.?
>
>
...not sure about this bit

Regards,
Sach

Subject: Plot a real time graph from serial port input

From: Ankit Desai

Date: 22 Jul, 2008 13:38:02

Message: 3 of 4

"Khairi Ismail" <khairi.ismail@srilanai.com> wrote in
message <g5v7ni$1ec$1@fred.mathworks.com>...
> Hi,
>
> I would like to know whether it is possible to plot a real
> time graph from serial port input.
>
> I have written the code, but it seems the data is not
> plotting real time. I understand that the data is stored in
> inputbuffer before it is being taken out by matlab to read.
> Is it possible for matlab to constantly check the
> inputbuffer instead of waiting for timeout to occur then
> read the data.?
>
>

Hi,

A couple of things you might want to try:

1. BytesAvailableFcn is a callback that you set to run at
every BytesAvailableFcnCount number of bytes in your input
buffer

2. Instead of plotting every time, try updating only the
axis property of the figure handle

Hope this helps

-Ankit

Subject: Plot a real time graph from serial port input

From: Sreeram Mohan

Date: 10 Jul, 2009 14:19:02

Message: 4 of 4

"Ankit Desai" <adesai.nospam@mathworks.com> wrote in message <g64nrq$s53$1@fred.mathworks.com>...
> "Khairi Ismail" <khairi.ismail@srilanai.com> wrote in
> message <g5v7ni$1ec$1@fred.mathworks.com>...
> > Hi,
> >
> > I would like to know whether it is possible to plot a real
> > time graph from serial port input.
> >
> > I have written the code, but it seems the data is not
> > plotting real time. I understand that the data is stored in
> > inputbuffer before it is being taken out by matlab to read.
> > Is it possible for matlab to constantly check the
> > inputbuffer instead of waiting for timeout to occur then
> > read the data.?
> >
> >
>
> Hi,
>
> A couple of things you might want to try:
>
> 1. BytesAvailableFcn is a callback that you set to run at
> every BytesAvailableFcnCount number of bytes in your input
> buffer
>
> 2. Instead of plotting every time, try updating only the
> axis property of the figure handle
>
> Hope this helps
>
> -Ankit
>
HI,

you could see my post that does the serial port plot with an arduino uc.

Thanks,
--sreeram

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us