I am designing a device, which needs to communicate with MATLAB via serial port
I need to have a CLI for taking values from the user which can be transmitted to the device. This has been done.
I have now run into this problem...
The device transmits a series of numbers which need to be plotted real time. Can this be done on MATLAB?
The CLI also needs to be active and available at the same time.
Could someone please point me in the right direction? Please feel free to offer any suggestions or ideas that you might have.
I am not asking for a complete solution here ... I just a nudge in the right direction. You might mention any command or library, and i will dig into it.
arindam <goswamiarindam@gmail.com> wrote in message <12009090.1227870188030.JavaMail.jakarta@nitrogen.mathforum.org>...
> I am designing a device, which needs to communicate with MATLAB via serial port
>
> I need to have a CLI for taking values from the user which can be transmitted to the device. This has been done.
>
> I have now run into this problem...
> The device transmits a series of numbers which need to be plotted real time. Can this be done on MATLAB?
> The CLI also needs to be active and available at the same time.
>
> Could someone please point me in the right direction? Please feel free to offer any suggestions or ideas that you might have.
>
> I am new to MATLAB, but not to programming.
I'm not sure how you will get the data from the device to MATLAB, but one idea is to run a timer object that grabs data from the serial port object at the desired interval. It appears that the serial port object has a TimerFcn, so you can probably put the code to display the data in that callback.
I now have an idea of how to proceed...
I will implement time interval based callbacks which will
1) read the input buffer of the serial object
2) callback the stripchart function
That should give me a real time plot with a rolling window
:)
If it works, I will share the results with you this Monday.
Thanks again
I am doing quite the same thing: trying to display data from an accelerometer with a serial interface.
The serial interface is quite simple
s=serial('comN');
fopen(s);
%then i send a command to the device
char;
fprintf( s,'adc%c',char);
%and then i get the values back
string=fgetl(s);
now the string has to be parsed (at least this is what i do: i convert char encoding to numbers), and you have your values.
For me it's a Vector3.
Now what i do to represent.
I do some math with the data (filtering and normalizing) and implement a simple delay: (non working code)
hline=plot
while(ishandle(hline))
a=cputime;
while(b<(a+0.01))
b=cputime;
end
do whatever is necessary
end
in the plot you draw the first picture, then it is updated every time the "for" runs.
a+0.01 is the delay
"Elettro Saldatura" <erupter_remove_this_@tiscali.it> wrote in message
> in the plot you draw the first picture, then it is updated every time the "for" runs.
> a+0.01 is the delay
My error.
I meant the "while".
The program automatically quits when the graph window is closed.
arindam <goswamiarindam@gmail.com> wrote in message <23963555.1227883427711.JavaMail.jakarta@nitrogen.mathforum.org>...
> Thank you Oliver and Ryan,
>
> I now have an idea of how to proceed...
> I will implement time interval based callbacks which will
> 1) read the input buffer of the serial object
> 2) callback the stripchart function
> That should give me a real time plot with a rolling window
> :)
> If it works, I will share the results with you this Monday.
> Thanks again
Hello to everybody,
I've done the same thing as you: I receive data from a serial port (by USB converter) on my notebook and I plot them "real-time" with stripchart (it works good). My problem is that I receive data every 5 ms, so Matlab is not able to follow this tempistic and I observe a "real time" graphic with a big delay. In particular, each fscanf to read data needs about 20 ms.
The question is the follow: is there an instruction similar to fscanf but faster?
arindam <goswamiarindam@gmail.com> wrote in message <23963555.1227883427711.JavaMail.jakarta@nitrogen.mathforum.org>...
> Thank you Oliver and Ryan,
>
> I now have an idea of how to proceed...
> I will implement time interval based callbacks which will
> 1) read the input buffer of the serial object
> 2) callback the stripchart function
> That should give me a real time plot with a rolling window
> :)
> If it works, I will share the results with you this Monday.
> Thanks again
Hello to everybody,
I've done the same thing as you: I receive data from a serial port (by USB converter) on my notebook and I plot them "real-time" with stripchart (it works good). My problem is that I receive data every 5 ms, so Matlab is not able to follow this tempistic and I observe a "real time" graphic with a big delay. In particular, each fscanf to read data needs about 20 ms.
The question is the follow: is there an instruction similar to fscanf but faster?
arindam <goswamiarindam@gmail.com> wrote in message <23963555.1227883427711.JavaMail.jakarta@nitrogen.mathforum.org>...
> Thank you Oliver and Ryan,
>
> I now have an idea of how to proceed...
> I will implement time interval based callbacks which will
> 1) read the input buffer of the serial object
> 2) callback the stripchart function
> That should give me a real time plot with a rolling window
> :)
> If it works, I will share the results with you this Monday.
> Thanks again
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.