Chances are that your smartphone has a compass to show you which way is North. A normal compass consists of a magnetic needle suspended on a pivot and the earth’s magnetic field aligns it towards the magnetic North Pole. Since there is no magnetic needle within the smartphone, it is a wonder how this digital compass works. Well, a modern smartphone contains a built-in electronic or semiconductor compass, also called the eCompass. Moreover, this eCompass is calibrated for the magnetic interference from the circuit board and compensated for the tilt of your smartphone.
Probably the first sensor to be incorporated into a smartphone was the accelerometer that selected between the portrait and landscape display orientation. Then came the magnetometer and this evolved into the electronic or eCompass. The electronic compass is used to align the street maps to the geographic heading of the smartphone or to overlay augmented reality. With the high-volume production and use of smartphones, sensors for accelerometer and magnetometer now cost less than $1 each.
However, just having a magnetometer sensor is not enough to provide an accurate compass heading for a smartphone. There are two reasons for this – first, the magnetic field measured with the magnetometer varies significantly with tilt, the angle at which the owner is holding the smartphone. Second, the magnetometer requires to be calibrated not only for its own offset, but also against spurious magnetic fields caused by the nearby ferromagnetic components on the circuit board.
Both the above reasons are taken care of by the accelerometer. This is usually a three-axis component operating in the +/-2-g range with at least a 10-bit resolution. Its output changes by 512 counts as the accelerometer rotates 180° from pointing upward to downward. That gives it an average sensitivity of one count for every 0.35° change in tilt. For tilt-compass purposes, this is an acceptable sensitivity figure.
The other important measurement required from an accelerometer is its 0-g offset accuracy. This is the output of the accelerometer when it is in a free fall and experiencing zero gravity. As this value is an error adding to each accelerometer channel, it adds a bias in the calculate angles of tilt.
The geomagnetic field of the earth has a magnitude of 50µT, with a horizontal component varying over the earth’s surface. It varies from a maximum of about 40µT and goes down to zero at the geomagnetic poles. Therefore, for an eCompass to operate in horizontal geomagnetic fields, for example in the arctic Canada, where the field can be as low as 10µT and an accompanying noise jitter of +/-3°, then the magnetometer required must have a maximum noise level of 0.5µT.
In a smartphone, the software uses the aerospace coordinate system, where the initial eCompass orientation has X-axis pointing North, the Y-axis pointing East and the Z-axis pointing down. The three orientation angles are defined as clockwise rotations about the x, y and z-axis. These are named roll (ø), pitch (Ɵ) and yaw (Ψ) respectively. The earth’s gravitational vector points downwards at a magnitude of 1-g or 9.81ms-2.