MKR IMU shield reliability ?

Hi,

I'm developing a project based on MKR IMU shield. Main objective is to build a rollover detector for agriculture tractors so precision is important. I've built a simple prototype based on Arduino MKRZERO + MKR IMU shield + touch screen display.

Code is functional, and I've mounted this setup on a platform which is attached to the ROPS structure, powered with the 12V battery in tractor, of course there is a simple power supply circuit there. In this way the display is visible to driver without loosing attention to terrain and driving tasks.

As the tractor is supposed to run always to the ground, only roll and pitch dimensions are considered in this project by now (other variables like angular speed, accelerations can be important for future releases) and the prototype works fine in lab conditions.

Problem appears when mounting the arduino setup in the tractor, the IMU shield is starting to provide, clearly, wrong data and accumulate error after starting the tractor movements. The only solution is to restart the arduino. I don't know if it's related to vibration or tractor movements but the sensor is clearly unuseable in these conditions.

Any idea ? Any update to library/sensor firmware/etc. ? Maybe I need to look for other IMU devices ?

Regards, Joan Altadill

Problem appears when mounting the arduino setup in the tractor, the IMU shield is starting to provide, clearly, wrong data and accumulate error after starting the tractor movements. The only solution is to restart the arduino. I don't know if it's related to vibration or tractor movements but the sensor is clearly unuseable in these conditions.

It would help to know which values go wrong and in what way. As the sensor contains a MPU which aggregates the raw values to provide angular values it's possible that vibrations alter the result. But I have some doubts that the error accumulates except if you accumulate it in your code. As you failed to post your code it's up to you to check that.

Hi,

Sorry for this really late feedback, but after completing the first field test of the sensor I’ve unmounted the circuit and stopped working on project. I’m a newbie with tractors and my terrain is really difficult because slopes so I’ve spent a lot of time learning how to use it safely. But now I’m resuming the project.

When I test the circuit on my desktop, with USB power direct to the arduino it never fails. I can move, shake, etc. the circuit works without issues and it always shows the right value, even when shaking for a minute for example.

Relevants parts of code ( omitting display, touch screen, etc. ):

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <MKRIMU.h>
#include <Adafruit_FT6206.h>

// To enable debugging and touch screen capabilities
#define debug false
#define touch false

// Text size of inclination and degrees symbol
#define size1 7
#define size2 4

// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ts = Adafruit_FT6206();

// For the Adafruit shield, these are the default.
#define TFT_DC 6
#define TFT_CS 7
// #define SD_CS 5

// danger threshold in degrees
#define danger 20

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

// Valor negatiu per assegurar que de bon començament es mostra l'angle.
int roll = 0,
    pitch = 0,
    rollprev = -99.0,
    pitchprev = -99.0;

float xp0 = 0.0, 
      yp0 = 0.0, 
      xp1 = 0.0, 
      yp1 = 0.0;

float xp2 = 0.0, 
      yp2 = 0.0, 
      xp3 = 0.0, 
      yp3 = 0.0;  

bool chg1 = true,
     chg2 = true;

boolean RecordOn = false;

float IMUheading, IMUroll, IMUpitch;
void initAll() {

  // Tft
  tft.fillScreen(ILI9341_BLACK);
  tft.setRotation(1);
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2);  

  // IMU
  if (!IMU.begin()) {
    tft.println("Failed to initialize IMU!");
    while (1);
  }
  
}
void setup() {
 
  tft.begin();

  initAll();
  diagnostics();
  delay(3000);

  tft.fillScreen(ILI9341_BLACK);
  yield(); 

  tft.setTextSize(8);
  tft.setTextColor(0xFFFF, 0x0000);

  //randomSeed(analogRead(0));

  #if touch
    redBtn();
  #endif  
}

void loop(void) {

  if (IMU.eulerAnglesAvailable()) {
    IMU.readEulerAngles(IMUheading, IMUroll, IMUpitch);
  }

  // els angles d'han d'acondicionar pq depen de com esta col·locat el circuit IMU
  // arrodonim a graus
  roll  = round(IMUroll);
  pitch = round(IMUpitch);
    
  // redraw only if there are changes 
  if (rollprev  == roll)  chg1 = false; else chg1 = true;
  if (pitchprev == pitch) chg2 = false; else chg2 = true;

  // no interessa el signe en el número, només l'inclinació cap on sigui
  // però la línia és convenient que estigui ben orientada
  displayIncLines(roll, chg1, pitch, chg2);
  
  /*for (int i=24; i <= 25; i++) {
    tft.fillRect(0, 0, tft.width() / 2, 80, ILI9341_BLACK);
    tft.setCursor(0, 10);
    tft.print(i); tft.print("  ");tft.print(char(i)); delay(300);
  }*/
  
  rollprev  = roll;
  pitchprev = pitch;

  // Mostreig, 250 = 4Hz, aprox !!
  delay(250);
}

Not sure if powering the circuit from the tractor battery, 12V DC using a power supply circuit to generate stable 5 Volts can influence the sensor behavior.

On the other hand I’m considering to not use the MKRIMU library and try to get the data directly from Bosch sensor using only BNO055_support.h library. I’m evaluating this option now.

Regards,
Joan

If the only requirement is to distinguish between the right way up vs upside down then an old style mercury tilt switch, or perhaps a series of tilt switches at different angles may work. You can tell if the geometry is correct just by looking at where the blobs of mercury are sitting in relation to the electrodes.

The inertia and surface tension of the mercury makes it somewhat resistant to false triggering by vibration. https://www.youtube.com/watch?v=EfV2jg1qeyY

The problem might be that the vibrations of the tractors motor get in sync with the IMU read outs which may show a completely wrong picture. One way is to change the read out frequency (not so easy if you use the library), the other and better way is to isolate the device as good as possible from the vibrations. That can be achieved by mounting it inside a professional microphone mount (often seen in radio stations). Of course you don’t have to buy one these expensive parts, you can do create such a thing easily yourself using a few elastics.