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

2 vues (au cours des 30 derniers jours)
%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 commentaires
Walter Roberson
Walter Roberson le 12 Mar 2014
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.
avinash pabbireddy
avinash pabbireddy le 13 Mar 2014
i am using flexi force sensor and i am applying max force 1N

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Startup and Shutdown 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