Pages: [1]   Go Down
Author Topic: Logging data from ADXL345 in Matlab  (Read 2700 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Everyone

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.

Thanks
Sam
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Many  thanks
« Last Edit: April 24, 2013, 07:45:06 am by Gerios » Logged

Pages: [1]   Go Up
Jump to: