-
Notifications
You must be signed in to change notification settings - Fork 41
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
Problems using library with Arduino NANO BLE Sense #7
Comments
then it works? |
The values seeems to 'stabilize' but then they gain a step. I've tried also don't using mag values with The integration you're calculating could be the cause of this angle difference? |
I am working with the NANO BLE Sense as well, this is my experience: @redflowIT I was wondering about those "steps" as well. The gyroscope is usually set to 245 deg/s it is rather easy to move the Arduino faster than that. In those instances the raw gyro values are at the limit and the orientation destabilizes. This is my code:
I use the https://github.com/sparkfun/SparkFun_LSM9DS1_Arduino_Library library, make sure to have this sparkfun/SparkFun_LSM9DS1_Arduino_Library#37 PR. The calibration was done with this https://github.com/jremington/LSM9DS1-AHRS library |
Any solution to this? It feels like the sensors are not at the same scale. The gyro will make the plot line jump to a position, then it will slowly move to another one dictated by the accelerometer. For IMU with the Nano 33 I'm using FemmeVerbeek's code and have calibrated my gyro and accell, still the same issue. Is it a measuring unit issue? |
@LazaroFilm did you try the code in this #7 (comment) ? It works well, except that the gyro is not calibrated, but that is an easy fix. We can just gather a few values while holding the arduino still, an apply them in the Also note that the LSM9DS1 gyro and accelerometer use a left handed coordinate system, while the Magnetometer uses a right handed one. Aside form the effect I mentioned in the comment above this will also introduce the jumps in the orientation. Flipping the Gyro and Acc X-Axis will fix that and align all the coordinate systems:
|
Nice @jonasBoss ! I am curious too, @LazaroFilm have you tried it?? |
I used the code from @jonasBoss and visualized it, since I like to see things move, rather than raw numbers. https://www.youtube.com/watch?v=McNhcrJgBuQ You can see a slight drift at the beginning, which fades away after a few seconds. This was done without any calibration and it delivers solid data after the initial drifting. |
Hi, I used @jonasBoss code.. Do I need to use Wire1?? |
@norahb #if WIRE_HOWMANY > 0
arduino::MbedI2C Wire(I2C_SDA, I2C_SCL);
#endif
#if WIRE_HOWMANY > 1
arduino::MbedI2C Wire1(I2C_SDA1, I2C_SCL1);
#endif Do you use the Arduino style If you write your own |
@jonasBoss I used setup() loop() style,, |
Hi Aster94
I'm using library with an Arduino BLE Sense with embedded Gyroscope and an external micro display. It seems it needs seconds to stabilize values, should I use an external IMU or what I'm doing wrong?
`#include <Arduino.h>
#include <Arduino_LSM9DS1.h> // Sensoristica
#include <U8g2lib.h> // Display
#include <SensorFusion.h> // Calcolo
// Inizializzazione DISPLAY
U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_MIRROR, /* clock=/ 9, / data=/ 8, / cs=/ 11, / dc=/ 10, / reset=/ 12); // PROTOTIPO SALDATO SU BASETTA
//U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_MIRROR, / clock=/ 11, / data=/ 12, / cs=/ 9, / dc=/ 10, / reset=*/ 8);
const int samplingCicleBeforeRefresh = 30;
SF fusion;
float xAcc, yAcc, zAcc;
float xGyro, yGyro, zGyro;
float xMag, yMag, zMag;
float deltat;
int roll, pitch, yaw;
void setup() {
Serial.begin(115200);
//while (!Serial);
Serial.println("Started");
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
//filter.begin(sensorRate);
u8g2.begin();
deltat=fusion.deltatUpdate();
// Abbasso il PIN per poter attivare il display (aggancio la massa)
pinMode(A0, OUTPUT);
digitalWrite(A0, LOW);
}
void refreshDisplay(int yaw, int pitch, int roll)
{
char buff[16];
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_artosserif8_8u);
snprintf (buff, sizeof(buff), "R%d ", yaw);
u8g2.drawStr(10,10,buff);
Serial.print(buff);
snprintf (buff, sizeof(buff), "F%d ", pitch);
u8g2.drawStr(10,19,buff);
Serial.print(buff);
snprintf (buff, sizeof(buff), "I%d ", roll);
u8g2.drawStr(10,28,buff);
Serial.println(buff);
u8g2.sendBuffer();
}
void loop() {
// read accelerometer & gyrometer:
IMU.readAcceleration(xAcc, yAcc, zAcc);
IMU.readGyroscope(xGyro, yGyro, zGyro);
IMU.readMagneticField(xMag, yMag, zMag);
deltat = fusion.deltatUpdate(); //this have to be done before calling the fusion update
//choose only one of these two:
//fusion.MahonyUpdate(xGyro, yGyro, zGyro, xAcc, yAcc, zAcc, deltat); //mahony is suggested if there isn't the mag and the mcu is slow
fusion.MadgwickUpdate(xGyro * DEG_TO_RAD, yGyro * DEG_TO_RAD, zGyro * DEG_TO_RAD, xAcc, yAcc, zAcc, xMag, yMag, zMag, deltat); //else use the magwick, it is slower but more accurate
// print the heading, pitch and roll
roll = round(fusion.getRoll());//round(fusion.getRoll()-90);
pitch = round(fusion.getPitch());
yaw = round(fusion.getYaw());//round(180-fusion.getYaw());
//Serial.print("Y ");
//Serial.print(yaw);
//Serial.print(" P ");
//Serial.print(pitch);
//Serial.print(" R ");
//Serial.println(roll);
refreshDisplay (yaw, pitch, roll);
}`
Thank you
Regards
The text was updated successfully, but these errors were encountered: