You are on page 1of 9

CMPS10 - Tilt Compensated Compass Module

Introduction The CMPS10 module is a tilt compensated compass. Employing a 3-axis magnetometer and a 3-axis accelerometer and a power ul 1!-"it processor# the CMPS10 has "een designed to remo$e the errors caused "y tilting o the PC%. The CMPS10 produces a result o 0-3&'' representing 0-3&'.' or 0 to (&&. The output o the three sensors measuring x# y and ) components o the magnetic ield# together with the pitch and roll are used to calculate the "earing# each o these components are also made a$aila"le in there raw orm. *e ha$e also written examples o using the CMPS10 module with a wide range o popular controllers. The CMPS10 module re+uires a power supply at 3.3 - &$ and draws a nominal (&m, o current. There are three ways o getting the "earing rom the module. , serial inter ace# an -(C inter ace or a P*M output.

Mode selection .or data on each mode please clic/ the mode heading. 0ote the CMPS10 loo/s at the mode selection pins at power-up only. I2C mode Serial mode PWM mode

To enter the -(C mode o operation lea$e the mode pin unconnected

To enter the serial mode o operation connect the mode pin to ground

To enter the P*M mode o operation connect the select P*M pin to ground

Data update frequency 1pdates o the tilt compensated heading occur at 2&h) with the data is iltered "y means o a 3& sample "u er# this means a complete re resh o the "u er is achie$ed e$ery !30ms. 4aw data rom the magnetometer and accelerometer is a$aila"le e$ery 13.3ms. PCB Drilling Plan The ollowing diagram shows the CMPS10 PC% mounting hole positions.

*e ha$e examples o using the Compass module with a wide range o popular controllers.

CMPS10 - Tilt Compensated Compass Module


I2C mode
Connections

To enter the -(C mode o operation lea$e the mode pin unconnected I2C Communication -(C communication protocol with the compass module is the same as popular eeprom5s such as the (3C03. .irst send a start "it# the module address with the read6write "it low# then the register num"er you wish to read. This is ollowed "y a repeated start and the module address again with the read6write "it high. 7ou now read one or two "ytes or 8"it or 1!"it registers respecti$ely. 1!"it registers are read high "yte irst. The compass has a (3 "yte array o registers. organi)ed as "elow9 Regist er 0 1 (#3 3 & ! 2 8 ' 10#11 Function So tware $ersion Compass %earing as a "yte# i.e. 0-(&& or a ull circle Compass %earing as a word# i.e. 0-3&'' or a ull circle# representing 0-3&'.' degrees. Pitch angle - signed "yte gi$ing angle in degrees rom the hori)ontal plane 4oll angle - signed "yte gi$ing angle in degrees rom the hori)ontal plane 1nused 1nused 1nused 1nused Magnetometer : axis raw output# 1! "it signed integer with register 10 "eing the upper 8 "its

1(#13 Magnetometer 7 axis raw output# 1! "it signed integer with register 1( "eing the

upper 8 "its 13#1& Magnetometer ; axis raw output# 1! "it signed integer with register 13 "eing the upper 8 "its ,ccelerometer : axis raw output# 1! "it signed integer with register 1! "eing the upper 8 "its ,ccelerometer 7 axis raw output# 1! "it signed integer with register 18 "eing the upper 8 "its ,ccelerometer ; axis raw output# 1! "it signed integer with register (0 "eing the upper 8 "its Command register

1!#12

18#1'

(0#(1 ((

4egister 1 is the "earing con$erted to a 0-(&& $alue. This may "e easier or some applications than 0-3&'' which re+uires two "ytes. .or those who re+uire "etter resolution registers ( and 3 <high "yte irst= orm a 1! "it unsigned integer in the range 0-3&''. This represents 0-3&'.'>. 4egister 3 is the pitch angle# gi$ing an angle o 0 when the "oard is lat and up to ?6- 8&> at maximum tilt in either direction. 4egister & wor/s the same way "ut with results or the 4oll angle. There is then an array o registers <10-(1= pro$iding all the raw sensor data rom the magnetic and acceleration sensors. .inally 4egister (( is the command register and is used to cali"rate the compass# change address and i necessary restore the actory de ault cali"ration. Calibration t e CMPS!" - would recommend e$aluating the CMPS10 per ormance irst "e ore implementing this unction. -ts purpose is to remo$e o sets caused "y constant magnetic sources around the CMPS10. .irst o all you need to determine 0orth and align the CMPS10 with it# then enter the cali"ration mode "y writing 0x.0 to the command register <((=. To cali"rate the irst point write 0x.& to the command register# this should also light the @EA# then mo$e the o"Bect through '0> and write 0x.& to the command register. 4epeat this twice more so our points are cali"rated and the @EA should also turn o to con irm cali"ration completion. Should you need to re$ert to the actory cali"ration then write the ollowing to the command register with 100ms "etween "ytes 0x(0#0x(,#0x!0. These commands must "e sent in the correct se+uence to restore the cali"ration# additionally# 0o other command may "e issued in the middle o the se+uence. The se+uence must "e sent to the command register at location ((# which means 3 separate write transactions on the -(C "us. Please ma/e sure that the CMPS10 is not located near to errous o"Bects as this will distort the magnetic ield and induce errors in the reading. C anging t e I2C Bus #ddress To change the -(C address o the CMPS10 you must ha$e only one module on the "us. *rite the 3 se+uence commands in the correct order ollowed "y the address with 100ms "etween writes. ExampleC to change the address o a compass currently at 0xC0 <the de ault shipped address= to 0xC(# write the ollowing to address 0xC0C <0x,0# 0x,,# 0x,&# 0xC( = with a 100ms delay a ter each o the irst three "ytes. These commands must "e sent in the correct se+uence to change the -(C address# additionally# 0o other command may "e issued in the middle o the se+uence. The se+uence must "e sent to the command register at location ((# which means 3 separate write transactions on the -(C "us. *hen done# you should la"el the CMPS10 with its address# howe$er i you do orget# Bust power it up without sending any commands. The CMPS10 will lash its address out on the @EA. Dne long lash ollowed "y a num"er o shorter lashes indicating its address. The lashing is terminated immediately on sending a command the CMPS10.

,ddress Aecimal 1'( 1'3 1'! 1'8 (00 (0( (03 (0! Eex C0 C( C3 C! C8 C, CC CE

@ong .lash 1 1 1 1 1 1 1 1

Short lashes 0 1 ( 3 3 & ! 2

Ta/e care not to set more than one de$ice to the same address# there will "e a "us collision and $ery unpredicta"le results. - you need more in ormation on the -(C "us# ha$e a loo/ at our -(C tutorial.

CMPS10 - Tilt Compensated Compass Module


Serial mode
Connections

To use the serial mode o operation the mode pin must "e connected to ground. Communication settings The Serial mode operates o$er a lin/ with a de ault "aud rate o '!00 "ps <no parity# ( stop "its= and 3.3$-&$ signal le$els. This is not 4S(3(. Ao not connect 4S(3( to the module# the high 4S(3( $oltages will irre$ersi"ly damage the module. Commands %elow is a ta"le descri"ing commands that can "e sent to the CMPS10 and the data it will respond with. Commands for Serial Cmd 0ame %ytes returned 1 1 4eturned data description So tware $ersion ,ngle as a single "yte 0-(&&

0x11 FET GE4S-D0 0x1( FET ,0F@E 8 %-T FET ,0F@E 1! %-T FET P-TCE FET 4D@@ FET M,F 4,* FET ,CCE@ 4,* FET ,@@

0x13 0x13 0x1& 0x(1

( 1 1 !

,ngle as two "ytes# high "yte irst 0-3!00 Pitch angle ?6- 0-8&> 4oll angle ?6- 0-8&> 4aw magnetic data# 1! "it signed9 : high# : low# 7 high# 7 low# ; high# ; low 4aw accelerometer data# 1! "it signed9 : high# : low# 7 high# 7 low# ; high# ; low angle high# angle low <0-3!00=# pitch <?6- 0-8&=# roll <?6- 0-

0x(( 0x(3

! 3

8&= 0x31 C,@-%4,TE E01 C,@-%4,TE E0( C,@-%4,TE E03 C,@-%4,TE 4ESTD4E 1 4ESTD4E ( 4ESTD4E 3 %,1A 1'(00 %,1A 38300 1 returns o/ <0x&&=

0x3&

returns o/ <0x&&=

0x&, 0x&E 0x!, 0x2C 0x81 0x,0 0x,1

1 1 1 1 1 1 1

returns o/ <0x&&= returns o/ <0x&&= returns o/ <0x&&= returns o/ <0x&&= returns o/ <0x&&= returns o/ <0x&&= returns o/ <0x&&=

Calibration t e CMPS!" - would recommend e$aluating the CMPS10 per ormance irst "e ore implementing this unction. -ts purpose is to remo$e o sets caused "y constant magnetic sources around the CMPS10. .irst o all you need to determine 0orth and align the CMPS10 with it# then write a se+uence o 3 commands in the correct order with a small delay "etween "ytes# 100ms will "e more than ade+uate. The se+uence to enter cali"ration mode is 0x31#0x3&#0x&,# then cali"rate the irst point "y sending 0x&E to the command register# this should also light the @EA. The Compass should then "e rotated '0> and 0x&E sent to the command register again# repeat or two urther '0> rotations and the cali"ration completes and the @EA turns o . Please ma/e sure that the CMPS10 is not located near to errous o"Bects as this will distort the magnetic ield and induce errors in the reading. Restore of factory calibration of t e CMPS!" To per orm a restore o the actory cali"ration write a se+uence o 3 commands in the correct order with a small delay "etween "ytes# 100ms will "e more than ade+uate. The se+uence is 0x!,#0x2C#0x81. C anging t e baud rate *hile the CMPS10 operates at a de ault serial "us "aud rate o '!00 you may wish to change this. There are two other "aud rates that can "e used# or 1'(00 Bust send 0x,0 or alternati$ely or 38300 send 0x,1. Please note that the CMPS10 will always de ault to its '!00/"ps rate a ter power cycling and a ter setting a new "aud rate the o/ response <0x&&= will "e sent at the newly selected speed.

CMPS10 - Tilt Compensated Compass Module


PWM mode
To aid the more "asic controllers we ha$e included a P*M mode o operation. ,s the compass is rotated a high pulse will "e generated that is proportional to the current angle. The pulse width $aries rom 1mS <0> = to 3!.''mS <3&'.'> = H in other words 100uS6> with a ?1mS o set. The signal goes low or !&mS "etween pulses# so the cycle time is !&mS ? the pulse width - ie. !!ms-10(ms. Pin connections and mode selection for PWM operation

To enter the P*M mode o operation you are re+uired to connect the Select P*M pin to ground. , ter &00ms the module will enter P*M mode and output a $aria"le high pulse rom the P*M out pin dependant on the angle o the PC%. Example 19 Pulse o (0ms - 1ms o set I 1'ms I 1'0>

Example (9 Pulse o !ms - 1ms o set I &ms I &0>

Calibration -n some en$ironments it may "e necessary to per orm a cali"ration to remo$e hard iron distortion# howe$er - would recommend e$aluating the CMPS10 per ormance irst "e ore implementing the routine. To achie$e this a normally open switch must "e wired "etween the cali"rate pin and ground. The irst step is to line the compass up with north# then press the switch and the CMPS10 will light is @EA. 4otate the module "y '0> and repeat 3 urther times# the @EA should now go out and the module will "e recali"rated. Should you wish to restore the actory cali"ration then press and hold the switch or at least & seconds "e ore releasing. Please ma/e sure that the CMPS10 is not located near to errous o"Bects as this will distort the magnetic ield and induce errors in the reading.

You might also like