LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

lsm303dlhs acc with labview - incorrect/diffrent readings

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

0 Kudos
Message 1 of 5
(4,573 Views)

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?

0 Kudos
Message 2 of 5
(3,790 Views)

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

0 Kudos
Message 3 of 5
(3,790 Views)

Could you post the Arduino code that you are using (where you got [0,0,1035])?

0 Kudos
Message 4 of 5
(3,790 Views)

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 %3d",ax,ay,az,(int)(heading_az*R2D));
  Serial.println(report);

}

tnxsensors_result.png

0 Kudos
Message 5 of 5
(3,790 Views)