What is reason for electronic compass calibration? Most GPS receivers and smart phones contain an "electronic compass", which I understand is generally a Hall effect magnetometer. These devices generally require "calibration", which involves waving the device in an 8-shaped figure. During the motion, the forward axis is tilted about 45 degrees in each direction and the sideways axis inverted there and back, initial direction does not matter. The device does not to be put in any special mode for the calibration. This calibration is needed each time the device is turned on. Why is it needed?
The Hall effect sensor should measure magnitude of the magnetic field in given direction. So I'd expect a pair of sensors to be able to measure direction and magnitude of magnetic field in horizontal plane consistently each time and a needle compass isn't doing anything more. I can understand the other kind of calibration, turning the compass around twice slowly, as needed to compensate for magnetic bias generated by the device itself, but that's only needed once as expected (the device generates same bias each time). So what is this every-time calibration compensating for?
 A: Here is a lengthy article on the topic: http://gge.unb.ca/Resources/gpsworld.september03.pdf In a forum posting elsewhere, the author of the article states that as of 2003, the magnetic sensors in Garmin GPS units were magnetoresistive: http://www.gps-forums.net/electronic-compasses-garmin-gps-receivers-not-fluxgates-t25216.html The gpsworld article says that the ones in many cars use magnetoinductive sensors. It sounds like the advantage of magnetoresistive ones is that they're very compact. The article describes a comprehensive list of techniques for sensing a magnetic field, and this list includes fluxgate and Hall effect sensors. He doesn't say explicitly, but it sounds like Hall effect sensors are not actually used in GPS units. The only application of fluxgate sensors he mentions is in marine applications.
The section of the article on calibration describes the physics involved. If I'm understanding correctly, the basic issue is that the compass can contain ferromagnetic materials, or it can be used near ferromagnetic objects such as the frame of a bike. If these materials are ones with lots of hysteresis ("hard" iron), they can have strong permanent magnetic fields, but these fields can change over time, so they aren't really permanent in that sense -- their effect on the sensors need to be recalibrated from time to time. Since the device has sensors on multiple axes, each axis also has some scaling error that needs to be eliminated. These scaling errors can be intrinsic to the sensors, or they can be due to nearby ferromagnetic materials with low hysteresis ("soft" iron). Rotating the device in a horizontal plane allows these errors to be calibrated away, since the presence of the errors causes the B vector to trace a path that is not a circle centered on the origin.
"This calibration is needed each time the device is turned on. Why is it needed?"
The link you provided seems to confirm that the explanation is as stated in the gpsworld article; the presence of nearby ferromagnetic materials.
For comparison, my Garmin Foretrex 401 only wants to be calibrated when you put in fresh batteries. The calibration procedure it asks for is that you turn around twice slowly in a circle while holding it level. (It doesn't ask you to do a figure 8.) This is exactly as described in the gpsworld article.
A: The Hall effect acts at right angles to the applied magnetic lines of force. We want to us this effect to determine true north. But the Earth's magnetic field can be considered to consist of multiple components in different directions. So we need some way to disambiguate these so we can eliminate all but the components that guide us to north. E.g. there is a radial (vertical) component that we don't want to use.
This is why we hold the device level and move it in a figure 8: from this motion the associated logic can tell which voltage corresponds to the vertical magnetic field component because its effect will be in the horizontal plane, which we defined for the device by holding it level. After calibration, the device knows to ignore that bit when determining true north. The figure 8 thing does this similarly for certain of the other components. 
EDITED TO ADD: See this site for a video showing the figure 8 motion in three dimensions. According to the site, by waving the device through all three dimensions, the device can tell the orientation of the earth's field (since the strongest component will be the vertical). END EDIT
I think that this can vary depending on how accurate the device is and how many components it can measure. But I think you get the idea. We are giving the device inputs in a controlled fashion so that it can ignore them and focus on just the component we care about: in this case the declination.
So yes, this is an engineering answer - but it relies on at least two bits of science: 1. (physics) the Hall effect acts at right angles to the applied lines of force 2. (geological) Earth's field may be considered to have 3+ components of which the strongest is actually the vertical (radial). 
wikipedia:Dipole Model of the Earth's magnetic field
NOAA has a site that is related and kind of fun !
A: My impression was always that "calibration" had to happen to account for the angle between the magnetic vector and horizontal...  Most electronic (especially old) ones have only 2D magnetic sensors and no accelerometers - so they need to be "calibrated" in a plane to correct for these problems.  In other words, devices with 3D magnetic compasses AND 3D accelerometers (defining magnetic vector and gravity vector with 3DOF each) do not need calibration.
