12-16-2013 03:58 PM
Hi
I'm using the lsm303dlhs accelometer with arduino and labview for some car navigation project.
I checked the reading of the accelometer in arduino and got readings that are [0 ,0, 1035] (X,Y,Z axis)
but when connecting arduino to labview ' getting different results in Z axis [0,0,1400] ,thats 350 diffrence in Z axis.
I’m using the VI that published Nathan_B. for interfacing with the arduino and the sensors, and it worked without a problem, but the different readings worry me...
Who gives the right reading? Why there is, a different reading?
can’t understand that…
anyone encountered that?
I'm using MEGA and labview 2012
12-16-2013 06:09 PM
I can't find any information about a LSM303DLHS. Can you post a link to the datasheet? Also, which set of VIs are you using?
12-16-2013 11:03 PM
Hi
the link to the datasheet is here :http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00027543.pdf
and the vi I run is "Graph Data" from you post here: https://decibel.ni.com/content/thread/18077
tnx for the fast respond
12-17-2013 10:58 AM
Could you post the Arduino code that you are using (where you got [0,0,1035])?
12-17-2013 11:28 AM
thats the code, and I added the sensors serial print at the end
#include <Wire.h>
#include <L3G.h> //Gyro
#include <LSM303.h> //Magnometer + Accelometer
L3G gyro;
LSM303 compass;
//CONSTS
#define D2R 0.01744f
#define R2D 57.324f
//Compass Vars
float heading_az;
int ax,ay,az;
//Prints
char report[80];
//-------------------------------------------------------------SETUP------------------------------------------
void setup()
{
Serial.begin(9600);
Wire.begin();
//Gyro
while (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
};
gyro.enableDefault();
//Compass
compass.init();
compass.enableDefault();
compass.m_min = (LSM303::vector<int16_t>){
-460, -372, -491 };
compass.m_max = (LSM303::vector<int16_t>){
+321, +453, +227 };
}
//---------------------------------------------------------------------MAIN------------------------------------------
void loop()
{
compass.read();
ax = (int)((compass.a.x/(16)));
ay = (int)((compass.a.y/(16)));
az = (int)(compass.a.z/(16));
heading_az = compass.heading((LSM303::vector<int>){
-1, 0, 0 }
)*D2R;
snprintf(report, sizeof(report), "Acc[X,Y,Z]: %3d %3d %3d AZ
Serial.println(report);
}
tnx