Patent ID: 7705584

Claim:
A magnetic sensor comprising: a magnetic movable member that moves in response to a movement of an object-being-detected; a sensor section provided opposite to the magnetic movable member through a gap and for detecting a change of magnetic field in the gap due to a movement of the magnetic movable member; a conversion circuit that converts the change in the magnetic field sensed by the sensor section into a plurality of electric signals, a relationship among the phases of the electric signals changing depending on whether a moving direction of the magnetic movable member is a first moving direction or a second moving direction; a signal forming circuit that forms a signal having at least four different levels based on the plurality of electric signals obtained through conversion by the conversion circuit, wherein a cycle in which the levels change in a predetermined order is repeated while the magnetic movable member moves in the first moving direction and a cycle in which the levels change in an order other than the predetermined order is repeated while the magnetic movable member moves in the second moving direction; and a reversal sensing circuit to which the signal formed by the signal forming section is inputted and whose output state changes in a case where, when the magnetic movable member moves in one of the first moving direction and the second moving direction, a level derived from each level among the plurality of levels in an arbitrary cycle out of the cycles differs from a level derived from said each level in a cycle immediately prior to the arbitrary cycle, wherein, based on a change in the output state of the reversal sensing circuit, it is detected that the moving direction of the magnetic movable member has changed from one of the first moving direction and the second moving direction to the other of the first moving direction and the second moving direction.