Hi!!
I recently bought a IMU-10DOF ...
The question is simple ...
How do I change the range of +/- 2G to a higher range ??
The reason is because I saturates to reach 20.01 m / s ^ 2 .
Thank You!!
Adafruit 10DOF IMU
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adafruit 10DOF IMU
You change bits FS0 and FS1 in CTRL_REG4_A as described in section 7.1.4 of the datasheet (page 26):
http://www.adafruit.com/datasheets/LSM303DLHC.PDF
http://www.adafruit.com/datasheets/LSM303DLHC.PDF
- fersical
- Posts: 19
- Joined: Sun Jul 19, 2015 6:08 pm
Re: Adafruit 10DOF IMU
Ok!! Thanks for the reply!!
I need to load this value:
write8(0x32, 0x23, 0x10); // (ADDRESS LSM303 , REGISTER 4 , +- 4G)
In this code:
But I don't know how
Or must be edited from the library Adafruit_LSM303_U ??
It should be easy, but I couldn't.
I need to load this value:
write8(0x32, 0x23, 0x10); // (ADDRESS LSM303 , REGISTER 4 , +- 4G)
In this code:
Code: Select all
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
/* Assign a unique ID to this sensor at the same time */
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321);
void setup(void)
{
Serial.begin(9600);
Serial.println("Accelerometer Test"); Serial.println("");
delay(8000);
/* Initialise the sensor */
if(!accel.begin())
{
/* There was a problem detecting the ADXL345 ... check your connections */
Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
while(1);
}
}
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
accel.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */
Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 ");
delay(500);
}
Or must be edited from the library Adafruit_LSM303_U ??
It should be easy, but I couldn't.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adafruit 10DOF IMU
The .write8() method is declared private to the class, so you'd need to change the class declaration or modify the library.
You'll need to do a little more than just write the range bits to register 4 though.. you don't want to change any of the other bits.
The code you want would look like:
and you can put it in the .begin() method.
You'll need to do a little more than just write the range bits to register 4 though.. you don't want to change any of the other bits.
The code you want would look like:
Code: Select all
uint8_t reg4_a = read8( LSM303_ADDRESS_ACCEL, LSM303_REGISTER_ACCEL_CTRL_REG4_A ) & 0xCF;
write8( LSM303_ADDRESS_ACCEL, LSM303_REGISTER_ACCEL_CTRL_REG4_A, reg4_a | 0x10 );
- fersical
- Posts: 19
- Joined: Sun Jul 19, 2015 6:08 pm
Re: Adafruit 10DOF IMU
Ok..I Remove the declaration of private in the library Adafruit_LSM303.h
The code to add is:
The Serial.print gives a value of 16 ( 0X10 in hex ) .
This indicates that the reg4 was modified correctly!!!
However, the maximum value of the acceleration continues to indicate -20.01 :(
I continue implementing programming wrong ?
Thanks for the great help !!
The code to add is:
Code: Select all
if(!accel.begin())
{
Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!"));
while(1);
};
accel.write8(LSM303_ADDRESS_ACCEL,LSM303_REGISTER_ACCEL_CTRL_REG4_A,0x10); // +- 4G (00010000)
byte reg4_a = accel.read8(LSM303_ADDRESS_ACCEL,LSM303_REGISTER_ACCEL_CTRL_REG4_A);
Serial.println(reg4_a);
...... etc etc etc
This indicates that the reg4 was modified correctly!!!
However, the maximum value of the acceleration continues to indicate -20.01 :(
I continue implementing programming wrong ?
Thanks for the great help !!
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adafruit 10DOF IMU
You'll also need to change the scaling factor that tells the code what units to use. That's on line 36 of the .cpp file:
If you've gone from 2G to 8G, you need to change that value from 0.001 to 0.004.
Code: Select all
static float _lsm303Accel_MG_LSB = 0.001F; // 1, 2, 4 or 12 mg per lsb
- fersical
- Posts: 19
- Joined: Sun Jul 19, 2015 6:08 pm
Re: Adafruit 10DOF IMU
YESSSSSSSSS!!!!!!!! THANK TO ALL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)
Please be positive and constructive with your questions and comments.