I got Matlab to talk, with Arduino, as outlined here http://www.arduino.cc/playground/Interfacing/Matlab
I have got ADXL345 to output data to Arduino's serial monitor. I would like to log all the data in Matlab.
Has anyone tried something similar? Would appreciate some advice.
After some googling, i found that the following code, gets the data into Matlab
clear all;
data_pts=1000;
s1 = serial('COM3'); %define serial port
s1.BaudRate=9600; %define baud rate
fopen(s1);
clear data;
for i= 1:data_pts %acquisition of 100 points
data(i,:)=fscanf(s1);%read sensor
end
% close the serial port!
fclose(s1);
% Below is the Matlab code for storing x,y,z accelerations
for i=1:length(data)
temp_string=data(i,:);
a=find(isspace(temp_string));
xacc(i)=str2double(temp_string(1:a(1)-1));
yacc(i)=str2double(temp_string(a(1)+1:a(2)-1));
zacc(i)=str2double(temp_string(a(2)+1:a(3)-1));
end
My concerns are the following
1)If the sensor outputs at a rate greater than the baud rate=9600, what happens to those values?Are they dropped?
2)Is it possible to gaurantee that Matlab, won't drop values, when listening to the usb port?
Is it better to use a SD card to save values?
Hi,
I'm trying to connect the ADXL345 and read the data with Matlab ..
how did you connected the sensor to the Arduino?
And what is the code loaded on the chip?