Magnetic sensor

By using the combination of the first and second magnetic body layers, magnetic sensitive elements and compensation coils in the magnetic sensor, the problem of difficulty in measuring when the magnetic field is weak is solved, and high-sensitivity magnetic field detection and closed-loop control are realized.

CN120044455APending Publication Date: 2025-05-27TDK CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510240744.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2018-03-29
Filing Date
2019-03-11
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

Existing magnetic sensors are difficult to measure effectively when the magnetic field is weak and cannot be controlled in closed loop.

Method used

A magnetic sensor is designed, and the first and second magnetic body layers are opposite to each other through a first magnetic gap, and the first magnetic sensitive element and the second magnetic sensitive element are configured, and the magnetic flux applied to the magnetic sensitive element is cancelled by a compensation coil, thereby realizing closed-loop control.

Benefits of technology

Even when the magnetic field is weak, the magnetic field can be detected with high sensitivity, and the magnetic flux can be effectively cancelled through closed-loop control, thereby improving the detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120044455A_ABST
    Figure CN120044455A_ABST
Patent Text Reader

Abstract

Provided is a magnetic sensor capable of detecting a magnetic field by closed-loop control even if the magnetic field to be measured is weak. This magnetic sensor is provided with: magnetic layers (41, 42) facing each other via a magnetic gap (G1); a magnetosensitive element (R1) disposed on a magnetic path formed by the magnetic gap (G1); and a compensation coil (60) that generates a cancellation magnetic flux ([phi] 4) that cancels the magnetic flux ([phi] 2) applied to the magnetosensitive element (R1). According to the present invention, since the magnetic flux ([phi] 2) flowing through the magnetic layers (41, 42) functioning as a yoke is applied to the magnetosensitive element (R1), detection can be performed even if the magnetic field to be measured is weak. In addition, since a compensation coil (60) that cancels out the magnetic flux ([phi] 2) is provided, closed-loop control can also be performed.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of a patent application with an application date of March 11, 2019 and an application number of 201980023034.3 and an invention title of Magnetic sensing device . Technical Field

[0002] The present invention relates to a magnetic sensor, and particularly to a magnetic sensor having a compensation coil for canceling the magnetic flux applied to a magnetosensitive element. Background Art

[0003] In magnetic sensors, there is a type of magnetic sensor that performs closed-loop control by providing a compensation coil for canceling the magnetic flux applied to a magnetosensitive element. For example, the magnetic sensor disclosed in Patent Document 1 includes: a magnetosensitive element, a magnetic shield for shielding the magnetic field to be measured, and a compensation coil disposed between the magnetic shield and the magnetosensitive element. The magnetic shield functions to attenuate the magnetic field applied to the magnetosensitive element, whereby even when the magnetic field to be measured is strong, the current flowing through the compensation coil can be suppressed to a small value.

[0004] Prior Art Documents

[0005] Patent Documents

[0006] Patent Document 1: Japanese Patent No. 5572208 Summary of the Invention

[0007] Problems to be Solved by the Invention

[0008] However, in the magnetic sensor disclosed in Patent Document 1, since the magnetic field to be measured is attenuated by the magnetic shield, there is a problem that it is difficult to measure when the magnetic field to be measured is weak.

[0009] Therefore, an object of the present invention is to provide a magnetic sensor that can detect a magnetic field by closed-loop control even when the magnetic field to be measured is weak.

[0010] Means for Solving the Problems

[0011] The magnetic sensor according to the present invention is characterized by including: first and second magnetic body layers that face each other via a first magnetic gap; a first magnetosensitive element disposed on a magnetic path formed by the first magnetic gap; and a compensation coil that cancels the magnetic flux applied to the first magnetosensitive element.

[0012] According to the present invention, since the magnetic flux flowing through the first and second magnetic body layers that function as magnetic yokes is applied to the magnetosensitive element, detection can be performed even when the magnetic field to be measured is weak. In addition, since a compensation coil for canceling the magnetic flux is provided, closed-loop control can also be performed.

[0013] In the present invention, it may be that: the first magnetic body layer is disposed at a position overlapping with the inner diameter region of the compensation coil in a plan view, and the second magnetic body layer is disposed at a position overlapping with the outer region of the compensation coil in a plan view. Thus, by passing a current through the compensation coil, a cancelling magnetic field can be generated from the first magnetic body layer to the second magnetic body layer via the first magnetic gap, or from the second magnetic body layer to the first magnetic body layer via the first magnetic gap.

[0014] The magnetic sensor according to the present invention may further include an external magnetic body layer that converges an external magnetic flux to be measured on the first magnetic body layer. Thus, the external magnetic flux can be effectively converged on the first magnetic body layer.

[0015] The magnetic sensor according to the present invention may further include: a third magnetic body layer that faces the first magnetic body layer via a second magnetic gap; and a second magnetic sensitive element that is disposed on a magnetic path formed by the second magnetic gap, and the compensation coil cancels the magnetic flux applied to the second magnetic sensitive element, and the third magnetic body layer is disposed at a position overlapping with the outer region of the compensation coil in a plan view. Thus, since magnetic fields in opposite directions are applied to the first magnetic sensitive element and the second magnetic sensitive element, higher detection sensitivity can be obtained by bridge-connecting the first magnetic sensitive element and the second magnetic sensitive element.

[0016] In the present invention, it may be that: the first to third magnetic body layers, the first and second magnetic sensitive elements, and the compensation coil are all integrated on a sensor substrate. Thus, a magnetic sensor with high detection sensitivity can be formed only by disposing an external magnetic body on the sensor substrate.

[0017] In the present invention, it may be that: the first and second magnetic sensitive elements are formed between the compensation coil and the first to third magnetic body layers in the stacking direction on the sensor substrate. Thus, the distance between the first to third magnetic body layers and the first and second magnetic sensitive elements can be shortened, and the magnetic gap formed between the external magnetic body and the first magnetic body layer can be reduced.

[0018] In the present invention, it may be that: the first to third magnetic body layers are formed between the compensation coil and the first and second magnetic sensitive elements in the stacking direction on the sensor substrate. Thus, since the distance between the first to third magnetic body layers and the first and second magnetic sensitive elements can be shortened, and the distance between the compensation coil and the first to third magnetic body layers can be shortened, the current flowing through the compensation coil can be further reduced.

[0019] In the present invention, it may be that: the compensation coil is wound over a plurality of wiring layers on the sensor substrate. Thus, the layout freedom of the conductor pattern constituting the compensation coil can be improved.

[0020] Advantages of the Invention

[0021] As described above, according to the present invention, even if the magnetic field to be measured is weak, the magnetic field can be detected with high sensitivity by closed-loop control. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a schematic top view for explaining the structure of the magnetic sensor 10 according to a preferred embodiment of the present invention.

[0023] Figure 2 is along Figure 1 a schematic cross-sectional view taken along the line A-A shown.

[0024] Figure 3 is a schematic top view for explaining the shape of the compensation coil 60.

[0025] Figure 4 is a circuit diagram for explaining the connection relationship between the terminal electrodes 51 to 56, the magnetosensitive elements R1 to R4, and the compensation coil 60.

[0026] Figure 5 is a schematic diagram for explaining the relationship between the external magnetic flux and the canceling magnetic flux.

[0027] Figure 6 is a schematic cross-sectional view showing the structure of the main part of the magnetic sensor 11 according to the first modification.

[0028] Figure 7 is a schematic top view for explaining the shape of the compensation coil 60 composed of the lower conductor pattern 60A and the upper conductor pattern 60B.

[0029] Figure 8 is a schematic cross-sectional view showing the structure of the main part of the magnetic sensor 12 according to the second modification.

[0030] Figure 9 is a schematic cross-sectional view showing the structure of the main part of the magnetic sensor 13 according to the third modification.

[0031] REFERENCE SIGNS

[0032] 10 to 13 Magnetic sensors

[0033] 20 Sensor substrate

[0034] 20a Element formation surface

[0035] 21 to 23 Insulating films

[0036] 31 to 33 External magnetic bodies

[0037] 41 First magnetic body layer

[0038] 42 Second magnetic body layer

[0039] 43rd Magnetic Body Layer

[0040] 51 - 56 Terminal Electrodes

[0041] 60 Compensation Coil

[0042] 60A Conductor Pattern

[0043] 60B Conductor Pattern

[0044] 60a Inner Diameter Region

[0045] 61 - 64 Conductor Patterns

[0046] 71 Differential Amplifier

[0047] 72 Detection Circuit

[0048] G1 - G4 Magnetic Gaps

[0049] M1 - M3 Main Regions

[0050] R1 - R4 Magnetosensitive Elements

[0051] S1 - S8 Beam Regions

[0052] External Magnetic Flux

[0053] Canceling Magnetic Flux Detailed Embodiment

[0054] Hereinafter, while referring to the drawings, preferred embodiments of the present invention will be described in detail.

[0055] Figure 1 is a schematic top view for explaining the structure of the magnetic sensor 10 according to the preferred embodiment of the present invention. In addition, Figure 2 is along Figure 1 the A - A line shown in the schematic cross - sectional view.

[0056] As Figure 1 and Figure 2 shown, the magnetic sensor 10 according to the present embodiment includes a sensor substrate 20 and external magnetic bodies 31 - 33. The sensor substrate 20 is a chip component having a substantially rectangular parallelepiped shape, and on its element formation surface 20a, magnetosensitive elements R1 - R4, magnetic body layers 41 - 43, terminal electrodes 51 - 56, and a compensation coil 60 are provided. The terminal electrodes 51 - 56 are connected to a circuit board (not shown) via bonding wires.

[0057] In this embodiment, the compensation coil 60, the magnetic sensing elements R1 to R4, and the magnetic layers 41 to 43 are sequentially stacked on the element forming surface 20a. The compensation coil 60 and the magnetic sensing elements R1 to R4 are separated by the insulating film 21, and the magnetic sensing elements R1 to R4 and the magnetic layers 41 to 43 are separated by the insulating film 22.

[0058] The external magnetic bodies 31 to 33 are blocks made of soft magnetic materials with high magnetic permeability such as ferrite. The external magnetic body 31 is arranged at the approximate center of the element forming surface 20a and has a shape protruding in the z direction. In contrast, the external magnetic bodies 32 and 33 are arranged on both sides of the sensor substrate 20 in the x direction, and their top ends are bent into an L shape and cover the element forming surface 20a.

[0059] The first to third magnetic layers 41 to 43 are formed on the insulating film 22 of the sensor substrate 20. The first magnetic layer 41 is located substantially in the center of the element forming surface 20a, and the second and third magnetic layers 42 and 43 are arranged on both sides thereof in the x direction. Although not particularly limited, the magnetic layers 41 to 43 may be films made of composite magnetic materials in which magnetic fillers are dispersed in resin materials, films or foils made of soft magnetic materials such as nickel or permalloy, or films or block-shaped sheets made of ferrite or the like.

[0060] The first magnetic layer 41 includes a main region M1 located in the center and covered by the outer magnetic body 31, and focusing regions S1 to S4 whose width in the y direction becomes narrower as they move away from the main region M1 in the x direction. Figure 1 As shown, the focusing regions S1 and S3 are located on the negative side (left side) of the main region M1 in the x direction, and the focusing regions S2 and S4 are located on the positive side (right side) of the main region M1 in the x direction. The first magnetic layer 41 and the external magnetic body 31 may be in direct contact, or a thin insulating film or adhesive layer may be interposed therebetween.

[0061] On the other hand, the second magnetic layer 42 includes a main region M2 covered by the external magnetic body 32, and bunching regions S5 and S7 whose width in the y direction becomes narrower as they move away from the main region M2 in the x direction (positive side). Similarly, the third magnetic layer 43 includes a main region M3 covered by the external magnetic body 33, and bunching regions S6 and S8 whose width in the y direction becomes narrower as they move away from the main region M3 in the x direction (negative side).

[0062] The external magnetic body 31 functions to absorb the external magnetic flux in the z direction. The magnetic flux absorbed via the external magnetic body 31 is incident on the main region M1 of the first magnetic body layer 41 and is distributed substantially uniformly with respect to the focusing regions S1 to S4. The magnetic flux reaching the focusing regions S1 to S4 is respectively supplied to the focusing regions S5 to S8 via the magnetic gaps G1 to G4 extending in the y direction. The magnetic flux reaching the focusing regions S5 and S7 is recovered by the external magnetic body 32 via the main region M2. Similarly, the magnetic flux reaching the focusing regions S6 and S8 is recovered by the external magnetic body 33 via the main region M3.

[0063] As Figure 1 shown, on the magnetic paths formed by the magnetic gaps G1 to G4, magnetosensitive elements R1 to R4 with the y direction as the long side direction are respectively arranged. The magnetosensitive elements R1 to R4 can be arranged within the magnetic gaps G1 to G4, but even outside the magnetic gaps G1 to G4, it is sufficient as long as they are arranged on the magnetic paths formed by the magnetic gaps. In addition, the width direction of the magnetic gaps G1 to G4 can be the x direction, and as long as a magnetic flux component in the x direction can be applied to the magnetosensitive elements R1 to R4, the width direction of the magnetic gaps G1 to G4 can have a z direction component.

[0064] The magnetosensitive elements R1 to R4 are not particularly limited as long as their physical properties change according to the magnetic flux, but magnetoresistive elements whose resistance changes according to the direction of the magnetic field are preferred. In the present embodiment, the magnetosensitive directions (fixed magnetization directions) of the magnetosensitive elements R1 to R4 are all aligned with Figure 1 the direction shown by the arrow P (the positive side of the x direction)

[0065] According to this structure, the magnetic flux converging on the main region M1 of the first magnetic body layer 41 via the external magnetic body 31 is distributed substantially uniformly via the magnetosensitive elements R1 to R4. Therefore, magnetic fluxes in opposite directions are applied to the magnetosensitive elements R1, R3 and the magnetosensitive elements R2, R4. As described above, since the fixed magnetization directions of the magnetosensitive elements R1 to R4 point in the positive x direction shown by the arrow P, they are sensitive to the x direction component of the magnetic flux.

[0066] In addition, a compensation coil 60 is provided below the magnetosensitive elements R1 to R4. The compensation coil 60 is provided for closed-loop control by canceling the magnetic flux applied to the magnetosensitive elements R1 to R4.

[0067] Figure 3 is a schematic plan view for explaining the shape of the compensation coil 60.

[0068] As Figure 3As shown, the compensation coil 60 is formed of a conductor pattern of five turns, and has conductor patterns 61 and 62 extending in the y direction, and conductor patterns 63 and 64 extending in the x direction. In addition, one end of the compensation coil 60 is connected to the terminal electrode 51, and the other end of the compensation coil 60 is connected to the terminal electrode 52. However, the number of turns of the compensation coil 60 is not limited to this.

[0069] The positional relationship between the compensation coil 60 in the top view and the first to third magnetic body layers 41 to 43 is as Figure 1 shown. That is, the first magnetic body layer 41 is disposed at a position overlapping the inner diameter region 60a of the compensation coil 60 in the top view, and the second and third magnetic body layers 42 and 43 are disposed at positions overlapping the outer region of the compensation coil 60 in the top view. In addition, the magnetic gaps G1 and G3, and the magnetosensitive elements R1 and R3 are disposed at positions overlapping the conductor pattern 61 of the compensation coil 60 in the top view, and the magnetic gaps G2 and G4, and the magnetosensitive elements R2 and R4 are disposed at positions overlapping the conductor pattern 62 of the compensation coil 60 in the top view.

[0070] Figure 4 is a circuit diagram for explaining the connection relationship between the terminal electrodes 51 to 56, the magnetosensitive elements R1 to R4, and the compensation coil 60.

[0071] As Figure 4 shown, the magnetosensitive element R1 is connected between the terminal electrodes 53 and 56, the magnetosensitive element R2 is connected between the terminal electrodes 53 and 54, the magnetosensitive element R3 is connected between the terminal electrodes 54 and 55, and the magnetosensitive element R4 is connected between the terminal electrodes 55 and 56. A power supply potential Vcc is applied to the terminal electrode 56, and a ground potential GND is applied to the terminal electrode 54. And, since the magnetosensitive elements R1 to R4 all have the same magnetization fixed direction, a difference is generated between the resistance change amounts of the magnetosensitive elements R1 and R3 located on one side as observed from the external magnetic body 31 and the resistance change amounts of the magnetosensitive elements R2 and R4 located on the other side as observed from the external magnetic body 31. Thus, the magnetosensitive elements R1 to R4 constitute a differential bridge circuit, and the resistance changes of the magnetosensitive elements R1 to R4 according to the magnetic flux density appear at the terminal electrodes 53 and 55.

[0072] The differential signal output from the terminal electrodes 53 and 55 is input to a differential amplifier 71 provided on the mounting substrate on which the magnetic sensor 10 according to the present embodiment is mounted. The output signal of the differential amplifier 71 is fed back to the terminal electrode 52. As Figure 4As shown, a compensation coil 60 is connected between the terminal electrodes 51 and 52. Thus, the compensation coil 60 generates a cancelling magnetic field corresponding to the output signal of the differential amplifier 71. With this structure, when changes in the resistances of the magnetosensitive elements R1 to R4 due to the magnetic flux density of the external magnetic flux occur at the terminal electrodes 53 and 55, a corresponding current flows through the compensation coil 60, and a magnetic flux in the opposite direction is generated. Thereby, the external magnetic flux is cancelled. Also, when the current output from the differential amplifier 71 is subjected to current-voltage conversion by the detection circuit 72, the intensity of the external magnetic flux can be detected.

[0073] Figure 5 It is a schematic diagram for explaining the relationship between the external magnetic flux and the cancelling magnetic flux.

[0074] In Figure 5 the example shown, the external magnetic flux in the z direction is absorbed by the external magnetic body 31 and is distributed left and right via the first magnetic body layer 41. Then, the magnetic flux distributed to the left flows through the magnetic gaps G1 and G3 to the second magnetic body layer 42, and the magnetic flux distributed to the right flows through the magnetic gaps G2 and G4 to the third magnetic body layer 43. At this time, a part of the magnetic flux flowing through the magnetic gaps G1 and G3 is applied to the magnetosensitive elements R1 and R3, and a part of the magnetic flux flowing through the magnetic gaps G2 and G4 is applied to the magnetosensitive elements R2 and R4. Thus, as explained using Figure 4 a potential difference appears at the terminal electrodes 53 and 55 through the differential bridge circuit composed of the magnetosensitive elements R1 to R4.

[0075] The potential difference between the terminal electrodes 53 and 55 is fed back to the terminal electrode 52, and thus a current flows through the compensation coil 60. In Figure 5 the example shown, a cancelling magnetic flux that rotates clockwise around the center is generated in the conductor pattern 61 of the compensation coil 60 a cancelling magnetic flux that rotates counterclockwise around the center is generated in the conductor pattern 62 of the compensation coil 60 The cancelling magnetic flux flows from the second magnetic body layer 42 to the first magnetic body layer 41 via G1 and G3, thereby cancelling the external magnetic flux Similarly, the cancelling magnetic flux flows from the third magnetic body layer 43 to the first magnetic body layer 41 via the magnetic gaps G2 and G4, thereby cancelling the external magnetic flux

[0076] Since through such closed-loop control, the external magnetic flux absorbed by the external magnetic body 31 is cancelled Therefore, by monitoring the current flowing through the compensation coil 60, that is, the voltage appearing in the detection circuit 72, the external magnetic flux can be detected. The intensity of.

[0077] Moreover, in the present embodiment, since the compensation coil 60, the magnetosensitive elements R1 to R4, and the magnetic layers 41 to 43 are laminated on the sensor substrate 20 in this order, the distance in the z direction between the magnetic layers 41 to 43 and the magnetosensitive elements R1 to R4 can be shortened. As a result, since the magnetic flux passing through the magnetic gaps G1 to G4 is effectively applied to the magnetosensitive elements R1 to R4, high detection sensitivity can be obtained. In addition, since the magnetic gap formed between the external magnetic body 31 and the first magnetic layer 41 can be reduced, the external magnetic flux absorbed by the external magnetic body 31 can be effectively Supplied to the first magnetic layer 41.

[0078] As described above, since the magnetosensor 10 according to the present embodiment has the magnetosensitive elements R1 to R4 arranged on the magnetic path formed by the magnetic gaps G1 to G4, even if the magnetic field to be measured is weak, it can be detected with high sensitivity. In addition, since not only the magnetosensitive elements R1 to R4 and the magnetic layers 41 to 43 are integrated on the sensor substrate 20, but also the compensation coil 60 is integrated on the sensor substrate 20, by simply arranging the external magnetic body 31 on the sensor substrate 20, a magnetosensor with high detection sensitivity can be constituted.

[0079] Figure 6 It is a schematic cross-sectional view showing the structure of the main part of the magnetosensor 11 according to the first modification.

[0080] Figure 6 The magnetosensor 11 shown is different from the magnetosensor 10 according to the above-described embodiment in that the compensation coil 60 is wound over a plurality of wiring layers. Specifically, the compensation coil 60 is composed of a lower conductor pattern 60A and an upper conductor pattern 60B. The lower conductor pattern 60A is covered with an insulating film 21, the upper conductor pattern 60B is covered with an insulating film 22, and the magnetosensitive elements R1 to R4 are covered with an insulating film 23. As a result, the layout freedom of the conductor patterns constituting the compensation coil 60 can be improved. For example, as Figure 7 Shown, when the winding directions of the lower conductor pattern 60A and the upper conductor pattern 60B are set to be opposite to each other and their inner peripheral ends are connected to each other, the two ends of the compensation coil 60 can be easily connected to the terminal electrodes 51 and 52. In addition, in Figure 7 In the example shown, when current flows from the terminal electrode 51 to the terminal electrode 52, the current flows counterclockwise (rotates to the left), but as in Figure 3 In the example shown, it can be wound so that the current flows clockwise (rotates to the right).

[0081] Figure 8 It is a schematic cross-sectional view showing the structure of the main part of the magnetic sensor 12 according to the second modified example.

[0082] Figure 8 The shown magnetic sensor 12 is different from the magnetic sensor 11 according to the first modified example in that magnetosensitive elements R1 to R4 are laminated between the lower conductor pattern 60A and the upper conductor pattern 60B. Here, the lower conductor pattern 60A is covered with the insulating film 21, the magnetosensitive elements R1 to R4 are covered with the insulating film 22, and the upper conductor pattern 60B is covered with the insulating film 23. In this way, when the compensation coil 60 is wound over a plurality of wiring layers, a structure can be set in which the magnetosensitive elements R1 to R4 are clamped in the stacking direction by the compensation coil 60.

[0083] Figure 9 It is a schematic cross-sectional view showing the structure of the main part of the magnetic sensor 13 according to the third modified example.

[0084] Figure 9 The shown magnetic sensor 13 is different from the magnetic sensor 10 according to the above-described embodiment in that the positional relationship between the magnetosensitive elements R1 to R4 and the magnetic body layers 41 to 43 is reversed. Here, the compensation coil 60 is covered with the insulating film 21, the magnetic body layers 41 to 43 are covered with the insulating film 22, and the magnetosensitive elements R1 to R4 are covered with the insulating film 23. As a result, since the distance in the z direction between the compensation coil 60 and the magnetic body layers 41 to 43 can be shortened, the current flowing through the compensation coil 60 can be further reduced.

[0085] In the above, the preferred embodiments of the present invention have been described, but the present invention is not limited to the above-described embodiments, and various modifications can be made without departing from the gist of the present invention. Needless to say, these modifications are also included in the scope of the present invention.

Claims

1. A magnetic sensor, characterized in that, it comprises: first and second magnetic layers that face each other via a first magnetic gap; a third magnetic layer that faces the first magnetic layer via a second magnetic gap; a first magnetosensitive element disposed on a magnetic path formed by the first magnetic gap; a second magnetosensitive element disposed on a magnetic path formed by the second magnetic gap; a compensation coil that cancels out the magnetic flux applied to the first and second magnetosensitive elements; and an external magnetic body that concentrates the external magnetic flux to be measured on the first magnetic layer, wherein the first to third magnetic layers, the first and second magnetosensitive elements, and the compensation coil are all integrated on a sensor substrate.

2. The magnetic sensor according to claim 1, characterized in that, the first magnetic layer is disposed at a position that overlaps with the inner diameter region of the compensation coil in a top view, the second magnetic layer and the third magnetic layer are disposed at positions that overlap with the outer region of the compensation coil in a top view.

3. The magnetic sensor according to claim 2, characterized in that, the first and second magnetosensitive elements are formed between the compensation coil and the first to third magnetic layers in the stacking direction on the sensor substrate.

4. The magnetic sensor according to claim 3, characterized in that, the distance between the first and second magnetosensitive elements and the first to third magnetic layers is smaller than the distance between the first and second magnetosensitive elements and the compensation coil.

5. The magnetic sensor according to claim 4, characterized in that, the first and second magnetosensitive elements overlap with the compensation coil in a top view.

6. The magnetic sensor according to any one of claims 2 to 5, characterized in that, the compensation coil is wound across a plurality of wiring layers on the sensor substrate.