필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
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
Mohammed Ammad
Mohammed Ammad 2022년 11월 13일
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 2022년 11월 13일
record the start time. Loop as long as etime() is less than 7 seconds.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by