Arduino/ Matlab interface for real time measurements. How to fix a time step? n

2 views (last 30 days)
I am using an arduino uno to collect real time sensing data. Below is my MATLAB code. (some steps are commented out due to going from a 4 cell to 1 cell detector.)
interv= 100; passo= 1 t=1 w_n2=0 %x5=0 %y5=0 %z3=0 while (t< interv); t=[0:0.01]'; b=readVoltage (a, 'A0') ; %c=readVoltage(a, 'A1'); %d=readVoltage(a, 'A2'); %e=readVoltage(a, 'A3'); w_n2= [w_n2,b]; %x5 = [x5,c]; %y5 = [y5,d]; %z3 = [z3,e]; hold on plot(w_n2, 'r'); %plot(x4, 'y'); %plot(y4, 'r'); %plot(z3, 'b'); axis ([0, interv, 0,1]); grid t= t+ passo; drawnow; end
However, it seems that each trial I take, the time step is longer than the previous trial. I am not sure if this is due to slowness of my operating system or if there is a way to time step around this. Any help is appreciated!
thanks, maggie
  1 Comment
Madhu Govindarajan
Madhu Govindarajan on 14 Jan 2016
Other things that might help are -
1) Remove the grid line as it gets executed on every loop 2) the readVoltage command itself has a few milliseconds of delay as the communication takes sometime, so try not having so many calls.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!