Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
6DOF Arduino

6DOF Arduino

Ratings: (0)|Views: 1,047|Likes:
Published by gbetromero

More info:

Published by: gbetromero on Apr 17, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

12/07/2012

pdf

text

original

 
6DOF Arduino: Compass & Accelerometer
This Arduino library is a mixed bag containing a number of functions to facilitate rapid sensor
 
integration between a three axis compass and a three axis accelerometer. Where speed isrequired, function math is 8.8 fixed point, while non-performance functions use float or somecombination of both. The library contains detailed examples for each section. There are three main parts making up this library, for introductory purposes, these parts are:
1.
 
Compass Hard Iron Offset Auto-Solver 2.
 
 Accelerometer Yaw Pitch & Roll Calculator 3.
 
360° Compass Tilt Compensation
The first item, the hard iron offset solver is an independent group of functions designed tocapture a set of semi-arbitrary 3 axis magnetic data points around a sphere and then calculate thex, y & z hard iron offsets. It produces consistently repeatable results by way of outlier datarejection based on an established trust relationship with axial sensitivity. A closer look at theparts that make up this solver reveal four functions:deviantSpread()
 – 
Picks eight positions around a sphere where each combination is a sampling of positive and negative x, y, z positions. To improve solving, it prefers to pick combinations whereone of the x, y, z components is a low number.calOffsets()
 – 
This function calls the solver for 6 of the 8 position datasets and creates an inversetrust associated with the result. After which, it bubbles the two remaining datasets throughcomparing the inverse trust to reject poor solutions. The accepted results get averaged to makeup the x, y & z hard iron offsets.
 
calSense()
 – 
This bit is from David W. Schultz.It does the preparatory work of stuffing the arrays and calling the solver. After which it computes offsets and axis sensitivities. It is modifiedfrom original to accept integers and computes an inverse trust variable with respect to axialsensitivity.linearEquationsSolving()
 – 
This is the actual solver which uses Gaussian elimination to deducethe axial limits of the datasets representing the sphere. This code is written by Henry Guennadi
 
Levkin. An example layout with the Honeywell HMC5883L compass, the Freescale MMA8453Qaccelerometer, a 3v3 linear power supply and associated i2c level shifting:The second and third parts of the library, the angle calculation and tilt compensation, are tightlyintegrated with each other, being they are inter-dependent. The basis of this code is the Freescaletilt compensation application note which has been modified to perform under the Arduino
 
environment. Changes were also made to improve the efficiency on the 8bit AVR platform.These two parts break down into a plethora of handy functions including some very usefultrigonometric fixed point math:
 
atan2Int()
 – 
This is a wrapper for the fixed point math function atanInt. It takes a ratio-metricinput of x and y and returns degrees times 100 using a first, third and fifth order polynomialapproximation.sinInt()
 – 
Another trig function in fixed point integer math which aptly named, returns the sine of an angle. According to wikipedia, the word sine comes from a Latin mistranslation of the Arabicword jiba.compCompass()
 – 
All the heavy lifting is done in this behemoth of an function. The deviceangles are computed and the tilt compensated magnetometer values are un-rolled, un-pitched andun-yawed.divInt()
 – 
This helper is an accurate integer division function. The accuracy comes in part bymaximizing both the denominator and numerator equally to reduce quantization error.lowPassInt()
 – 
Finally we have a clever lowpass filter for the computed angles. What makes thisfunction special is that it operates using modulo arithmetic to prevent rollover errors on deadNorth transitions where 0° starts and 360° ends.
And finally it’s now time for some pretty moving pictures. In the following vi
deo we are realtime plotting in 3D utilizing 
 processing code. The video is in threeparts, first showing the 3D plot of the raw unadulterated magnetometer data from a HoneywellHMC5883L, notice the significant Z offset caused by some ferrous material on the PCB. As aresult of input saturation, out of bounds of data is discarded and the plot takes longer. The secondplot is after running the hard iron auto-solver, we can see the sphere is now centered and itpopulates very quickly. And the third plot is of the tilt compensated magnetometer data stream.Make some popcorn, sit back and enjoy the romantic comedy of error correction:The accelerometer used in this test is the Freescale MMA8453Q for which we previouslyreleased the Arduino library here: http://n0m1.com/2012/02/12/shake-rattle-roll-the-mma8453q-
 
Shake, Rattle & Roll: The MMA8453Q & Arduino

Activity (5)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
elfrascos liked this
tm5200 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->