Pages: [1]   Go Down
Author Topic: Sensor board MinIMU-9 Gyro, Accelerometer, and Compass  (Read 1202 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi  :)recently a bought MinIMU-9 Gyro, Accelerometer, and Compass and now i am testing it but there is someting i can't understand.Here is my source :
Code:
#include <Wire.h>
#include <L3G.h>
#include <LSM303.h>

L3G gyro;
LSM303 compass;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  
  if (!gyro.init())
  {
    Serial.println("Failed to autodetect gyro type!");
    while (1);
  }

  gyro.enableDefault();
   compass.init();
  compass.enableDefault();
}

void loop() {
  gyro.read();
 compass.read();
  Serial.print("A ");
  Serial.print("X: ");
  Serial.print((int)compass.a.x);
  Serial.print(" Y: ");
  Serial.print((int)compass.a.y);
  Serial.print(" Z: ");
  Serial.print((int)compass.a.z);
  
  Serial.print("G ");
  Serial.print("X: ");
  Serial.print((int)gyro.g.x);
  Serial.print(" Y: ");
  Serial.print((int)gyro.g.y);
  Serial.print(" Z: ");
  Serial.println((int)gyro.g.z);
  
  Serial.print(" M ");  
  Serial.print(" X: ");
  Serial.print((int)compass.m.x);
  Serial.print(" Y: ");
  Serial.print((int)compass.m.y);
  Serial.print(" Z: ");
  Serial.println((int)compass.m.z);

  delay(100);
}
and i receive all the values but they are changing withouT me moving the sensor or anityng else .The sensor and my arduino board are on the floor . Here is  what i get in serial monitor  
Code:
A X: -31 Y: -1 Z: 967 G X: 23 Y: -86 Z: 43
 M  X: -199 Y: -280 Z: -376
 A X: -19 Y: 12 Z: 943 G X: 16 Y: -90 Z: 61
 M  X: -197 Y: -282 Z: -380
 A X: -48 Y: 6 Z: 959 G X: 24 Y: -87 Z: 41
 M  X: -188 Y: -271 Z: -378
 A X: -41 Y: 11 Z: 961 G X: 27 Y: -52 Z: 64
 M  X: -202 Y: -282 Z: -377
 A X: -35 Y: 6 Z: 959 G X: 22 Y: -62 Z: 54
 M  X: -193 Y: -276 Z: -379
 A X: -25 Y: 6 Z: 958 G X: 7 Y: -81 Z: 67
 M  X: -199 Y: -281 Z: -377
 A X: -13 Y: 1 Z: 975 G X: 19 Y: -81 Z: 18
 M  X: -197 Y: -279 Z: -379
 A X: -27 Y: 6 Z: 937 G X: 48 Y: -51 Z: 73
 M  X: -191 Y: -272 Z: -378
Does someone now how to fix this?Here is the board in pololu website
Thanx.
« Last Edit: October 25, 2012, 12:14:27 pm by stunito0o0 » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi  smiley again i read in the internet that these values are different ,because  you need some kind of filter for  the data u receive .So far ok ,but i can't find a filter or tutorials anywhere .Could  someone give me an example or tutorial please.
Thanks ,
Stanislav smiley
« Last Edit: October 27, 2012, 07:44:15 am by stunito0o0 » Logged

Israel
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you need to use average results..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

If everything works sound in your board and in your connections with the sensor and the sensor it self ain't broken then, i suggest the problem is caused by other things.

You see, the flactuation on these values could be due to white noise, perhaps some magnetic fields interfierence or anything could cause it. You have to consinder the square error in the measurements as well.

The best way to deal with this, is kalman filter.

I think will be a good code example in arduino forums for the kalman filter implementation.

Hope this helps.

Minas
« Last Edit: January 24, 2013, 06:51:52 pm by minnnnnas » Logged

Pages: [1]   Go Up
Jump to: