scieee Open visual document viewer

Hard iron distortion compensation for 3 axis magnetometer

Cornea, George Mihai; Nilgesz, Arnold; Ionut Flaviu, Birouas; Radu, Tarca

Abstract

This paper presents the way how the hard iron effect could be compensated and a way to implement it on a small power device such as a microcontroller. Because of the magnetized materials that can stay near a magnetometer sensor and because of the very small magnetic field of the Earth, before the use of the measured values from a magnetometer to determine the heading (angle with the N direction) of the sensor a compensation is needed.

Full text

Recen Inno a ions in Mecha onics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/ iim.2016.1-2/5. Ha d i on dis o ion compensa ion o 3 axis magne ome e Co nea Geo ge Mihai Depa men o Mecha onics Uni e si y o O adea, Facul y o Enginee ing and Managemen O adea, Romania mihai@ echswa m. o Nilgesz A nold Depa men o Mecha onics Uni e si y o O adea, Facul y o Enginee ing and Managemen O adea, Romania Bi ouas Ionu Fla iu Depa men o Mecha onics Uni e si y o O adea, Facul y o Enginee ing and Managemen O adea, Romania Ta ca Radu Depa men o Mecha onics Uni e si y o O adea, Facul y o Enginee ing and Managemen O adea, Romania Abs ac — This pape p esen s he way how he ha d i on e ec could be compensa ed and a way o implemen i on a small powe de ice such as a mic ocon olle . Because o he magne ized ma e ials ha can s ay nea a magne ome e senso and because o he e y small magne ic ield o he Ea h, be o e he use o he measu ed alues om a magne ome e o de e mine he heading (angle wi h he N di ec ion) o he senso a compensa ion is needed. Keywo ds—3 axis magne ome e ; compensa ion; ha d i on; I. INTRODUCTION The e a e 2 main ypes o magne ic dis o ions ha ha e o be aken in o accoun when designing an eCompass: ha d i on dis o ions and so i on dis o ions. Ha d i on dis o ions a e made by ma e ials ha p oduce a cons an magne ic ield which is in supe posi ion wi h he ea h magne ic ield. A speake o a mo o magne , o example, will p oduce a ha d i on dis o ion. This dis o ion can be isualized as an cons an o se om he o igin o he ci cle o he (0,0,0) coo dina e poin . In small obo s ha d i on dis o ion is he componen ha ends o be o he g ea es impo ance. This is due o he ac ha he o al mass o e ous ma e ials in he obo is small, bu s ong magne s a e used o ac ua o s. In o de o ge a usable heading om he magne ome e senso s i is a mus o deal wi h ha d i on in e e ences. I is o be no ed ha in o de o be able o apply he compensa ion, he magne ic ields ha e o be cons an and in he same posi ion ela i e o he senso . So i on dis o ions a e made by ma e ials ha in luence he ea h magne ic ield bu don' ha e a magne ic ield o hei own. They a e mo e compu a ional expensi e o elimina e since hey a e no cons an wi h espec o o ien a ion. So i on dis o ions can be isualized as a il ed ellipsoid a he han a pe ec ly cen e ed ci cle. So i on dis o ions a e signi ican only in ehicles ha con ain a lo o e ous ma e ials. I has a ce ain in luence on he compass o a ca o ai plane (whe e o analogic compasses he e a e co ec ing ables) bu i is ce ainly an impo an componen in he dis o ions o a ships compass as can be seen in Fig. 1. Fig. 1. Dis o ions in he magne ic ield made by a la ge mass o e ous ma e ial such as a ship I has been measu ed ha a la ge con aine ship can make a signi ican dis o ion o a ew km om i s posi ion. O he ypes o in e e ences a e he e a ic in e e ences ha can be somewha p edic ed and because o his co ec ed. An example o his ype o in e e ence is he in e e ence done by he cu en ha passes a pai o conduc o s in o de o eed a mo o . Based on he cu en loop su ace and cu en in ensi y, he e will be a ce ain magne ic ield gene a ed. Since he cables could be conside ed o be ixed in espec o he senso , only he cu en is a iable so ha i he cu en can be measu ed, a compensa ion able can be de e mined o be used wi h di e en cu en in ensi ies o compensa e he heading. This ype o in e e ence can be g ea ly minimized by using good p ac ice echniques when designing he high cu en ca ing cables inside he obo , such as minimizing he loop be ween cu en eed and cu en e u n, wis ing he high cu en cables e c. Recen Inno a ions in Mecha onics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/ iim.2016.1-2/5. II. IDEAL CONDITIONS COMPENSATION In he case o an ideal da ase o measu emen s he ha d i on compensa ion could be ex emely easy o be compu ed. A lo o examples using his easy me hod a e p esen ed on he in e ne mos ly because o i s ease o use and implemen a ion. One plo ep esen ing his kind o da a can be obse ed in Fig. 2. Fig. 2. Ideal condi ions o compass calib a ion da a acquisi ion In an ideal case he calib a ion da a o he magne ome e would be looking like he abo e images. This can be done h ough ca e ully guiding he senso ca ie boa d on a la su ace ( o he le da a se ) o by o a ing he senso in e e y possible di ec ion, homogeneously spacing as many measu emen s as possible. Ou side a con olled en i onmen his kind o calib a ion da a acquisi ion can be eally icky o be done i no impossible. Fig. 3. Pololu 3 axis magne ome e , 3 axis accele ome e and 3 axis gy oscope used o es The ype o da a om he le side o Fig. 2 can be aken by guiding he senso on a pe ec ly la su ace and slowly u ning i a ound. This will gua an y us ha all he measu emen s om a ce ain axis ele a ion will be egis e ed and a local minimum and a local co esponding maximum is ac ually measu ed. The calib a ion o each axis is made sepa a ely, one a e ano he , by aking he maximum and minimum alues on he measu ed axis and compu ing he a e age o he 2. The esul is he ac ual o se o he axis o he compensa ed senso se up. I is o be no ed ha his me hod employs he usage o he local minimum and maximum de ined as a slice ue he sphe e ha would ep esen he ull measu emen space. Any misalignmen o one o he measu emen s could place he esul ing o se way o cha by g ea ly in luencing he a e age o he 2 alues. E en i his me hod is ha de o be made in uncon olled en i onmen s i s ill can be done i a la su ace is a ailable o guide he senso on i . On he igh side o Fig. 2 ano he measu emen da ashee can be seen. This ime he en i e measu emen space was homogenously illed wi h measu emen da a. Be ween hose 2 pic u es i can be seen ha he sphe e con aining he i s measu emen se (le side) also con ains he second measu emen se ( igh side). The di e ence be ween he wo is ha he second se o measu emen s ends o con ain he absolu e maximum and absolu e maximum on each axis. In his case he o se can be simul aneously compu ed as he a e age o he max and min on each axis o he magne ome e . The second da ase o measu emen is p ac ically impossible o be made wi hou special equipmen ha will b ing he senso in e e y possible posi ion. Fo he p esen a ion pu pose i was gene a ed by using he sphe e om he i s da ase . The o se s ha whe e de e mined can go om he e on o be used by shi ing all he measu emen s done on hei co esponding axis by he amoun de e mined wi h he a e age o he ex emes. When dealing wi h his ype o da a he de e mina ion o he bias ec o is ela i ely simple. The chance o eaching a maximum on a ce ain axis wi hou ac ually measu ing i as a sample is less likely. This way i is sa e o assume ha he bias on e e y axis is de e mined by he a e age o he minimum and maximum o he measu ed alues. This me hod can be easily op imized o i a limi ed capabili y de ice as a mic ocon olle by only sa ing he minimum and maximum o he measu ed alues on each axis and hen compu e he a e age, gi ing he bias. In he i s case we also ha e o impose ha he compensa ion p ocedu e o be done sepa a ely on each axis. As simple his implemen a ion would be, bo h in e ms o equi ed p ocessing powe and implemen a ion, i s majo se back is he complica ed and ha dly epea able compensa ion echnique ha has o be employed by he use . Many imes Recen Inno a ions in Mecha onics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/ iim.2016.1-2/5. his p ocedu e has o be done on he ield, wi h no la su aces o be used o he calib a ion o he obo . III. FIELD/REAL CONDITION COMPENSATION When wo king wi h ield da a, in he case o an „on he spo ” calib a ion we mos likely will end up wi h an acquisi ion ha will look like he one in Fig. 4. Fig. 4. Magne ome e compensa ion da a gene a ed by he ee, andom mo emen o he senso by hand I can be seen ha on he high scale o he mag_x axis he e is a highe densi y, making i is mo e likely ha he senso hi i s maximum in a measu emen bu on he low side he e is a lack o measu emen s ha will esul in an o se -ed sphe e a e co ec ion applica ion. This ypes o „mis akes”, une en co e age o he minimum and maximum o each axis is impossible o con ol in such a compensa ion, done by an un ained ope a o , ha doesn' unde s and he mechanics behind he compensa ion p ocess o e en by someone who unde s ands hem bu is unable o pe ec ly co e he sphe e. Ano he obse a ion is ha , i we conside he so i on in e e ences o be small enough o be negligible, we a e dealing wi h a pe ec sphe e. Tha pe ec sphe e can be su icien ly de e mined by 4 poin s ha a e on i s su ace. Because o eal da a con aining, e en i negligible, so i on in e e ences and noise, a bes i app oach is he bes solu ion o he da ase . A sphe e can be de ined by speci ying i s cen e poin (Xc,Yc,Zc) and i s adius, R. So he goal o his example is o de elop a NLREG p og am ha will compu e he alues o Xc, Yc, Zc and R ha cause a sphe e o bes i a se o da a poin s whose coo dina es (Xp,Yp,Zp) a e p o ided as a andom selec ion o measu emen s. The ma ix o m o he sol e can be seen in equa ion (1). (1) Whe e X is he measu emen ma ices and Y is he ec o o known dependen a iables acco ding o F eescale AN4399. (2) (3) In p ac ice i is mo e con enien o add each new measu emen as i comes a he han making a huge ma ices o measu emen s and compu e he esul om hem. The ma ices ep esen ed a (2) and (3) can be compu ed o each measu emen in pa and only he in e media e esul o be sa ed in o memo y. By doing so a lo o memo y space can be spa ed which is e y impo an in a low spec sys em as a mic ocon olle . The unc ions ha a e doing he calcula ions a e he ollowing: oid magCalAddx x( double x, double y, double z) { x x[0][0] += x*x; x x[0][1] += x*y; x x[0][2] += x*z; x x[0][3] += x; x x[1][0] += x*y; x x[1][1] += y*y; x x[1][2] += y*z; x x[1][3] += y; x x[2][0] += x*z; x x[2][1] += y*z; x x[2][2] += z*z; x x[2][3] += z; x x[3][0] += x; Recen Inno a ions in Mecha onics (RIiM) Vol. 3. (2016). No. 1-2. DOI: 10.17667/ iim.2016.1-2/5. x x[3][1] += y; x x[3][2] += z; x x[3][3] += 1; } oid magCalAddx y(double x,double y,double z) { double dd = x*x+y*y+z*z; x y[0][0] += x*dd; x y[1][0] += y*dd; x y[2][0] += z*dd; x y[3][0] += 1*dd; } Usage: while(measu ing) { magCalAddx x( awx, awy, awz); magCalAddx y( awx, awy, awz); ... } MagCalCompu e(); //will also p in he esul ed 4 lines ma ices. The i s 3 pa ame e s ep esen he o se s on x, y and z. In o de o ge he esul o he compensa ion he MagCalCompu e unc ion compu es he p oduc o he 2 ma ices (x x and x y) and he i s 3 elemen s in he esul ing ma ices ep esen s he o se s and he 4 h elemen ep esen he ield s eng h. In p ac ice i has been seen ha he esul o his algo i hm, when supplied wi h measu emen s aken oo close om each o he can be eally o se -ed. This is happening because o he senso noise ha is e y big is espec o he possible dis ances be ween 2 measu emen s. In o de o sol e his p oblem he usage o an addi ional gy oscope can be used o sca e he aken measu emen s in a con enien way while he calib a ion mo emen is aking place. Ano he bene i o using a second senso as a gy oscope is he possibili y o gi e he ope a o a eedback consis ing on ac ions ha has o be aken. This way, by in eg a ing he o a ion speeds on he axis ha is been calib a ed, magne ome e measu emen s can be aken on he igh ime a e a ce ain angle o o a ion has been achie ed and he ope a o can be in o med o swi ch he axis once he calib a ion is done. By doing his a ce ain sp ead o he measu emen s and be achie ed so ha he dilu ion o p ecision gene a ed by he esolu ion o he senso and he noise o be minimum. Ano he impo an hing o men ion is ha he gy oscope in he sys em is no an added cos only o he calib a ion o he magne ome e ; ins ead i can be used la e on, in a senso usion sys em, bo h o smoo h he compu ed heading and o de e mine he il and oll o he senso in conjunc ion wi h an accele ome e . CONCLUSIONS Two me hods o ha d i on magne ome e calib a ion ha e been p esen ed in his pape oge he wi h he au ho addi ions o he calib a ion p ocess. The i s one, la gely used because o i s simplici y is no capable o o e good esul s in all cases. The second me hod, oge he wi h he gy oscope calib a ion assis ance, can be easily in eg a ed in o a low cos MCU wi h less han 2 kB o am and s ill lea e oom o o he applica ions, since he RAM usage can be o e lapped, using he esou ces o he speci ic applica ion. I also has o be poin ed ha he second me hod isn' adding any supplemen a y cos s in senso s as an gy oscope would mo e han likely be used in he inal sys em in conjunc ion wi h o he senso s. REFERENCES 1. h p://cache. eescale.com/ iles/senso s/doc/app_no e a. /AN4399 .pd 2. h p://www- pe sonal.umich.edu/~johannb/Pape s/pape 64.pd 3. h ps://use s.soe.ucsc.edu/~elkaim/Documen s/magca l.pd