CMPS11 - Tilt Compensated Compass Module

Devantech Ltd CMPS11 - Tilt Compensated Compass Module
Click to enlarge
Price: £25.44
(£21.20 + VAT)
Availability: 19
Model: CMPS11
Manufacturer: Devantech Ltd
Average Rating: Not Rated

Devantech Ltd

CMPS11 - Tilt Compensated Compass Module

The CMPS11 module is a true tilt compensated compass for a fraction of the price of competing modules. Unlike similar modules which just give you the raw data, this little board incorporates a powerful 16-bit processor which performs all the complex calculations to give an output of 0 to 359.9 degrees.

Employing a 3-axis magnetometer, a 3-axis gyro and a 3-axis accelerometer. A Kalman filter combines the gyro and accelerometer to remove the errors caused by tilting of the PCB. The CMPS11 produces a result of 0-3599 representing 0-359.9 or 0 to 255. The output of the three sensors measuring x, y and z components of the magnetic field, together with the pitch and roll are used to calculate the bearing, each of these components are also made available in there raw form. The CMPS11 module requires a power supply at  3.6 - 5v and draws a nominal 25mA of current. A choice of  serial or I2C interfaces are provided.

Features

  • Tilt Compensated Compass output - 0 to 359.0 degrees
  • Supply Voltage 3.3V to 5V
  • Current - 35mA Typ.
  • Resolution - 0.1 Degree
  • Accuracy - Better than 2%. after calibration
  • Signal levels - 3.3V, 5V tolerant
  • I2C mode - up to 100khz
  • Serial mode - 9600, 19200, 38400 baud

Data update frequency

Updates of the tilt compensated heading occur at 75hz with the data filtered by means of a 45 sample buffer, this means a complete refresh of the buffer is achieved every 640ms. Raw data from the magnetometer and accelerometer is available every 13.3ms.

Mode selection

The CMPS11 looks at the mode selection pins at power-up only.

  • To enter the I2C mode of operation leave the mode pin unconnected
  • To enter the serial mode of operation connect the mode pin to ground

Tilt Compensated Compass Mode

I2C Communication

I2C communication protocol with the compass module is the same as popular eeprom's such as the 24C04. First send a start bit, the module address with the read/write bit low, then the register number you wish to read. This is followed by a repeated start and the module address again with the read/write bit high. You now read one or two bytes for 8bit or 16bit registers respectively. 16bit registers are read high byte first. The compass has a 28 byte array of registers. organized as below:

Register  Function
0 Command register (write) / Software version (read)
1 Compass Bearing 8 bit, i.e. 0-255 for a full circle
2,3 Compass Bearing 16 bit, i.e. 0-3599, representing 0-359.9 degrees. register 2 being the high byte
4 Pitch angle - signed byte giving angle in degrees from the horizontal plane, Kalman filtered with Gyro
5 Roll angle - signed byte giving angle in degrees from the horizontal plane, Kalman filtered with Gyro
6,7 Magnetometer X axis raw output, 16 bit signed integer with register 6 being the upper 8 bits
8,9 Magnetometer Y axis raw output, 16 bit signed integer with register 8 being the upper 8 bits
10,11 Magnetometer Z axis raw output, 16 bit signed integer with register 10 being the upper 8 bits
12,13 Accelerometer  X axis raw output, 16 bit signed integer with register 12 being the upper 8 bits
14,15 Accelerometer  Y axis raw output, 16 bit signed integer with register 14 being the upper 8 bits
16,17 Accelerometer  Z axis raw output, 16 bit signed integer with register 16 being the upper 8 bits
18,19 Gyro X axis raw output, 16 bit signed integer with register 18 being the upper 8 bits
20,21 Gyro  Y axis raw output, 16 bit signed integer with register 20 being the upper 8 bits
22,23 Gyro Z axis raw output, 16 bit signed integer with register 22 being the upper 8 bits
24,25 Temperature raw output, 16 bit signed integer with register 24 being the upper 8 bits
26 Pitch angle - signed byte giving angle in degrees from the horizontal plane (no Kalman filter)
27 Roll angle - signed byte giving angle in degrees from the horizontal plane (no Kalman filter)


Register 0 is a dual action register, in the event of a read the CMPS11 will reply with the software version, for a write it acts as the command register and is used to calibrate the compass, change address and if necessary restore the factory default calibration. Register 1 is the bearing converted to a 0-255 value, this may be easier for some applications than 0-3599 which requires two bytes. For those who require better resolution registers 2 and 3 (high byte first) form a 16 bit unsigned integer in the range 0-3599. This represents 0-359.9°. Register 4 is the pitch angle, giving an angle of 0 when the board is flat and up to +/- 85° at maximum tilt in either direction and also features a Kalman filter that uses the gyro sensor to reduce errors caused by unwanted acceleration effects (such as shake). Register 5 works the same way but with results for the Roll angle. There is then an array of registers (6-25) providing all the raw sensor data from the magnetic and acceleration sensors. Finally we have included the pitch and roll angle with no Kalman filter in registers 26 and 27. The raw output values in registers 6-25 are exactly what we get from the LSM9DS0 sensor chip, customers wishing to make use of these should consult the ST data sheet for further information.

Calibration of the CMPS11 

Please do not do this until you have I2C communication fully working. I would recommend evaluating the CMPS11 performance first before implementing this function. Its purpose is to remove sensor gain and offset of both magnetometer and accelerometer and achieves this by looking for maximum sensor outputs. First of all you need to enter the calibration mode by sending a 3 byte sequence of 0xF0,0xF5 and then 0xF6 to the command register, these MUST be sent in 3 separate I2C frames, you cannot send them all at once. There MUST be a minimum of 20ms between each I2C frame. An I2C frame is [start sequence] [I2C address] [register address] [command byte] [stop sequence]. The LED will then extinguish and the CMPS11 should now be rotated in all directions in 3 dimensions, if a new maximum for any of the sensors is detected then the LED will flash, when you cannot get any further LED flashes in any direction then exit the calibration mode with a command of 0xF8. Please make sure that the CMPS11 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading. While calibrating rotate the compass slowly. Remember the axis of the magnetic field is unlikely to be horizontal, it dips into the earth at an angle which varies depending on your location. At our offices in the UK it dips into the earth at 67 degrees and that is the orientation each axis of the compass needs to be to find the maximums. You need to find both positive and negative maximums for each axis so there are 6 points to calibrate. The accelerometer is also calibrated at the same time, so the module should also be positioned horizontal, inverted, and on all 4 sides to calibrate the 6 accelerometer points. Each accelerometer point needs to be stable for 200mS for its reading to be used for calibration. This delay is deliberate so that light taps to the module do not produces disruptive accelerometer readings which would mess up the pitch and roll angles. There is no delay for the magnetic points. The performance of the module is directly related to how well you perform calibration so do this slowly and carefully. 

Calibration of the CMPS11 for horizontal only operation

If the compass does not require the tilt compensation then a simple calibration may be used that can be implemented by a rotation on the horizontal plane only. First of all you need to enter the calibration mode by sending a 3 byte sequence of 0xF0,0xF5 and then 0xF7 to the command register, these MUST be sent in 3 separate I2C frames, you cannot send them all at once. There MUST be a minimum of 20ms between each I2C frame. The LED will then extinguish and the CMPS11 should now be rotated in all directions on a horizontal plane, if a new maximum for any of the sensors is detected then the LED will flash, when you cannot get any further LED flashes in any direction then exit the calibration mode with a command of 0xF8. Please make sure that the CMPS11 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading. While calibrating rotate the compass slowly. Only the X and Y magnetometer axis are calibrated in this mode.

Restoring Factory Calibration

Should you need to revert to the factory calibration then write the following to the command register in 3 separate transactions with 20ms between each transaction: 0x20,0x2A,0x60. These commands must be sent in the correct sequence to restore the calibration, additionally, No other command may be issued in the middle of the sequence. The sequence must be sent to the command register at location 0, which means 3 separate write transactions on the I2C bus. (A write transaction is [start sequence] [I2C address] [register address] [command byte] [stop sequence] then a 20mS delay).

Changing the I2C Bus Address

To change the I2C address of the CMPS11 you must have only one module on the bus. Write the 3 sequence commands in the correct order followed by the address with 100ms between writes. Example; to change the address of a compass currently at 0xC0 (the default shipped address) to 0xC2, write the following to address 0xC0; (0xA0, 0xAA, 0xA5, 0xC2 ) with a 100ms delay after each of the first three bytes. These commands must be sent in the correct sequence to change the I2C address, additionally, No other command may be issued in the middle of the sequence. The sequence must be sent to the command register at location 22, which means 4 separate write transactions on the I2C bus. When done, you should label the CMPS11 with its address, however if you do forget, just power it up without sending any commands. The CMPS11 will flash its address out on the LED, one long flash followed by a number of shorter flashes indicating its address. The flashing is terminated immediately on sending a command the CMPS11.

Address Long Flash Short flashes
Decimal Hex
192 C0 1 0
194 C2 1 1
196 C4 1 2
198 C6 1 3
200 C8 1 4
202 CA 1 5
204 CC 1 6
206 CE 1 7

Take care not to set more than one device to the same address, there will be a bus collision and very unpredictable results.

Serial Communication

The Serial mode operates over a link with a default baud rate of 9600 bps (no parity, 2 stop bits) and 3.3v-5v signal levels.
This is not RS232. Do not connect RS232 to the module, the high RS232 voltages will irreversibly damage the module.

Serial Commands

Below is a table describing commands that can be sent to the CMPS11 and the data it will respond with.

 Command 

Name

 Bytes returned  

Returned data description

0x11

GET VERSION 1 Software version

0x12

GET ANGLE 8 BIT 1 Angle as a single byte 0-255

0x13

GET ANGLE 16 BIT 2 Angle as two bytes, high byte first 0-3599

0x14

GET PITCH 1 Pitch angle +/- 0-85° Kalman filtered

0x15

GET ROLL 1 Roll angle +/- 0-85° Kalman filtered
0x16 GET PITCH NO KAL 1 Pitch angle +/- 0-85° no Kalman filter
0x17 GET ROLL NO KAL 1 Roll angle +/- 0-85° no Kalman filter

0x19

GET MAG RAW 6 Raw magnetic data, 16 bit signed: X high, X low, Y high, Y low, Z high, Z low 
0x20 GET ACCEL RAW 6  Raw accelerometer data, 16 bit signed: X high, X low, Y high, Y low, Z high, Z low 
0x21 GET GYRO RAW 6 Raw gyro data, 16 bit signed: X high, X low, Y high, Y low, Z high, Z low
0x22 GET TEMP 2 Temperature as two bytes, high byte first 0. Typical resolution 8 LSB/°C

0x23

GET ALL 4 angle high, angle low (0-3599), pitch (+/- 0-85), roll  (+/- 0-85)
0xF0 CALIBRATE BYTE 1 1 returns ok (0x55)
0xF5 CALIBRATE BYTE 2 1 returns ok (0x55)
0xF6 CALIBRATE BYTE 3 FULL 1 returns ok (0x55)
0xF7  CALIBRATE BYTE 3 FLAT   1 returns ok (0x55)
0xF8 CALIBRATE EXIT 1 returns ok (0x55)
0x6A RESTORE 1 1 returns ok (0x55)
0x7C RESTORE 2 1 returns ok (0x55)
0x81 RESTORE 3 1 returns ok (0x55)

0xA0

BAUD 19200 1 returns ok (0x55)
0xA1 BAUD 38400 1 returns ok (0x55)


Calibration of the CMPS11 

Please do not do this until you have serial communication fully working. I would recommend evaluating the CMPS11 performance first before implementing this function. Its purpose is to remove sensor gain and offset of both magnetometer and accelerometer and achieves this by looking for maximum sensor outputs. First of all you need to enter the calibration mode by sending a 3 byte sequence of 0xF0,0xF5 and then 0xF6 (reading the acknowledge byte after each one).  The LED will then extinguish and the CMPS11 should now be rotated in all directions in 3 dimensions, if a new maximum for any of the sensors is detected then the LED will flash, when you cannot get any further LED flashes in any direction then exit the calibration mode with a command of 0xF8. Please make sure that the CMPS11 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading. While calibrating rotate the compass slowly. Remember the axis of the magnetic field is unlikely to be horizontal, it dips into the earth at an angle which varies depending on your location. At our offices in the UK it dips into the earth at 67 degrees and that is the orientation each axis of the compass needs to be to find the maximums. You need to find both positive and negative maximums for each axis so there are 6 points to calibrate. The accelerometer is also calibrated at the same time, so the module should also be positioned horizontal, inverted, and on all 4 sides to calibrate the 6 accelerometer points. Each accelerometer point needs to be stable for 200mS for its reading to be used for calibration. This delay is deliberate so that light taps to the module do not produces disruptive accelerometer readings which would mess up the pitch and roll angles. There is no delay for the magnetic points. The performance of the module is directly related to how well you perform calibration so do this slowly and carefully. 

Calibration of the CMPS11 for horizontal only operation

If the compass does not require the tilt compensation then a simple calibration may be used that can be implemented by a rotation on the horizontal plane only. First of all you need to enter the calibration mode by sending a 3 byte sequence of 0xF0,0xF5 and then 0xF7 (reading the acknowledge byte after each one).  The LED will then extinguish and the CMPS11 should now be rotated in all directions on a horizontal plane, if a new maximum for any of the sensors is detected then the LED will flash, when you cannot get any further LED flashes in any direction then exit the calibration mode with a command of 0xF8. Please make sure that the CMPS11 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading. While calibrating rotate the compass slowly. Only the X and Y magnetometer axis are calibrated in this mode.

Restore of factory calibration of the CMPS11

To perform a restore of the factory calibration write a sequence of 3 commands in the correct order. The sequence is 0x6A,0x7C,0x81 (reading the acknowledge byte after each one).

Changing the baud rate

The default serial baud rate of 9600 can be changed. There are two other baud rates that can be used, for 19200 just send 0xA0 or alternatively for 38400 send 0xA1. Please note that the CMPS11 will always default to its 9600 bps rate after power cycling and after setting a new baud rate the ok response (0x55) will be sent at the newly selected speed.

Documents

Example Arduino Sketch

 

Write Review
Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad            Good

Enter the code in the box below:

CMPS11 - Tilt Compensated Compass Module
Click to enlarge
CMPS11 - Tilt Compensated Compass Module
Click to enlarge
CMPS11 - Tilt Compensated Compass Module
$ 25.44 New In Stock
Shopping Cart
0 items
 
DELIVERY/PAYMENT

Free Delivery Orders over £50

UK - £2.40 orders under £50
Airmail from £2.95 (+VAT)
More Details...

 
Brands
 
 Check out our videos