Go Down

Topic: sampling rate of Arduino UNO R3 (Read 1 time) previous topic - next topic

ziltu57

Hi everybody,
I am using Arduino UNO R3 in the combine with ADXL335 in order to plot real time in MATLAB 2011a. What I am getting is real time but slightly difference with stopwatch. What could be the problem? underneath is my code. This code takes 33sec for 100 data points. Has any body got suggestion to do faster operation? Would glad if I get any.

clc;
clear all;
close all;
t=0;
t1=[];
s = serial('COM3','baudrate',9600);
data = [];
j=1;
fopen(s);
for i=1:200
tic
    idn = fscanf(s);
    data1 = str2num(idn);
    data =[data; data1];
       t=toc+t;
    t1 =[t1; t];
     plot(t1,data(:,1),'m',t1,data(:,2),'c',t1,data(:,3),'b'); 
     legend('X-axis', 'Y-axis', 'Z-axis');
    axis auto;
    xlabel('Time(s)');
    ylabel('Amplitude');
    grid on;
    drawnow;
    %hold on;
end
fclose(s);
delete(s);

Grumpy_Mike


Go Up