9DOF IMU - Setting Sensitivity Range of Accelerometer

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
brocks
 
Posts: 3
Joined: Thu Jun 27, 2013 8:10 am

9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by brocks »

I am attempting to use the 9DOF IMU board (Product ID: 1714) to map the motion of a vehicle. In looking through the libraries I have not found anything that involves setting the acceleration sensitivity range on the LSM303DLHC accelerometer/magnetometer. The closest I have found is in the file "Adafruit_LSM303_U.cpp" there is a function which appears to set the gain of the magnetometer. Different cases including LSM303_MAGGAIN_1_3, LSM303MAGGAIN_1_9, etc. I am curious as to if these relate to the 2, 4, 8, and 16g settings of the accelerometer? If not, how do I set this sensitivity in an Arduino sketch?

I have also purchased ADXL345 accelerometer (Product ID: 1231) and have used that as a reference. Here there are functions which you pass arguments such as ADXL345_DATARATE_3200HZ and ADXL345_RANGE_8_G to set the data rate and sensitivity. Does the 9DOF board have similar functions?

Thanks for the help!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by adafruit_support_rick »

Unfortunately, the library does not include a function for setting the accelerometer sensitivity. However, it is easy to do. Please reference section 7.1.4 of the datasheet (http://www.adafruit.com/datasheets/LSM303DLHC.PDF ).

You have to read register CTRL_REG4_A (23h), adjust the bits FS0 and FS1, and write the result back to CTRL_REG4_A.

User avatar
brocks
 
Posts: 3
Joined: Thu Jun 27, 2013 8:10 am

Re: 9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by brocks »

Thanks for the response and I see in the data sheet where it is stated. So this may be a dumb question, but how do you gain access to the register? I have been looking at the ADXL345 library files and see code the aimed at accomplishing a similar task. Would I need to add similar code to the 9 DOF library files or is it possible to add this code to an Arduino sketch? I apologize for the ignorance in this area, my background is in mechanical areas.

Thanks for the assistance.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by adafruit_support_rick »

You can call the library functions readRegister and writeRegister from your sketch.
There is already a #define ADXL345_REG_WINDOW for register 0x23 in the library's .h file, so you can use that:

Code: Select all

  #define FS0 0x10
  #define FS1 0x20

  #define TWO_G 0
  #define FOUR_G FS0
  #define EIGHT_G FS1
  #define SIXTEEN_G (FS1 | FS0)

  . . . etc . . .

  uint8_t window = readRegister(ADXL345_REG_WINDOW);  //get current register contents
  window = window | SIXTEEN_G;   //adjust to range to 16G
  writeRegister(ADXL345_REG_WINDOW, window); //update register

  . . . etc . . .
Or, do it all in one line this way:

Code: Select all

  writeRegister(ADXL345_REG_WINDOW, (readRegister(ADXL345_REG_WINDOW) | SIXTEEN_G));

User avatar
bhatadb
 
Posts: 17
Joined: Thu May 01, 2014 3:46 pm

Re: 9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by bhatadb »

@ BrockS : I am working on a similar project, and was wondering if you were able to make headway with the vehicle navigation system.

I have a feeling my double integration isn't going to be good enough, and so was wondering how your project is coming along.

P.S: I am a Mechanical Engineer too, so your statement about the coding resonates with me!

Thanks,
Abhi

User avatar
brocks
 
Posts: 3
Joined: Thu Jun 27, 2013 8:10 am

Re: 9DOF IMU - Setting Sensitivity Range of Accelerometer

Post by brocks »

Abhi:

The honest answer is that I haven't gotten too far on that project. I was able to record data from the sensor, but have not gotten comfortable enough with the signal processing aspect to remove the noise that I received from the accelerometer. Hence after performing the integration, I was not able to get results that matched a known path taken by the vehicle. I'm sure that it is my lack of knowledge that is holding me back and not the capabilities of the hardware.

Good luck with your project.
Brock

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”