CMPS11 - Tilt Compensated Compass Module
Serial mode
Connections
![]() |
3.6v-5v |
![]() |
To use the serial mode of operation the mode pin must be connected to ground.
Communication settings
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.
Commands
Below
is a table describing commands that can be sent to the CMPS11 and the data it
will respond with.
Commands for Serial
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.