Hello, I´m currently in a project with an Arduino nano IoT 33 plate, and I´m trying to get data from the IMU, both accelerometer and gyroscope.
The issue is that I´m not sattisfied with the +-4g range, and wish to change it to +-8g, but even trying to modify the Arduino library is not working, I´m getting that the correct register value is written, but I´m not getting any values bigger than 4g.
I don´t know if someone has come with this issue, if so, I would love to hear what you did.
untitled (arduino.cc)
Here is the datasheet I found on the register values.
Thanks in advance.
Care sharing your code changes to the library?
Seems to me that
writeRegister(LSM6DS3_CTRL1_XL, 0x4A);
should be changed to
writeRegister(LSM6DS3_CTRL1_XL, 0x4E);
In the begin()
function…
I have moved your topic from International > Spanish > Software to English forum.
From now on, please use the appropriate category for the language in which you wish to publish. This is important for responsible use of the forum, and it is explained here in the guide "How to get the best out of this forum."
This guide contains a lot of useful information. Please read it.
Thank you in advance for your cooperation.
Hey, here is the code change, I also done that but the sensor doesn´t receive any accelaration stronger than 4g
int LSM6DS3Class::begin()
{
if (_spi != NULL) {
pinMode(_csPin, OUTPUT);
digitalWrite(_csPin, HIGH);
_spi->begin();
} else {
_wire->begin();
}
if (!(readRegister(LSM6DS3_WHO_AM_I_REG) == 0x6C || readRegister(LSM6DS3_WHO_AM_I_REG) == 0x69)) {
end();
return 0;
}
//set the gyroscope control register to work at 104 Hz, 2000 dps and in bypass mode
writeRegister(LSM6DS3_CTRL2_G, 0x4C);
// Set the Accelerometer control register to work at 104 Hz, 4 g,and in bypass mode and enable ODR/4
// low pass filter (check figure9 of LSM6DS3's datasheet)
writeRegister(LSM6DS3_CTRL1_XL, 0x4E);
// set gyroscope power mode to high performance and bandwidth to 16 MHz
writeRegister(LSM6DS3_CTRL7_G, 0x00);
// Set the ODR config register to ODR/4
writeRegister(LSM6DS3_CTRL8_XL, 0x09);
return 1;
}
I also created another function to change the accelaration range register value, I don´t know if that is going to affect the change of range for good.
int LSM6DS3Class::setAccelerationRange(int range){
uint8_t value;
switch (range)
{
case 2:
value = 0x00;
break;
case 4:
value = 0x10;
break;
case 8:
value = 0x11;
break;
case 16:
value = 0x01;
break;
default:
break;
}
uint8_t regValue = readRegister(LSM6DS3_CTRL1_XL);
regValue &= ~(0x0C);
regValue |= (value << 2);
writeRegister(LSM6DS3_CTRL1_XL, regValue);
}
Are you using this library?
SparkFunLSM6DS3.h
LSM6DS3 Arduino and Teensy Driver
Marshall Taylor @ SparkFun Electronics
May 20, 2015
Nop, I was using Arduino_LSM6DS3.h, i don´t know if i have to do anything else in the begin fucntion, or what else.
The begin() routine that comes with the library you are not using seems to be more robust. Also, the library provides tools to change the acceleration rate.
You might want to try it