A control device 200 calibrates a magnetic-field sensor 100 by
computation. A computation unit 210 calculates the magnetic-field
intensity based upon the outputs of X-axis, Y-axis, and Z-axis
magnetic-field detection devices of the magnetic-field sensor 100. Such
calculation is performed for four or more different points. The
calculation is performed such that at least one point is not positioned
on a plane including the other points. The computation unit 210 converts
the outputs from the X-axis, Y-axis, and Z-axis magnetic-field detection
devices of the magnetic-field sensor 100 into three-dimensional spatial
coordinate points. Then, the computation unit 210 creates a sphere on
which the four or more coordinate points thus obtained are positioned.
The coordinate point of the center of the sphere thus created represents
the magnetic-field offset. The interfering magnetic-field components in
the X-axis, Y-axis, and Z-axis directions thus obtained are subtracted
from the outputs of the X-axis, Y-axis, and Z-axis magnetic-field
detection devices of the magnetic sensor 100, whereby calibration is
made.