This version (25 Jan 2021 08:38) was approved by Pop Andreea.The Previously approved version (14 Jan 2021 05:38) is available.Diff

Activity: Magnetic proximity sensor


The objective of this activity is to use the principles of magnetic field generation and detection to build a simple proximity detector and observe how the detector output voltage increases as the electromagnet moves closer to the sensor.


A simple proximity sensor senses how close one object is to another, and can be used for many applications ranging from simple detection of open and closed doors and windows to sophisticated high-precision absolute position detectors. They can be designed in a number of ways, one of which involves sensing the magnetic field strength generated by a magnet (often a permanent magnet, but may also be an electromagnet) contained in one of the objects and placing a magnetic field sensor in the other object. In this lab we generate the magnetic field using a ferrite-core solenoid. A solenoid is a coil of wire that is wrapped in a cylindrical fashion around a core, typically to fabricate an inductor with particular value of inductance, or an electromagnet.

The 100 μH inductor contained in the ADALP2000 Analog Parts Kit can be used to generate a magnetic field that is strong enough to be detected by the AD22151 magnetic field sensor, also contained in the Parts Kit. AD22151 is a linear magnetic field transducer. The sensor output is a voltage proportional to a magnetic field applied perpendicularly to the package top surface. The AD22151 magnetic field sensor operation is based upon the Hall effect. The Hall effect is a phenomenon in which a voltage (the Hall voltage) is developed across a material when current flows through the material with a magnetic field present. The Hall voltage is due to the electric field produced by deflection of the moving charges by the magnetic field via the Lorentz force.


ADALM2000 Active Learning Module
Solder-less breadboard, and jumper wire kit
4 100 Ω resistors
1 100 uH inductor 1 AD22151 magnetic field transducer
2 470 Ω resistors
1 100 kΩ resistor
1 0.1 uF capacitor
1 10 uF capacitor
1 200 kΩ resistor 1 LED

Hardware setup

Start with building the electromagnet circuit presented in Figure 1 on the solderless breadboard.

Figure 1. Electromagnet circuit

Add the Hall effect sensor circuit with AD22151 magnetic field transducer(Figure 2) to the solderless breadboard.

Figure 2. Hall effect sensor circuit

The breadboard connections are shown in Figure 3.

Figure 3. Magnetic proximity sensor breadboard connections


Use signal generator W1 to generate a constant 5V signal as the VCC input of the AD22151. Turn on the positive power supply V+ to 5V to power the electromanget. The output of AD22151 will be visualized on channel 1 of the oscilloscope whith the electromanget far from the chip. This voltage is ideally mid-supply, which is 2.5V on a 5.0 V supply, but it will differ from mid-supply due to DC offsets in the sensor and op-amp that get multiplied by the op-amp closed-loop gain.

Figure 4. Output offset voltage

If the electromagnet is closer to the chip the output voltage will increase proportional to the magnetic field present. In figure 5 you can see the voltage increasing when the electromagnet is close to the chip and when it is far the voltage will decrease again until it reaches the the offset voltage value.

Figure 5. Output voltage variation

The output offset voltage may be changed by adding a resistor R4 between the 5.0 V supply and the op-amp summing node on Pin 6. Our objective is to place the sensor output voltage with no applied magnetic field as close as possible to the lower end of its linear range, which is 0.5 V. We calculate the value of R4 in the next few steps. It's important to note that the 5.0 V Vcc will actually be at about 4.8 V to 4.9 V due to the IR drop that is produced by the 150 mA current that drives the electromagnet and that the resistor values are limited and have +/-5% tolerances, so the final voltage will not be perfect. We will designate Vcc as the supply voltage of the AD22151 and VMID as the mid-supply voltage.

Measure Vcc using the Voltmeter tool, on channel 2. In order to calculate R4 it is necessary to know the currents flowing in and out of the op-amp summing node. The current through R2 is defined as IR2. Under ideal conditions this current would be zero since the voltage on each side of it would be VMID, but there is a small offset voltage between the internal Hall effect sensor output voltage with zero field and the internally buffered VREF. For small gains this voltage can in many instances be ignored, but it must be considered in high-gain circuits such as this one.

Use the Voltmeter to measure and record the voltage at Pin 7 and define it as VREF. Measure and record with the voltmeter the voltage at Pin 6 and define it as VCM; this is the common-mode voltage at the op-amp input, and is driven to be very close to the output of the internal Hall effect sensor by negative feedback. Calculate the voltage across R2 as VR2 = VREF - VCM and the current through R2 as IR2 = VR2/235 Ω. The current through the feedback resistor R3 can be calculated as IR3 = (VCM - VOUT,Z)/100 KΩ Calculate the amount of voltage shift necessary to move VOUT,Z from its current level down to 0.5 V as VSHIFT = 0.5 V - VOUT,Z; note the VSHIFT is a negative quantity. The amount of additional current, ISHIFT, required through the feedback resistor R3 to shift VOUT,Z to 0.5 V as ISHIFT = VSHIFT/100 KΩ; note that this is a negative quantity because VSHIFT is negative. The current flowing into the summing node through R4, IR4, that is used to create the desired offset is in the opposite direction to that of ISHIFT, so we can write IR4 = -ISHIFT, which is a positive quantity Calculate the value of R4 by noting that the voltage across R4 is the difference between Vcc and VCM, as R4 = (Vcc - VCM)/IR4

Figure 6. Circuit with resistor R4 that changes the offset voltage

Select a resistor from the kit that is closest to this value for R4; unless the calculated value is very close to a value available in the kit, round up in order to make any error result in a higher output voltage. Place R4 in the circuit as shown in the schematic in Figure 6. Also, in Figure 8 is shown how this resistor is placed on the breadboard. Now on the channel 1 of the oscilloscope you can see the output offset voltage has dropped to the lower end of its linear range.

Figure 7. Output offset voltage lowered

Magnetic proximity sensor with LED indicator

You can use an LED as a visual indicator of proximity. The connection can be done as in Figure 8. Use an 100 Ω resistor in series with the LED to limit the current through it. You will notice that the LED light intensity increases as the electromagnet is closer to the chip.

Figure 8. Magnetic proximity sensor with LED indicator


• How will the response of the circuit change if the value of the inductor is changed?

• Why do we want to lower the output offset voltage?

Lab Resources:

Further Readings

Some additional resources:

Return to Lab Activity Table of Contents

university/courses/electronics/magnetic_proximity_sensor.txt · Last modified: 25 Jan 2021 08:37 by Pop Andreea