Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plot a real time graph from serial port input

39 views
Skip to first unread message

Khairi Ismail

unread,
Jul 20, 2008, 7:32:02 AM7/20/08
to
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.?


Khairi Ismail

unread,
Jul 20, 2008, 7:33:02 AM7/20/08
to

Donn Shull

unread,
Jul 20, 2008, 10:53:02 PM7/20/08
to
Hi,

The short answer is yes. To get better help post the
portion of your code where you are having trouble. You
should be able poll the serial port object for bytes
available and read them as they become available and update
your plot using drawnow as the values are read.


Sachitha Obeysekara

unread,
Jul 21, 2008, 4:11:02 AM7/21/08
to
"Khairi Ismail" <khairi...@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

Ankit Desai

unread,
Jul 22, 2008, 9:38:02 AM7/22/08
to
"Khairi Ismail" <khairi...@srilanai.com> wrote in
message <g5v7ni$1ec$1...@fred.mathworks.com>...

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

Sreeram Mohan

unread,
Jul 10, 2009, 10:19:02 AM7/10/09
to
"Ankit Desai" <adesai...@mathworks.com> wrote in message <g64nrq$s53$1...@fred.mathworks.com>...
HI,

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

Thanks,
--sreeram

0 new messages