I have a 9DOF based with a ITG3200/ITG320?5 ADXL345 HMC5883L chips. The item is available at ebay.com http://www.ebay.com/itm/9DOF-9axis-degree-of-freedom-IMU-sensor-ITG3200-ITG320-5-ADXL345-HMC5883L-Module-/310513793857?pt=LH_DefaultDomain_0&hash=item484c107b41
Important is to connect the sensor to 3.3V instead of the 5V. My board has a VCC but I havent tried to connect it to 5V because I have no documentation of the sensor. It looks like it have a 3.3V regulator but it is not tested (yet)
Attach sensor to Ground.
The connection to I2C is simple. If the board dont show movement of the sensor, its possible to change the SCL/SDA. I do not have resistors to SCL/SDA. There is guides where pullup resistors is used. For me it worked without. (=KISS)
My first atemt to get the sensor working is to implement theFreeIMU.
- Download the FreeIMU library http://www.varesano.net/files/FreeIMU-20121122_1126.zip
The Library needs to be changed. The FreeIMU board have other chips. To change the FreeIMU the library have to be changed to an “older” FreeIMU board with
ITG3200/ITG320?5 ADXL345 HMC5883L chips.
// Uncomment the appropriated version of FreeIMU you are using //#define FREEIMU_v01 //#define FREEIMU_v02 #define FREEIMU_v03 // <========================================================================================= //#define FREEIMU_v035 //#define FREEIMU_v035_MS //#define FREEIMU_v035_BMP //#define FREEIMU_v04 // 3rd party boards. Please consider donating or buying a FreeIMU board to support this library development. //#define SEN_10121 //IMU Digital Combo Board - 6 Degrees of Freedom ITG3200/ADXL345 SEN-10121 http://www.sparkfun.com/products/10121 //#define SEN_10736 //9 Degrees of Freedom - Razor IMU SEN-10736 http://www.sparkfun.com/products/10736 //#define SEN_10724 //9 Degrees of Freedom - Sensor Stick SEN-10724 http://www.sparkfun.com/products/10724 #define SEN_10183 //9 Degrees of Freedom - Sensor Stick SEN-10183 http://www.sparkfun.com/products/10183 <====================================== //#define ARDUIMU_v3 // DIYDrones ArduIMU+ V3 http://store.diydrones.com/ArduIMU_V3_p/kt-arduimu-30.htm or https://www.sparkfun.com/products/11055 //#define GEN_MPU6050 // Generic MPU6050 breakout board. Compatible with GY-521, SEN-11028 and other MPU6050 wich have the MPU6050 AD0 pin connected to GND. // *** No configuration needed below this line ***
Start the FreeIMU example: FreeIMU_quaternion
In the serial monitor it gives alot of HEX figures that contains floats. This output is NOT for human eyes. Its for a visualization GUI made in processing.
Download processing: http://www.processing.org/
The processing platform looks like Arduino IDE.
Now we need the visualization GUI for processing. The processing if found in the download of FreeIMU under the processing directory.
Copy the processing directory to a easyer place like c:\processing.
Check the COM port used for the Arduino IDE. In my case it was COM28. Open the processing sketch FreeIMU_cube.pde.
Search for the code where processing is assigning the Serial port to lissening to. Chang it to our Arduino IDE Com port.
import processing.serial.*; import processing.opengl.*; Serial myPort; // Create object from Serial class final String serialPort = "COM28"; // replace this with your serial port. On windows you will need something like "COM28". <============================== float  q = new float ; float  hq = null;
Run the Arduino IDE sketch example for FreeIMU_quaternion WITHOUT starting the Serial monitor.
Run the Processing sketch to see how the board is moving.
Change the Processing to the sketch FreeIMU_yaw_pitch_roll.pde to get another view.
This is a guide to be sure that the board is working and that all libraries are in place.
Now to my problem:
The visualization GUI shows that the accelometers and the gyros have a drift over time. How do I get a steady direction from the yaw and combine it to the compass.
When I test the compass i get a heading that is very unstable. (testexamle for HMC5883L). The testexample is not tiltcompensated but even if its not moved it gives ±10 degress readings.
The purpose is to guide a robot with PID in a straight line. PID can adjust bad readings, but to start with good readings before the PID makes it alot easyer.
Any suggestion to get a steady reading from the compass with compensation from accelometers and Gyros?