필터 지우기
필터 지우기

i am try to get the 4 sensors data from a serial port and my data lies in 13,15,17,19 bytes of a packet .I want to plot the data of each sensor in real time but i am facing problem even though one sensor is giving maximum output i couldnt see it i

조회 수: 1 (최근 30일)
%run('clean');
clear all;
close all;
delete(instrfindall);
s = serial('COM5'); %assigns the object s to serial port
set(s, 'InputBufferSize', 512); %number of bytes in inout buffer
set(s, 'BaudRate', 115200);
%set(s, 'Timeout',10);
%clc;
fopen(s); %opens the serial port
t=1;
disp('Running');
x=0;
y=0;
z=0;
w=0;
while(true)
a1 =fread(s); %reads the data from the serial port and stores it to the matrix a
s1=a1(13);
a=(s1-175)/80;
x =[x a];% Merging the value to an array, this is not very computationaly effective, as the array size is dynamic.
plot(x,'Color','g');
axis auto;
grid on;
hold on;
drawnow;
s2=a1(15);
b=(s2-166)/89;
y =[y b];
plot(y,'Color','y');
axis auto;
grid on;
hold on;
drawnow;
s3=a1(17);
c=(s3-168)/87;
z =[z c];
plot(z,'Color','r');
axis auto;
grid on;
hold on;
drawnow;
s4=a1(19);
d=(s4-166)/89;
w =[w d];
plot(w,'Color','b');
axis auto;
grid on;
t=t+1;
drawnow;
%a1=0; %Clear the buffer
end
fclose(s); %close the serial port
  댓글 수: 4
Walter Roberson
Walter Roberson 2014년 3월 12일
which sensor? How do you know it is giving the maximum value?
By the way, my house elves get all of March off to go skiing, so I have to do my own grocery shopping, leaving me out of contact sometimes.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by