Effacer les filtres
Effacer les filtres

How to plot a graph with x and y axis input live from two hardware (arduino and laser gauge- UART)

3 vues (au cours des 30 derniers jours)
Hi,
I'm a newbie to matlab. I'm trying to plot a graph where realtime data is received from a laser gauge using serial input (FT232), and pressure reading from a sensor using arduino. I tried to interface both the hardware to arduino but it wasn't an option recommended by the tech for the laser gauge and wasn't working.Serial signal was verified to work with tera term. Now I built up a code to receive that in matlab. I would like some help on how to now integrate that code to plot where the x axis is the source from arduino.
%
close all;
%serial object
s = serialport('COM4','BaudRate',9600);
% open serial port
fopen(s);
%plotting data
i=1;
while (1)
data (i) = str2double(fscanf(s));
if i <= 150
plot(data);
else
plot(data(end-150:end));
ylim([0 5]);
pause(0.01);
i=i+1;
end
  3 commentaires
Mohammed Ammad
Mohammed Ammad le 13 Nov 2022
Is it possible to get the data for the x and y axis from the hardware to plot the graph for 7 seconds and then stay idle?
Walter Roberson
Walter Roberson le 13 Nov 2022
record the start time. Loop as long as etime() is less than 7 seconds.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by