-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sampling rate/range configuration? #2
Comments
I had the same issues best is to use the sparkfun library So your code would become; #include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>
int int_received = 0;
unsigned long tijd;
LSM9DS1 imu;
void setup() {
Serial.begin(115200);
while (!Serial);
Wire1.begin();
Wire1.setClock(400000);
while (imu.begin(0x6B, 0X1E, Wire1) == false)
{
Serial.println("Failed to communicate with LSM9DS1.");
Serial.println("Will retry in 1 second.");
delay(1000);
}
imu.settings.accel.sampleRate = 6;
imu.settings.gyro.sampleRate = 6;
imu.initAccel();
imu.initGyro();
}
void loop() {
Serial.println("awaiting command");
Serial.println(imu.settings.gyro.sampleRate);
delay(1000);
int_received = Serial.parseInt();
switch(int_received) {
case 0 : // parseInt polls and returns 0 if nothing is received so ignored
break;
case 1 : {Serial.println("One received");
int total_time = 952;
int iteration = 0;
tijd = millis();
while(iteration<total_time){
if (imu.accelAvailable())
{
imu.readAccel();
iteration = iteration + 1;
}
}
unsigned long difference;
difference = millis()-tijd;
if(difference>1100){
Serial.println("Test failed");
Serial.println(difference);
}
else{
Serial.println("Test succeeded in ms");
Serial.println(difference);
}
break;}
default:{Serial.println(int_received);
Serial.println("Invalid command");
break;}
};
} |
In operational mode 2 the gyro and accelerometer share their ODR. Both obey to the setting in the gyro register. I've written an update for this library with the full possibilities of changing and interrogating the chip's ODR, Full scale and bandwidth filter value. I made a pull request here and am awaiting the answer. |
is there a specific reason for fixing imu sampling ranges and rates?
The text was updated successfully, but these errors were encountered: