A simple proximity sensor senses how close one object is to another, and can 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. The magnetic field sensor output can be linear in which its output voltage is linearly related to the magnetic field strength impinging on the detector, or binary in which the output is in one state when the measured magnetic field strength is greater than a particular threshold, and in the other state when the measured magnetic field strength is less than the threshold. Binary proximity sensors are often used to replace simple position-determining mechanical switches because they have no moving parts to wear or jam, and are therefore more reliable than their mechanical counterparts.
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 coil can be wrapped around any type of core material, and the strength of the magnetic field generated inside the solenoid is proportional to the relative permeability of the core material. Magnetic field strength in the air surrounding the solenoid is less, since the relative permeability of air is approximately one. Magnetic materials such as iron, cobalt, and neodymium can have large relative permeabilities, and therefore can be used as core materials to develop large magnetic fields, and thereby realize large inductance values. Since the relative permeability of air is very close to one, air core inductors have much lower inductance values than their high-relative-permeability core counterparts. 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.
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. With the magnetic field pointing vertically with respect to the current, the Hall voltage is perpendicular to the direction of current flow with the positive side to the left of the conventional current flow. (Note that conventional current flows in the opposite direction to that of electron flow.) The Hall effect can clearly be used to measure currents with frequencies down to DC (which is not possible with magnetic-flux-based transformer current sensors) by using a sensitive voltage detector to measure the voltage across the conductor as an indication of current flow. The Hall effect can also be used to measure magnetic fields by producing a constant current in the material and measuring the Hall voltage as a function of the magnetic field. We will use a Hall effect sensor to detect the presence of a magnetic field, as well as see how to deal with some of the non-ideal behaviors in the sensor.
To study magnetic field generation and detection. To use a solenoid shaped electromagnet to generate the magnetic field and the AD22151 linear Hall-effect-based magnetic field sensor to detect the magnetic field. 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. To review bias current, offset voltage, and noise that are present in all electronic circuits. To use a comparator with hysteresis to turn the linear output of the sensor into a binary output, indicating whether or not the electromagnet has passes a particular position threshold, and illuminate a LED as an indication of the electromagnet passing through the threshold. Upon completion of this lab you should be able to describe magnetic field generation, give a basic description of the Hall effect and how it can be used to detect magnetic fields, describe bias current, input offset voltage, and noise in electronic circuits, have a basic understanding of hysteresis and at least one reason it is used, and explain the operation of a simple magnetic proximity detector.
Most magnetic-field-based proximity sensors use strong permanent magnets to generate the magnetic fields that are sensed, and therefore the sensors only require modest gains in order to output a reasonable voltage. In this lab we generate a relatively weak magnetic field using an electromagnet carrying about 150 mA, and thus require a fairly large gain in the op-amp contained in the Hall effect sensor. Having large op-amp gain introduces a few practical problems. One problem is that the output noise is large. This happens because the noise at the input to the op-amp gets multiplied along with the desired signal in the op-amp and appears at the op-amp output. Another similar problem is DC offset, in which a small offset at the input to the op-amp gets multiplied by the op-amp and appears as a DC offset in the output voltage. The op-amp has an input offset voltage, and imperfectly matched input bias currents that get converted to voltages, and these are reflected by the op-amp gain to the op-amp output voltage. Additionally, the internal Hall effect sensor output offset and internally generated and buffered reference voltage, REF, are not exactly the same. These all contribute to the output offset voltage, and are the reasons why the output voltage is not exactly at mid-supply when no magnetic field is present. We can compensate for these offsets, and even shift the output offset voltage wherever we need to (within the limits of the part) by summing in an offset voltage at the op-amp's summing node.
The summing node of the op-amp contained in the AD22151 is made available on Pin 6, and the non-inverting op-amp input is internally biased at approximately +2.5 V, so it is possible to inject positive or negative current into the summing node in order to shift the output offset level. In this case we desire to shift the output offset down, which requires an injection of current into the summing node. This can also be viewed as summing a positive voltage into an inverting op-amp summing amplifier configuration. With zero magnetic field applied, the voltage across the op-amp gain resistor R2 is ideally zero since the reference voltage VREF and the output of the Hall effect sensor would be the same -- note that the voltage on the op-amp inverting input is driven to be essentially the same as the voltage no the non-inverting input by negative feedback, so the voltage on the inverting input can be viewed as essentially the same as that of the Hall effect sensor output, neglecting the op-amp input offset voltage. The voltage that is essentially common to both op-amp inputs is referred to as the “input common-mode voltage.” There is, however, a small voltage across R2 due to the mismatch between VREF and the op-amp input common-mode voltage. Even though this is a small voltage, it is applied across a small resistance and produces an appreciable current that flows through a large-valued feedback resistor to produce an appreciable shift in output voltage. This is how op-amps work to amplify signal voltages, and why the inverting gain of an op-amp is proportional to the feedback resistance and inversely proportional to the gain resistance. We can determine the current flowing though R2 by measuring the voltage across it and dividing by its value. Most of this current flows through the feedback resistor R3, but a small amount flows into the op-amp inverting input; this small current is the input bias current, and is the reason why the current through R2 is not exactly equal to the current through R3.
Additional current can be added through the feedback resistor in order to shift the output voltage down to the lower end of its linear range of 0.5 V. The amount of current necessary for this can be calculated by taking the difference between the existing output voltage and the desired output voltage and dividing by the feedback resistance. This value of current is then injected into the op-amp summing node through an offset injection resistor R4. The value of R4 is calculated as the difference between the voltage on the input side of R4 (VSUPPLY) and the op-amp input common-mode voltage, divided by the required injection current.
The op-amp is set up as a non-inverting amplifier to the voltage that is output from the Hall effect sensor element. The gain of a non-inverting op-amp, AV,NI, is the ratio of the feedback resistance to the gain resistance plus one. In terms of the reference designators used in the lab, this is AV,NI = 1 + R3/R2. Note that VREF is also summed in an inverting fashion in order to place the output nominally at mid-supply (it is close to mid-supply for the typical small gains that are used when permanent magnets are used as the sources of the magnetic fields). The gain of an inverting op-amp, AV,I, is the negative of the ratio of the feedback resistance to the gain resistance, or AV,I = -R3/R2. The output level with no magnetic field present has been defined by the gain, circuit offsets, VREF, and the offset injection circuitry. The AD22151 output voltage, VO, due to the Hall effect sensor element output voltage, VH, is therefore simply
The gain from VH to VO is 1 + R3/R2, and in this lab is approximately equal to 427. This is a relatively high gain, which amplifies the noise from the Hall effect sensor element to a level that is visible on the PixelPulse voltage display. Placing the 0.1 μF capacitor across the feedback resistor reduces the non-inverting gain as frequency increases because the reactance of the capacitor decreases with frequency, thereby reducing the overall feedback impedance as frequency increases (the general gain formula for a non-inverting op-amp is AV,NI = 1 + ZF/ZG where ZF and ZG are the feedback and gain impedances, respectively). The feedback impedance can only approach a minimum of zero, and therefore the minimum gain of a non-inverting op-amp is equal to 1 + 0 = 1. This means that the noise from the Hall effect sensor element cannot be attenuated in the non-inverting amplifier. An inverting amplifier, on the other hand, can attenuate signals applied to its input, and is therefore a better configuration to be used in filtering applications. The capacitor across the feedback resistor therefore does help somewhat to reduce noise, but cannot reduce the op-amp gain below one. Removing the feedback capacitor eliminates the high frequency gain reduction, and allows us to see the unfiltered noise on the PixelPulse display.
Now that we have designed and built a proximity detector with a continuously variable output, we can proceed to add a one-bit quantizer, also known as a comparator, to its output to produce a binary proximity detector (the comparator was introduced in the Introduction to Filters lab). The binary proximity detector has two states -- near and not near. The demarcation point between these two states is defined by the threshold(s) used in the comparator design. A comparator is a high gain differential-input amplifier that is designed to be run open-loop, and has an output that is compatible with a particular logic family. Some comparators have single-ended outputs and some have differential outputs. We will use the AD8561 from the parts kit that has a differential output. The differential output is most often used to interface with differential logic, but in this lab we will use it to drive a LED with one output and use the other to implement hysteresis, which will be described later. Note that the LED is being driven by sourcing current in the high output state rather than sinking current in the low state, which is often more advantageous. The AD8561 outputs can source current in the high state as well as they can sink current in the low state, so this configuration was used in order to simplify the hysteresis design outlined below.
A comparator can be viewed as a one-bit analog-to-digital converter that produces one binary state on its output when its input voltage is above a particular threshold and the other state on its output when its input is below the threshold. Simple comparator designs operate by applying a fixed voltage threshold to one of the comparator inputs and applying the input signal to the other. For simplicity, we'll place the threshold on the inverting input. When the input voltage that is applied to the non-inverting input exceeds the threshold voltage on the inverting input by a small amount, the output voltage quickly moves to the high logic state. This happens because the comparator has very high gain and it does not take much voltage across its inputs (often called overdrive) to move the output voltage to either of its limits. As a simple example, applying a sine wave to a comparator with its threshold set exactly at the baseline of the sine wave produces a square wave at the comparator output. Though it may seem that a conventional op-amp could be used as a comparator, this is not recommended for a number of reasons including the fact that op-amp designs include internal compensation that is optimized for closed-loop operation, and that op-amps do not produce standard logic levels on their outputs.
When the comparator input signal is moving very slowly, noisy, or both, the output can chatter between logic levels as the input bounces above and below the threshold. This is an undesirable situation, and can be avoided using hysteresis. Hysteresis is a technique that uses two thresholds instead of one. One threshold is for an increasing input signal and the other is for a decreasing signal. When an increasing signal crosses through its threshold, the threshold immediately changes to a lower threshold, preventing the input signal from re-crossing the threshold due to noise or other fluctuations as long as the difference between the two thresholds is larger than the input fluctuations. Similarly, when a decreasing signal crosses through its threshold, the threshold immediately changes to a higher threshold. The difference between the two thresholds is defined as the hysteresis voltage. The combination of the change in comparator output state used to change the thresholds with the connection between the output and one of the inputs constitutes a form of positive feedback. The thresholds are derived from a voltage divider that is placed between the comparator output and a reference voltage. Often the reference voltage must be derived using an available supply and Thevenin equivalent voltage divider network.
Referring to the comparator circuit above, the reference voltage is generated by the Thevenin equivalent circuit comprised of the 2.5 V supply and the 2.2 KΩ and 4.7 KΩ resistors. The Thevenin equivalent of this circuit is a Thevenin voltage source of approximately 1.7 V in series with a Thevenin resistance of approximately 1.5 KΩ. We can replace the voltage divider with the Thevenin equivalent as shown
The two thresholds can be determined by calculating the voltage on Pin 3 for each of the comparator output states. We will use 3.5 V for the high output state and 0.2 V for the low output state. Using the voltage divider rule, the high threshold is approximately 2.0 V and the low threshold is approximately 1.4 V, giving about 600 mV of hysteresis.
When moving the electromagnet close to the sensor, the LED should abruptly turn on with no chatter, and abruptly turn off when the electromagnet is moved away from the sensor. The comparator output on Pin 8 can be monitored with the M1K to verify this. The thresholds can also be experimentally verified by observing the voltage on Pin 3 while moving the electromagnet close to the sensor and away from the sensor. As would be expected, the actual thresholds will deviate somewhat from the calculated values due to uncertainties in the comparator output voltages and resistor values.
Return to Engineering Discovery Index