An angle sensor for generating a detected angle value, the detected angle value having a correspondence with an angle that a direction of a rotating magnetic field in a reference position forms with respect to a reference direction,
- the angle sensor comprising:
- a first detection unit;
- a second detection unit;
- and
- an angle detection unit, wherein
- the first detection unit includes a first and a second detection signal generation unit for generating a first and a second detection signal, respectively, each of the first and the second detection signal having a correspondence with an angle that the direction of the rotating magnetic field in a first position forms with respect to a first direction,
- the second detection unit includes a third and a fourth detection signal generation unit for generating a third and a fourth detection signal, respectively, each of the third and the fourth detection signal having a correspondence with an angle that the direction of the rotating magnetic field in a second position forms with respect to a second direction,
- when the direction of the rotating magnetic field varies with a predetermined period, each of the first to the fourth detection signal contains an ideal component and a first error component,
- the ideal component varies periodically in such a manner as to trace an ideal sinusoidal curve,
- the first error component is an error component corresponding to an n-th harmonic of the ideal component, n being 5 or more,
- the ideal components of the first and the second detection signal are different in phase from each other,
- the ideal components of the third and the fourth detection signal are different in phase from each other,
- the first detection unit and the second detection unit are arranged in a positional relationship that establishes a first phase relationship between the ideal components of the first and the third detection signal, and a second phase relationship between the ideal components of the second and the fourth detection signal,
- the first phase relationship is such a relationship that performing a first operation to obtain a sum of or difference between the first and the third detection signal yields a signal that is lower in the first error component than the first and the third detection signal,
- the second phase relationship is such a relationship that performing a second operation to obtain a sum of or difference between the second and the fourth detection signal yields a signal that is lower in the first error component than the second and the fourth detection signal, and
- the angle detection unit includes:
- a first computing circuit for generating a first signal by performing operations including the first operation, the first signal being lower in the first error component than the first and the third detection signal;
- a second computing circuit for generating a second signal by performing operations including the second operation, the second signal being lower in the first error component than the second and the fourth detection signal;
- and
- an angle computing unit for calculating the detected angle value on the basis of the first and the second signal.