This is an old revision of the document!
VIDEO NUMBER HERE
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 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 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 on the output voltage. The op-amp itself has an input offset voltage, imperfectly matched input bias currents that get converted to voltages which are reflected to the op-amp output voltage, and 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 (we used 4.8 V for this) 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.
Series RC circuits can realize the simplest lowpass and highpass filters that operate on voltages, though current-mode operation is also possible. The filter is lowpass when the output voltage is taken across the capacitor and is highpass when the output voltage is taken across the resistor. The filter operates as a two-element voltage divider between the resistance of the resistor, R, and the reactance of the capacitor, 1/2πfC. Since the capacitive reactance varies inversely with frequency, the voltage across the capacitor decreases with frequency, producing the lowpass frequency response. By Kirchhoff's Voltage Law, the voltage across the resistor increases with frequency in a complementary fashion to that of the capacitor, producing the highpass response. The cutoff frequency fC is defined as the frequency at which the capacitive reactance is equal to the resistance. Setting R = 1/2πfCC and solving for fC gives the following result.
At the cutoff frequency, the amplitude of the sinusoidal output voltage in response to a sinusoidal input voltage is equal to the reciprocal of the square-root of two times the input voltage amplitude, or about 70.7% of the input voltage amplitude.
The lowpass filter in the lab is comprised of a 68 Ω resistor and a 22 μF capacitor, and therefore has a cutoff frequency of approximately 106 Hz. Because of the tolerances of the resistor and capacitor, the actual cutoff frequency will deviate from this value. The frequency at which the peak-to-peak output amplitude was measured to drop from about 5 V to (0.707)*5 V ≈ 3.5 V in the lowpass filter part of the lab should have been close to 106 Hz.
The highpass filter in the lab is comprised of a 68 Ω resistor and a 10 μF capacitor, and therefore has a cutoff frequency of approximately 234 Hz. As with the lowpass filter, component tolerances will introduce a small cutoff frequency error. The frequency at which the peak-to-peak output amplitude was measured to drop from about 5 V to (0.707)*5 V ≈ 3.5 V in the highpass filter part of the lab should have been close to 234 Hz.
It's important to note that the resistor in the highpass filter is referenced to +2.5 V instead of ground. The highpass filter cannot pass DC, and it can therefore be viewed as a circuit the removes the DC level from its input signal. The DC level on the other side of the resistor sets the DC level on the output side of the highpasss filter as long as the output does not have a significant DC load. This is true because DC current cannot flow back through the capacitor and there is no significant load current, so the DC voltage drop across the resistor in the highpass filter is effectively zero. Placing the output DC level at 2.5 V places the output swing in the center of the M1K input range. If the resistor were referenced to ground, the highpass filter output would swing above and below ground, and the negative excursions would not be visible on the M1K.
After making basic characterizations of the filters, simple, rather inaccurate, peak detectors consisting of series diodes and shunt capacitors are added to the filter outputs in order to give a rough indication of the filter output level. The peak detector allows the capacitor to charge when the voltage out of the filter is greater than the capacitor voltage plus the forward diode drop. The diode is a nonlinear element with a varying forward voltage drop, so the capacitor will not be able to charge to the actual peak voltage out of the filter. Once the signal out of the filter passes its peak, the diode becomes reverse-biased and conducts very little current, allowing to the capacitor to hold a rough estimate of the peak level that includes the error due to the diode drop. The capacitor voltage does not stay perfectly constant while the diode is reverse biased because the diode leaks current when reverse biased, and current leaks into the M1K when the when the capacitor voltage is measured. The current leakages cause the capacitor voltage to sag during reverse-biased parts of the cycle. The sag is more noticeable for low frequency inputs when the reverse-biased times are long. This brings up an important dilemma that is encountered in all peak detectors. A small capacitor is desirable for fast charging times required in detecting the peaks of high frequency signals, but a large capacitor is required to achieve long hold times for low frequency signals. Ultimately, a compromise must be reached in selecting the capacitor value in a given application. Much more accurate peak detectors can be built using negative feedback circuits that remove the diode drop error from the measurement.
Since these peak detectors include errors, it is best to measure their outputs for various levels output from the filters. In the lab, frequencies roughly a quarter-decade apart are used to characterize the peak detectors. One of these frequencies is chosen to be approximately equal to the cutoff frequency of the respective filter -- 100 Hz for the lowpass filter and 200 Hz for the highpass filter. These peak detector output levels are used to set the threshold levels of the comparators that detect when the signals are in the filter passbands and drive the corresponding LEDs.
A comparator is a high-gain amplifier with a differential input and a binary output that is used to detect when input signals are above or below a predetermined threshold voltage. A comparator is similar to an operational amplifier that is set up in an open-loop configuration, though operational amplifiers should not be used as comparators for a number of reasons. There are many comparators on the market that are specifically designed to be operated open-loop and provide a specific type of digital logic output. Comparators can also be operated in a closed-loop positive-feedback configuration to produce hysteresis. Hysteresis is a feature in which the operation of the comparator depends on its history. It provides two thresholds -- a higher one for increasing inputs and a lower one for decreasing inputs. One of the major benefits of hysteresis is that it prevents the comparator output from “chattering” when the input signal is changing very slowly about the threshold. Hysteresis would be a nice feature in this application if the input frequencies were hovering near the filter cutoff frequencies, but it was not included for simplicity's sake.
The comparators are set up with threshold voltages on their inverting inputs. The output logic goes to a “high” level when the voltage on the non-inverting input exceeds the threshold voltage by a small amount. We want to drive the LED when the threshold is exceeded, indicating that the input signal is in the filter passband, and it is best to drive the LED when the comparator output is in the “low” logic state. The AD8561 has true and complimentary outputs. The true output goes high when the input voltage exceeds the threshold voltage is exceeded and low when the input voltage is below the threshold voltage. The complementary output beaves in the opposite fashion. Since the complementary output goes “low” when the input voltage exceeds the threshold voltage, it is used to drive the LED. If the comparator only had a true output, the same result could be achieved by swapping the input signals, i.e., placing the threshold voltage on the non-inverting input and the input signal on the inverting input.