Abstract:
Provided is a magnetic sensor device including: a switching circuit that controls switching of a terminal pair of the magnetoelectric conversion element to which a supply voltage is applied and a terminal pair to which detection voltage of a magnetic intensity is output; a differential amplifier that differentially amplifies the detection voltage; a first capacitor connected to a first output terminal of the differential amplifier; a second switch connected to a second output terminal of the differential amplifier; a comparator that has a first input terminal connected to the first capacitor and a second input terminal connected to the second switch; a first switch connected between the first input terminal and an output terminal of the comparator; and a second capacitor connected to the second input terminal of the comparator; and a detection voltage setting circuit connected to the second capacitor, in which effects of respective offset voltages of the magnetoelectric conversion element, the amplifier, and the comparator are suppressed, and an arbitrary detection magnetic field intensity is set to enable accurate magnetic reading.

Description:
RELATED APPLICATIONS 
     This application claims priority under 35 U.S.C. §119 to Japanese Patent Application No. 2009-137667 filed on Jun. 8, 2009, the entire content of which is hereby incorporated by reference. 
     BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to a magnetic sensor device for converting a magnetic field intensity into an electric signal, and more particularly to a magnetic sensor device to be employed as a sensor for detecting an open/close state used in a flip phone, a notebook computer, or the like, or a sensor for detecting a rotational position of a motor. 
     2. Description of the Related Art 
     A magnetic sensor device has been employed as a sensor for detecting the open/close state used in a flip phone, a notebook computer, or the like, or a sensor for detecting a rotational position of a motor (for example, refer to Japanese Patent Application Laid-open No. 2001-337147). A circuit diagram of the magnetic sensor device is illustrated in  FIG. 7 . 
     In the magnetic sensor device, a magnetoelectric conversion element (for example, Hall element) outputs a voltage proportional to a magnetic field intensity or a magnetic flux density, an amplifier amplifies the output voltage, and a comparator judges the voltage (outputs a binary signal of an H signal or an L signal). The output voltage of the magnetoelectric conversion element is minute, and is easily affected by an offset voltage (element offset voltage) of the magnetoelectric conversion element, an offset voltage (input offset voltage) of the amplifier or the comparator, or noise within the conversion device, which leads to a problem. The element offset voltage is mainly developed by a stress exerted on the magnetoelectric conversion element by a package. The input offset voltage is mainly developed by a characteristic variation of an element that configures an input circuit of the amplifier. The noise is mainly generated by a flicker noise of a monolithic transistor that configures a circuit, or a thermal noise of the monolithic transistor or a resistive element. 
     In order to reduce an influence of the above-mentioned offset voltage of the magnetoelectric conversion element or the amplifier, the magnetic sensor device illustrated in  FIG. 7  is configured as follows. The magnetic sensor device illustrated in  FIG. 7  is configured to include a Hall element  1 , a switching circuit  2  that switches between a first detection state and a second detection state of the Hall element  1 , a differential amplifier  3  that amplifies a voltage difference (V 1 −V 2 ) of two output terminals of the switching circuit  2 , a capacitor C 1  having one end connected to one output terminal of the differential amplifier  3 , a switch S 1  connected between the other output terminal of the differential amplifier  3  and the other end of the capacitor C 1 , and a comparator  4 . In the first detection state, a supply voltage is input from terminals A and C, and a detection voltage is output from terminals B and D. In the second detection state, the supply voltage is input from the terminals B and D, and the detection voltage is output from the terminals A and C. 
     It is assumed that a differential output voltage of the magnetoelectric conversion element is Vh, a gain of the differential amplifier is G, and the input offset voltage of the differential amplifier is Voa. In the first detection state, the switch S 1  turns on, and the capacitor C 1  is charged with Vc 1 =(V 3 −V 4 )=G(Vh 1 +Voa). Then, in the second detection state, the switch S 1  turns off, and Vc 2 =(V 3 −V 4 )=G(−Vh 2 +Voa) is output. Here, V 5 −V 6 =V 3 −Vc 1 −V 4 =Vc 2 −Vc 1 =−G(Vh 1 +Vh 2 ) is satisfied, to thereby offset the effect of the input offset voltage. Further, the detection voltages Vh 1  and Vh 2  of the magnetoelectric conversion element have an in-phase valid signal component and a reverse-phase element offset component, and hence the effect of the element offset component is also removed from the above-mentioned output voltage. 
     However, the above-mentioned magnetic sensor device according to the related art suffers from such a problem that the input offset voltage of the comparator  4  connected to a subsequent stage may not be removed, and the detected magnetic field intensity is varied. 
     SUMMARY OF THE INVENTION 
     In view of the above-mentioned circumstances, an object of the present invention is to provide a magnetic sensor device which may remove effects of an element offset voltage and an input offset voltages of an amplifier and a comparator with a relatively simple circuit configuration so as to detect a magnetic field intensity with high precision. 
     In order to solve the above-mentioned problem with the related art, the magnetic sensor device according to the present invention is configured as follows. 
     According to the present invention, there is provided a magnetic sensor device including: a switching circuit that is connected with a first terminal pair and a second terminal pair of a magnetoelectric conversions element, controls switching of the terminal pair to which a supply voltage is applied and a terminal pair to which detection voltage of the magnetic intensity is output, and has a first output terminal and a second output terminal which output the detection voltage; a differential amplifier that has a first input terminal and a second input terminal connected to the first output terminal and the second output terminal of the switching circuit, respectively, and has a first output terminal and a second output terminal which output results of differentially amplifying the detection voltage; a first capacitor having one terminal connected to the first output terminal of the differential amplifier; a second switch having one terminal connected to the second output terminal of the differential amplifier; a comparator that has a first input terminal connected to another terminal of the first capacitor and a second input terminal connected to the another terminal of the second switch, and outputs a comparison result of voltages input to the first input terminal and the second input terminal to an output terminal; a first switch connected between the first input terminal and the output terminal of the comparator; a second capacitor having terminal connected to the second input terminal of the comparator; and a detection voltage setting circuit connected to another terminal of the second capacitor. 
     According to the magnetic sensor device of the present invention, the offset component generated in the magnetoelectric conversion element, the differential amplifier, and the comparator in the magnetic sensor device may be removed with a simple circuit configuration effectively utilizing the switch and the capacitor. Also, a detection voltage level of the magnetic field intensity may be set with high precision. Accordingly, the present invention may provide the magnetic sensor device capable of detecting the magnetic field intensity with high precision. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       In the accompanying drawings: 
         FIG. 1  is a circuit diagram illustrating a magnetic sensor device according to the present invention; 
         FIG. 2  is an example of a timing chart of a switch control signal in the magnetic sensor device according to the present invention; 
         FIG. 3  is another example of a timing chart of the switch control signal in the magnetic sensor device according to the present invention; 
         FIG. 4  is a circuit diagram illustrating an example of a differential amplifier in the magnetic sensor device according to the present invention; 
         FIG. 5  is a circuit diagram illustrating another example of the differential amplifier in the magnetic sensor device according to the present invention; 
         FIG. 6  is a circuit diagram illustrating an example of an analog switch in the magnetic sensor device according to the present invention; and 
         FIG. 7  is a circuit diagram illustrating a magnetic sensor device according to a related art. 
     
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     An embodiment of the present invention is described below in detail with reference to the accompanying drawings. A magnetic sensor device according to the present invention is widely used as a sensor for detecting a state of a magnetic field intensity, such as a sensor for detecting an open/close state in a flip phone or a notebook computer, or a sensor for detecting a rotational position of a motor. In the following embodiment, a magnetic sensor device using a magnetoelectric conversion element is described. A conversion device according to the present invention may employ a conversion element that similarly outputs a voltage according to acceleration or a pressure, in place of the magnetoelectric conversion element that outputs a voltage according to the magnetic field intensity. 
       FIG. 1  is a circuit diagram of the magnetic sensor device according to the present invention. The magnetic sensor device according to the present invention includes a Hall element  1  that is a magnetoelectric conversion element, a switching circuit  2 , a differential amplifier  3 , an amplifier  4 , a detection voltage setting circuit  5 , a first capacitor C 1 , a second capacitor C 2 , a first switch S 1 , and a second switch S 2 . 
     The Hall element  1  has a first terminal pair A-C and a second terminal pair B-D. The switching circuit  2  has four input terminals connected to the respective terminals A, B, C, and D of the Hall element  1 , a first output terminal, and a second output terminal. The differential amplifier  3  has a first input terminal and a second input terminal which are connected to the first output terminal and the second output terminal of the switching circuit  2 , respectively, a first output terminal, and a second output terminal. The first capacitor C 1  has one terminal connected to the first output terminal of the differential amplifier  3 . The second switch S 2  has one terminal connected to the second output terminal of the differential amplifier  3 . The comparator  4  has a first input terminal connected with the other terminal of the first capacitor C 1  and a second input terminal connected with the other terminal of the second switch S 2 , and outputs a comparison result of the voltages input to the respective input terminals to an output terminal. The first switch S 1  is connected between the first input terminal and the output terminal of the comparator  4 . The second capacitor C 2  has one terminal connected to the second input terminal of the comparator  4 . The detection voltage setting circuit  5  is connected to the other terminal of the second capacitor C 2 . The detection voltage setting circuit  5  has bleeder resistors connected between a supply terminal VDD and a ground terminal GND, and a switch circuit that connects connection points of the respective resistors and the other terminal of the second capacitor C 2 . 
     The switching circuit  2  has a function of switching between a first detection state in which the supply voltage is input to the first terminal pair A-C of the Hall element  1  while the detection voltage is output from the second terminal pair B-D of the Hall element  1 , and a second detection state in which the supply voltage is input to the second terminal pair B-D while the detection voltage is output from the first terminal pair A-C. 
     The differential amplifier  3  is configured as an instrumentation amplifier illustrated in  FIG. 4 . The differential amplifier  3  has differential amplifiers  11 ,  12 , and resistors R 11 , R 12 , R 13 . Each of the differential amplifiers  11  and  12  function as a noninverting amplifier. The differential amplifier  3  has the first input terminal connected to a noninverting input terminal of the differential amplifier  11 , the second input terminal connected to a noninverting input terminal of the differential amplifier  12 , the first output terminal connected to an output terminal of the differential amplifier  11 , and the second output terminal connected to an output terminal of the differential amplifier  12 . The differential amplifier  3  is configured as such an instrumentation amplifier, to thereby suppress the effect of in-phase noise in the differential input. In this example, it is assumed that the gains of the differential amplifiers  11  and  12  are set to be equal to each other. 
     The switches S 1  and S 2  are each formed of an analog switch as illustrated in  FIG. 6 . The analog switch includes two transmission gates connected in series between the input terminal and the output terminal. The transmission gate on the input terminal side includes an NMOS transistor M 31  and a PMOS transistor M 32 . The transmission gate on the output terminal side includes an NMOS transistor M 33  and a PMOS transistor M 34  having corresponding sources and drains short-circuited. In this example, the NMOS transistor M 33  is set to an L length which is equal to the NMOS transistor  31 , and a W length which is the half thereof. Likewise, the PMOS transistor M 34  is set to an L length which is equal to the PMOS transistor  32 , and a W length which is the half thereof. A signal φA is input to gates of the NMOS transistor M 31  and the PMOS transistor M 34 , and a signal obtained by inverting the signal φA is input to gates of the PMOS transistor M 32  and the NMOS transistor M 33 . In this example, since the analog switch illustrated in  FIG. 6  generates no noise on the output terminal side, the first switch S 1  sets the first capacitor C 1  side as the output terminal, and the second switch S 2  sets the second capacitor C 2  side as the output terminal. 
     Subsequently, the operation of the magnetic sensor device according to the present invention is described. In a first embodiment, it is assumed that the differential amplifier  3  has a configuration of  FIG. 4 , and the respective switches are driven according to a timing chart for a switch control signal of  FIG. 2 . 
     One period T in detection operation is divided into a first detection state T 1  and a second detection state T 2  according to the operation of the above-mentioned switching circuit  2 . The period T of the detection operation is also divided into a first sample phase F 1 , a second sample phase F 2 , and a comparison phase F 3  according to the open/close states of the respective switches. In the first sample phase F 1 , the offset components of the Hall element  1 , the differential amplifier  3 , and the comparator  4  are stored in the capacitors C 1  and C 2 . In the second sample phase F 2 , preparations are made for setting a detection voltage level of the magnetic field intensity. In the comparison phase F 3 , a voltage determined according to the magnetic field intensity is compared with the detection voltage level. 
     In the first sample phase F 1 , the Hall element  1  goes into the first detection state T 1 , and the switches S 1 , S 2 , and S 3  turn on. When the switch S 1  turns on, the comparator  4  operates as a voltage follower circuit. Accordingly, the capacitor C 1  is charged with a difference ΔC 1  between a voltage V 3  and a voltage V 5 .
 
Δ C 1 =V 3 −V 5  (1)
 
     In the second sample phase F 2 , the Hall element  1  goes into the second detection state T 2 , and the switch S 1  turns off. The capacitor C 1  stores ΔC 1 , and hence the voltage V 5  is represented by Expression (2).
 
 V 5 =V 3 −ΔC 1  (2)
 
     The capacitor C 2  is charged with a difference ΔC 2  between a voltage V 6  and a voltage V 8 .
 
Δ C 2 =V 6 −V 8 =V 6 −Vr 1  (3)
 
     In the comparison phase F 3 , the switches S 2  and S 3  turn off, and the switch S 4   a  turns on. As a result, because ΔC 2  is stored in the capacitor C 2 , the voltage V 6  is represented by Expression (4).
 
 V 6 =V 8 +ΔC 2 =Vr 2 +ΔC 2  (4)
 
     Finally, in the comparator  4 , the voltage V 5  represented by Expression (2) and the voltage V 6  represented by Expression (4) are compared with each other, and an H signal (VDD) or an L signal (GND) is output. 
     Next, assuming that a differential output voltage in the output terminal pair of the Hall element  1  is Vh, an in-phase voltage is Vcm (≈VDD/2), and a gain of the differential amplifier  3  is G, the transmission of a valid signal component is described. The calculation is made based on Expressions (1) to (4) described above. 
     In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Vh/ 2 ,V 2 =Vcm−Vh/ 2  (5)
 
 V 3 =Vcm+GVh/ 2 ,V 4 =Vcm−GVh/ 2  (6)
 
 V 5 =V 7 =V 6 =V 4 =Vcm−GVh/ 2  (7)
 
Δ C 1 =V 3 −V 5 =GVh   (8)
 
     In the second sample phase F 2 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm−Vh/ 2 ,V 2 =Vcm+Vh/ 2  (9)
 
 V 3 =Vcm−GVh/ 2 ,V 4 =Vcm+GVh/ 2  (10)
 
 V 5 =V 3 −ΔC 1 =Vcm− 3 GVh/ 2  (11)
 
Δ C 2 =V 6 −V 8 =Vcm+GVh/ 2 −Vr 1  (12)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 5 =Vcm− 3 GVh/ 2  (13)
 
 V 6 =Vr 2 +ΔC 2 =Vcm+GVh/ 2 +Vr 2 −Vr 1  (14)
 
 V 6 −V 5=2 GVh+Vr 2 −Vr 1  (15)
 
     Accordingly, in the comparison phase F 3 , in the comparator  4 , a signal component  2 GVh and a detection voltage component (Vr 1 −Vr 2 ) determined according to a resistance ratio of the bleeder resistors are compared with each other. 
     Then, the same calculation is conducted assuming that the element offset voltage of the Hall element  1  is Voh. In the above-mentioned calculation, because the output voltage component of the Hall element  1  is reversed in phase between the first detection state and the second detection state, the element offset component is in phase. 
     In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Voh/ 2 ,V 2 =Vcm−Voh/ 2  (16)
 
 V 3 =Vcm+GVoh/ 2 ,V 4 =Vcm−GVoh/ 2  (17)
 
 V 5 =V 7 =V 6 =V 4 =Vcm−GVoh/ 2  (18)
 
Δ C 1 =V 3 −V 5 =GVoh   (19)
 
     In the second sample phase F 2 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Voh/ 2 ,V 2 =Vcm−Voh/ 2  (20)
 
 V 3 =Vcm+GVoh/ 2 ,V 4 =Vcm−GVoh/ 2  (21)
 
 V 5 =V 3 −ΔC 1 =Vcm−GVoh/ 2  (22)
 
Δ C 2 =V 6 −V 8 =Vcm−GVoh/ 2 −Vr 1  (23)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 5 =Vcm−GVoh/ 2  (24)
 
 V 6 =Vr 2 +ΔC 2 =Vcm−GVoh/ 2 +Vr 2 −Vr 1  (25)
 
 V 6 −V 5 =Vr 2 −Vr 1  (26)
 
     Accordingly, in the comparison phase F 3 , the element offset component is removed. 
     Then, the same calculation is conducted assuming that an input offset voltage at the first input terminal of the differential amplifier  3  is Voa 1 , an input offset voltage at the second input terminal is Voa 2 , and an input offset voltage of the comparator  4  is Voa 3 . 
     In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm,V 2 =Vcm   (27)
 
 V 3 =Vcm+GVoa 1 ,V 4 =V 6 =Vcm+GVoa 2  (28)
 
 V 5 =V 7 =V 6 +Voa 3 =Vcm+GVoa 2 +Voa 3  (29)
 
Δ C 1 =V 3 −V 5 =GVoa 1 −GVoa 2 −Voa 3  (30)
 
     In the second sample phase F 2 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm,V 2 =Vcm   (31)
 
 V 3 =Vcm+GVoa 1 ,V 4 =V 6 =Vcm+GVoa 2  (32)
 
 V 5 =V 3 −ΔC 1 =Vcm+GVoa 2 +Voa 3  (33)
 
Δ C 2 =V 6 −V 8 =Vcm+GVoa 2 −Vr 1  (34)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 5 =Vcm+GVoa 2 +Voa 3  (35)
 
 V 6 =Vr 2 +ΔC 2 =Vcm+GVoa 2 +Vr 2 −Vr 1  (36)
 
     Comparison is made taking the input offset component of the comparator  4  at the time of comparison into consideration, that is, by adding Voa 3  to V 6  at the time of comparison.
 
( V 6 +Voa 3)− V 5 =Vr 2 −Vr 1  (37)
 
     Accordingly, in the comparison phase F 3 , the input offset components of the differential amplifier  3  and the comparator  4  are removed. 
     The above description is summarized as follows. As represented by Expressions (15), (26), and (37) described above, in the magnetic sensor device according to the present invention, all of the offset components generated in the Hall element  1 , the differential amplifier  3 , and the comparator  4  may be removed. Also, the detection voltage level of the magnetic field intensity may be arbitrarily set based only on the resistance ratio of the bleeder resistors. As a result, only the signal component detected by the magnetoelectric conversion element is compared with the above-mentioned detection voltage set according to the resistance ratio of the bleeder resistors, to thereby realize the detection of the magnetic field intensity with high precision. 
     The above-mentioned in-phase voltage of the Hall element  1  is set as the in-phase voltage Vcm common to the first detection state and the second detection state. However, the same effect is obtained even if the voltage is different therebetween. 
     Further, in the magnetic sensor device according to the present invention, the capacitors C 1  and C 2  are connected to the respective input terminals of the comparator  4 , and hence the effects of clock field through noise and charge injection noise generated at an instant when the respective switches connected to the input terminals are opened or closed may be suppressed. In addition, each of the switches S 1  and S 2  is formed of the analog switch illustrated in  FIG. 6 , and hence the effect of noise may be further suppressed. Accordingly, the magnetic sensor device is capable of detecting the magnetic field intensity with high precision. The analog switch illustrated in  FIG. 6  may also be used for the switches S 3 , S 4   a , and S 4   b.    
     Assuming that the differential amplifier  3  is configured as illustrated in  FIG. 5 , the operation of the magnetic sensor device according to the present invention is described below. 
     The differential amplifier  3  illustrated in  FIG. 5  includes differential amplifiers  21 ,  22  and resistors R 21 , R 22 . The differential amplifier  21  functions as a noninverting amplifier, and the differential amplifier  22  functions as a voltage follower. The differential amplifier  3  has the first input terminal connected to a noninverting input terminal of the differential amplifier  21 , the second input terminal connected to a noninverting input terminal of the differential amplifier  22 , the first output terminal connected to an output terminal of the differential amplifier  21 , and the second output terminal connected to an output terminal of the differential amplifier  22 . In this configuration, calculations represented by Expressions (5) to (37) described above are similarly conducted in a state where the valid signal component and the respective offset components are mixed together. 
     In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Vh/ 2 +Voh/ 2  (38)
 
 V 2 =Vcm−Vh/ 2 −Voh/ 2  (39)
 
 V 3 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 +G ( Vh+Voh+Voa 1 −Voa 2)  (40)
 
 V 4 =V 6 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2  (41)
 
 V 5 =V 7 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 +Voa 3  (42)
 
Δ C 1 =G ( Vh+Voh+Voa 1 −Voa 2)− Voa 3  (43)
 
     In the second sample phase F 2 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm−Vh/ 2 +Voh/ 2  (44)
 
 V 2 =Vcm+Vh/ 2 −Voh/ 2  (45)
 
 V 3 =Vcm+Vh/ 2 −Voh/ 2 +Voa 2 +G (− Vh+Voh+Voa 1 −Voa 2)  (46)
 
 V 4 =V 6 =Vcm+Vh/ 2 −Voh/ 2 +Voa 2  (47)
 
 V 5 =Vcm+Vh/ 2 −Voh/ 2−2 GVh+Voa 2 +Voa 3  (48)
 
Δ C 2 =Vcm+Vh/ 2 −Voh/ 2 +Voa 2 −Vr 1  (49)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 5 =Vcm+Vh/ 2 −Voh/ 2−2 GVh+Voa 2 +Voa 3  (50)
 
 V 6 =Vcm+Vh/ 2 −Voh/ 2 +Voa 2 +Vr 2 −Vr 1  (51)
 
     Comparison is made taking the input offset component of the comparator  4  at the time of comparison into consideration, that is, by adding the voltage Voa 3  to the voltage V 6  at the time of comparison.
 
( V 6 +Voa 3)− V 5=2 GVh+Vr 2 −Vr 1  (52)
 
     Accordingly, in the comparison phase F 3 , the signal component  2 GVh and the detection voltage component (Vr 1 −Vr 2 ) determined according to the resistance ratio of the bleeder resistors are compared with each other. That is, the same effect is obtained even when the differential amplifier  3  is configured as illustrated in  FIG. 5 . 
     The node voltages V 5  and V 6  in the comparison phase F 3  include no offset components amplified by the differential amplifier  3 , as is understood from Expressions (50) and (51). Accordingly, because no amplified offset components exist at the respective input terminals of the comparator  4  at the time of comparison, an in-phase input voltage range of the comparator  4  may be effectively utilized. This exhibits that the normal operation of the magnetic sensor device is enabled even under the environments of the lower supply voltage. 
     The above-mentioned in-phase voltage of the Hall element  1  is set as the in-phase voltage Vcm common to the first detection state and the second detection state. However, even if the in-phase voltage is different therebetween, there is no effect on the components to be compared, and the same effect is obtained. 
     Next, the operation to be performed in accordance with the switch control signals illustrated in  FIG. 3  is described below. In the timing chart illustrated in  FIG. 3 , one period T in detection operation is divided into a first sample phase F 1  and a comparison phase F 3  according to the open/close states of the respective switches. In the first sample phase F 1 , the offset components of the Hall element  1 , the differential amplifier  3 , and the comparator  4  are stored in the capacitors C 1  and C 2 . In the comparison phase F 3 , a voltage determined according to the magnetic field intensity is compared with the detection voltage level. 
     In the first sample phase F 1 , the Hall element  1  goes into the first detection state T 1 , and the switches S 1 , S 2 , and S 3  turn on. When the switch S 1  turns on, the comparator  4  operates as a voltage follower circuit. Accordingly, the capacitor C 1  is charged with the difference ΔC 1  between the voltage V 3  and the voltage V 5 .
 
Δ C 1 =V 3 −V 5  (53)
 
     The capacitor C 2  is charged with the difference ΔC 2  between the voltage V 6  and the voltage V 8 .
 
Δ C 2 =V 6− V 8= V 6 −Vr 1  (54)
 
     In the comparison phase F 3 , the Hall element  1  goes into the second detection state T 2 , and the switch S 1  turns off. The capacitor C 1  stores ΔC 1 , and hence the voltage V 5  is represented by Expression (55).
 
 V 5= V 3−Δ C 1  (55)
 
     At the same time, the switches S 2  and S 3  turn off, and the switch S 4   a  turns on. As a result, because the capacitor C 2  stores ΔC 2 , the voltage V 6  is represented by Expression (56).
 
 V 6 =V 8 +ΔC 2 =Vr 2 +ΔC 2  (56)
 
     Accordingly, in the comparator  4 , the voltage V 5  represented by Expression (55) and the voltage V 6  represented by Expression (56) are compared with each other, and an H signal (VDD) or an L signal (GND) is output. 
     Next, the signal transmission is calculated assuming that a differential output voltage in the output terminal pair of the Hall element  1  is Vh, an in-phase voltage is Vcm (≈VDD/2), an element offset voltage is Voh, a gain of the differential amplifier  3  is G, an input offset voltage at the first input terminal is Voa 1 , an input offset voltage at the second input terminal is Voa 2 , and an input offset voltage of the comparator  4  is Voa 3 . The calculation is made based on Expressions (53) to (56) described above. Because the output voltage component of the Hall element  1  is reversed in phase between the first detection state T 1  and the second detection state T 2 , the element offset component is in phase. In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Vh/ 2 +Voh/ 2  (57)
 
 V 2 =Vcm−Vh/ 2 −Voh/ 2  (58)
 
 V 3 =Vcm+G ( Vh/ 2 +Voh/ 2 +Voa 1)  (59)
 
 V 4 =V 6 =Vcm+G (− Vh/ 2 −Voh/ 2 +Voa 2)  (60)
 
 V 5 =V 7 =Vcm+G (− Vh/ 2 −Voh/ 2 +Voa 2)+ Voa 3  (61)
 
Δ C 1 =G ( Vh+Voh+Voa 1 −Voa 2)− Voa 3  (62)
 
Δ C 2 =Vcm+G (− Vh/ 2 −Voh/ 2 +Voa 2)− Vr 1  (63)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm−Vh/ 2 +Voh/ 2  (64)
 
 V 2 =Vcm+Vh/ 2 −Voh/ 2  (65)
 
 V 3 =Vcm+G (− Vh/ 2 +Voh/ 2 +Voa 1)  (66)
 
 V 5 =Vcm+G (−3 Vh/ 2 −Voh/ 2 +Voa 2)+ Voa 3  (67)
 
 V 6 =Vcm+G (− Vh/ 2 −Voh/ 2 +Voa 2)+ Vr 2 −Vr 1  (68)
 
     Comparison is made taking the input offset component of the comparator  4  at the time of comparison into consideration, that is, by adding the voltage Voa 3  to the voltage V 6  at the time of comparison.
 
( V 6 +Voa 3)− V 5 =GVh+Vr 2 −Vr 1  (69)
 
     Accordingly, in the comparison phase F 3 , the signal component GVh and the detection voltage component (Vr 1 −Vr 2 ) determined according to the resistance ratio of the bleeder resistors are compared with each other. As compared with a case of the timing chart illustrated in  FIG. 2 , there is an advantage that no second sample phase F 2  is required, despite that the valid signal component decreases by half. 
     In the calculation of Expressions (57) to (69) described above, it is assumed that the differential amplifier  3  is configured as the instrumentation amplifier illustrated in  FIG. 4 . Alternatively, the circuit configuration of  FIG. 5  may also be used. In this case, the same calculation is conducted as follows. 
     In the first sample phase F 1 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm+Vh/ 2 +Voh/ 2  (70)
 
 V 2 =Vcm−Vh/ 2 −Voh/ 2  (71)
 
 V 3 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 +G ( Vh+Voh+Voa 1 −Voa 2)  (72)
 
 V 4 =V 6 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2  (73)
 
 V 5 =V 7 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 +Voa 3  (74)
 
Δ C 1 =G ( Vh+Voh+Voa 1 −Voa 2)− Voa 3  (75)
 
Δ C 2 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 −Vr 1  (76)
 
     In the comparison phase F 3 , voltages at the respective nodes are represented as follows.
 
 V 1 =Vcm−Vh/ 2 +Voh/ 2  (77)
 
 V 2 =Vcm+Vh/ 2 −Voh/ 2  (78)
 
 V 3 =Vcm+Vh/ 2 −Voh/ 2 +Voa 2 +G (− Vh+Voh+Voa 1 −Voa 2)  (79)
 
 V 5 =Vcm+Vh/ 2 −Voh/ 2−2 GVh+Voa 2 +Voa 3  (80)
 
 V 6 =Vcm−Vh/ 2 −Voh/ 2 +Voa 2 +Vr 2 −Vr 1  (81)
 
     Comparison is made taking the input offset component of the comparator  4  at the time of comparison into consideration, that is, by adding the voltage Voa 3  to the voltage V 6  at the time of comparison.
 
( V 6 +Voa 3)− V 5=(2 G− 1) Vh+Vr 2 −Vr 1  (82)
 
     Accordingly, in the comparison phase F 3 , the signal component ( 2 G−1)Vh and the detection voltage component (Vr 1 −Vr 2 ) determined according to the resistance ratio of the bleeder resistors are compared with each other. 
     In the operation performed in accordance with the switch control signals illustrated in  FIG. 3 , the in-phase voltage of the Hall element  1  need be set as the in-phase voltage Vcm common to the first detection state and the second detection state. 
     According to the driving method of the magnetic sensor device described with reference to the timing chart illustrated in  FIG. 2  or  3 , in one detection period T, magnetic intensity for one of a south pole and a north pole is detected. Accordingly, when detecting magnetic intensity for both of the south pole and the north pole, the detection period T is repeated twice. Here, the differential detection voltage Vh output to the output terminal pair of the Hall element  1  is reversed in phase between the south pole and the north pole. In other words, the signal component input to the comparator  4  is reversed in sign between a case of detecting the south pole and a case of detecting the north pole. Accordingly, the detection voltage set by the detection voltage setting circuit  5  requires a detection voltage identical in voltage value and reverse in sign. However, when the bleeder resistors are configured to output a detection voltage whose voltage value is identical but whose sign is reversed, there is a possibility that a manufacturing variation of the resistors affects the detection voltage. 
     In view of the above circumstances, the switching circuit  2  performs control so as to switch the connection of the output terminal pair of the Hall element  1  and the input terminal of the differential amplifier  3  in the detection of the south pole and the north pole. When the switching circuit  2  thus performs control, the detection voltage set by the detection voltage setting circuit  5  requires no detection voltage reverse in sign, and hence the circuit configuration of  FIG. 1  may be employed. Accordingly, the resistor circuit may be configured by half, and the manufacturing variation of the resistor does not affect the detection voltage. 
     The detection voltage setting circuit  5  employs the switch S 4   b  so as to provide hysteresis to the detection voltage. When the magnetic field intensity set by the switch S 4   a  is detected, the switch that turns on in the comparison phase F 3  in the subsequent detection period T is changed to the switch S 4   b . Likewise, when the detection of the magnetic field intensity is canceled, the switch that turns on in the comparison phase F 3  in the subsequent detection period T is changed to the switch S 4   a . As a result, chattering at the time of detecting the magnetic field intensity and canceling the detection may be suppressed. 
     The detection voltage setting circuit  5  may include the switches S 3 , S 3   b , and S 4   a  connected in the stated order from the GND side, according to sign of the valid signal component output from the Hall element  1 . 
     Further, the magnetic sensor device according to the present invention may be used for alternation detection (for example, rotation detection of a motor). The magnetic sensor device for alternation detection is configured to switch from a state where only one polarity (for example, south pole) is detected to a state where only the other polarity (north pole) is detected upon detection of the one polarity. 
     Also, the driving method according to the timing chart of  FIG. 2  or  3 , may be changed such that a given standby period is provided between the detection period T and the subsequent detection period T so as to suppress an average current consumption of the magnetic sensor device, which produces the same effect.