Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
university:courses:engineering_discovery:lab_6 [22 Jun 2016 21:06] Jonathan Pearsonuniversity:courses:engineering_discovery:lab_6 [04 Sep 2019 20:32] (current) – add alternate inductor options from kit Doug Mercer
Line 1: Line 1:
 ===== A Simple Magnetic Proximity Sensor===== ===== A Simple Magnetic Proximity Sensor=====
-{{ analogTV>VIDEO NUMBER HERE}}+{{ analogTV>5032143786001}}
  
 ==== Introduction ==== ==== Introduction ====
Line 9: Line 9:
 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. 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.
 ==== Objective ==== ==== Objective ====
-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.+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.
 ==== Materials and Apparatus ==== ==== Materials and Apparatus ====
   * Data sheet handout for the AD22151 magnetic field sensor   * Data sheet handout for the AD22151 magnetic field sensor
Line 28: Line 28:
   * (1) 0.1 μF capacitor (marked "104") from the ADALP2000 Analog Parts Kit   * (1) 0.1 μF capacitor (marked "104") from the ADALP2000 Analog Parts Kit
   * (1) 10 μF capacitor from the ADALP2000 Analog Parts Kit   * (1) 10 μF capacitor from the ADALP2000 Analog Parts Kit
-  * (1) 100 μH inductor (marked "101"from the ADALP2000 Analog Parts Kit+  * (1) inductor from the ADALP2000 Analog Parts Kit, either 100uH (marked 101), 1mH (102), 10mH (103)
 ==== Procedure ==== ==== Procedure ====
   - Construct the following electromagnet circuit on the solderless breadboard{{ university:courses:engineering_discovery:lab_6_image_1.png?400 }}   - Construct the following electromagnet circuit on the solderless breadboard{{ university:courses:engineering_discovery:lab_6_image_1.png?400 }}
-  - **Note that the 100 Ω resistors get very hot due to Joule heating, so avoid coming in contact with them**+  - **Note that the 100 Ω resistors get very hot due to Joule heating, so avoid coming in contact with them** Using 1mH or 10mH inductor will draw less current and make stronger magnetic field.
   - Refer to the illustration below for one way to install the components in the solderless breadboard{{ university:courses:engineering_discovery:lab_6_assembly_image_1.png?900 }}   - Refer to the illustration below for one way to install the components in the solderless breadboard{{ university:courses:engineering_discovery:lab_6_assembly_image_1.png?900 }}
   - Add the following Hall effect sensor circuit to the solderless breadboard{{ university:courses:engineering_discovery:lab_6_image_2.png?800 }}   - Add the following Hall effect sensor circuit to the solderless breadboard{{ university:courses:engineering_discovery:lab_6_image_2.png?800 }}
Line 38: Line 38:
   - Update M1K firmware, if necessary   - Update M1K firmware, if necessary
   - Connect the M1K to the circuit as indicated in the schematic   - Connect the M1K to the circuit as indicated in the schematic
-  - Set up PixelPulse to measure voltage on Channel A and deselect repeated sweep mode in the tools menu+  - Set up PixelPulse to measure voltage on Channel A
   - Observe and record the DC voltage on Channel A with the electromagnet far from the sensor chip and define this as V<sub>OUT,Z</sub>   - Observe and record the DC voltage on Channel A with the electromagnet far from the sensor chip and define this as V<sub>OUT,Z</sub>
   - 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; 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.   - 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; 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.
   - Refer to the following schematic for the placement of R4, but do not install any resistor here at this time{{ university:courses:engineering_discovery:lab_6_image_3.png?800 }}   - Refer to the following schematic for the placement of R4, but do not install any resistor here at this time{{ university:courses:engineering_discovery:lab_6_image_3.png?800 }}
   - Calculate the op-amp closed-loop gain   - Calculate the op-amp closed-loop gain
-  - 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 supply will actually be at about 4.8 V due to the IR drop (internal to the M1K) 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 therefore use 2.4 for the mid-supply voltage. +  - 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 supply will actually be at about 4.8 V to 4.9 V due to the IR drop (internal to the M1K) 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 V<sub>SUPPLY</sub> as the supply voltage and V<sub>MID</sub> as the mid-supply voltage. 
-  - 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 I<sub>R2</sub> Under ideal conditions this current would be zero since the voltage on each side of it would be mid-supply, but there is a small offset voltage between the internal Hall effect sensor output voltage with zero field and the internally buffered V<sub>REF</sub> For small gains this voltage can in many instances be ignored, but it must be considered in high-gain circuits such as this one.+  - Measure and record V<sub>SUPPLY</sub> using the M1K 
 +  - 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 I<sub>R2</sub> Under ideal conditions this current would be zero since the voltage on each side of it would be V<sub>MID</sub>, but there is a small offset voltage between the internal Hall effect sensor output voltage with zero field and the internally buffered V<sub>REF</sub> 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 M1K to measure and record the voltage at Pin 7 and define it as V<sub>REF</sub>   - Use the M1K to measure and record the voltage at Pin 7 and define it as V<sub>REF</sub>
   - Use the M1K to measure and record the voltage at Pin 6 and define it as V<sub>CM</sub>; 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   - Use the M1K to measure and record the voltage at Pin 6 and define it as V<sub>CM</sub>; 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
Line 54: Line 55:
   - Calculate the amount of additional current, I<sub>SHIFT</sub>, required through the feedback resistor R3 to shift V<sub>OUT,Z</sub> to 0.5 V as I<sub>SHIFT</sub> = V<sub>SHIFT</sub>/100 KΩ; note that this is a negative quantity because V<sub>SHIFT</sub> is negative   - Calculate the amount of additional current, I<sub>SHIFT</sub>, required through the feedback resistor R3 to shift V<sub>OUT,Z</sub> to 0.5 V as I<sub>SHIFT</sub> = V<sub>SHIFT</sub>/100 KΩ; note that this is a negative quantity because V<sub>SHIFT</sub> is negative
   - The current flowing into the summing node through R4, I<sub>R4</sub>, that is used to create the desired offset is in the opposite direction to that of I<sub>SHIFT</sub>, so we can write I<sub>R4</sub> = -I<sub>SHIFT</sub>, which is a positive quantity   - The current flowing into the summing node through R4, I<sub>R4</sub>, that is used to create the desired offset is in the opposite direction to that of I<sub>SHIFT</sub>, so we can write I<sub>R4</sub> = -I<sub>SHIFT</sub>, which is a positive quantity
-  - Calculate the value of R4 by noting that the voltage across R4 is the difference between the supply voltage, which we determined to be 4.8 Vand V<sub>CM</sub>, as R4 = (4.8 V - V<sub>CM</sub>)/I<sub>R4</sub>+  - Calculate the value of R4 by noting that the voltage across R4 is the difference between V<sub>SUPPLY</sub> and V<sub>CM</sub>, as R4 = (V<sub>SUPPLY</sub> - V<sub>CM</sub>)/I<sub>R4</sub>
   - 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   - 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 above   - Place R4 in the circuit as shown in the schematic above
Line 76: Line 77:
   - Can you explain why there are two different threshold voltages and how having two threshold voltages provides an advantage in this binary proximity detector?   - Can you explain why there are two different threshold voltages and how having two threshold voltages provides an advantage in this binary proximity detector?
 ==== Theory ==== ==== Theory ====
-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.+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. 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 for this) and the op-amp input common-mode voltage divided by the required injection current.+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 (V<sub>SUPPLY</sub>) and the op-amp input common-mode voltagedivided 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, A<sub>V,NI</sub>, 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 A<sub>V,NI</sub> = 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, A<sub>V,I</sub>, is the negative of the ratio of the feedback resistance to the gain resistance, or A<sub>V,I</sub> = -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, V<sub>O</sub>, due to the Hall effect sensor element output voltage, V<sub>H</sub>, is therefore simply 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, A<sub>V,NI</sub>, 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 A<sub>V,NI</sub> = 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, A<sub>V,I</sub>, is the negative of the ratio of the feedback resistance to the gain resistance, or A<sub>V,I</sub> = -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, V<sub>O</sub>, due to the Hall effect sensor element output voltage, V<sub>H</sub>, is therefore simply
Line 88: Line 89:
 The gain from V<sub>H</sub> to V<sub>O</sub> 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 A<sub>V,NI</sub> = 1 + Z<sub>F</sub>/Z<sub>G</sub> where Z<sub>F</sub> and Z<sub>G</sub> 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. The gain from V<sub>H</sub> to V<sub>O</sub> 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 A<sub>V,NI</sub> = 1 + Z<sub>F</sub>/Z<sub>G</sub> where Z<sub>F</sub> and Z<sub>G</sub> 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.+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.
  
-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 Lawthe voltage across the resistor increases with frequency in complementary fashion to that of the capacitorproducing the highpass response.  The cutoff frequency f<sub>C</sub> is defined as the frequency at which the capacitive reactance is equal to the resistance.  Setting R = 1/2πf<sub>C</sub>C and solving for f<sub>C</sub> gives the following result.+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 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 thresholdpreventing 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.  Similarlywhen 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.
  
-<m>f_C = 1/{pi RC}</m>+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
  
-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.+{{ university:courses:engineering_discovery:lab_6_image_5.png?800 }}
  
-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 ≈ 3.in the lowpass filter part of the lab should have been close to 106 Hz.+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.for the low output state Using the voltage divider rule, the high threshold is approximately 2.0 and the low threshold is approximately 1.4 V, giving about 600 mV of hysteresis.
  
-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. +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.
- +
-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 DCand 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 currentso 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 frequenciesbut 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.+
 ==== Observations and Conclusions ==== ==== Observations and Conclusions ====
-  * An electric filter is a circuit that passes certain frequencies and rejects other frequencies +  * A magnetic field can be generated using a solenoid as an electromagnet 
-  * The simplest filters consist of two elements, RC and RL +  * The Hall effect is phenomenon in which a current passing through a material in the presence of a magnetic field generates a voltage that is transverse to the direction of the current 
-  * A lowpass filter passes low frequencies and rejects high frequencies +  * Magnetic fields can be sensed using a Hall effect sensor 
-  * A highpasss filter passes high frequencies and rejects low frequencies +  * A magnetic-field-based proximity sensor can be designed using a magnetic field source and magnetic field detector 
-  * A highpass filter does not pass DC +  * A high gain is required in the Hall effect sensor to sense weak magnetic fields 
-  * RC and RL circuits can each be designed as simple lowpass or highpass filters +  * High gains can introduce undesirable effects such as high noise and DC offsets 
-  * The passband of filter is commonly defined as the band of frequencies for which the amplitude of the output signal ranges from 100% to 70.7% of the input amplitude +  * Op-amps have imperfectly matched input bias currents, input offset voltage, and input noise 
-  * The end of the passband is called the cutoff frequency, f<sub>C</sub> +  * DC offsets can be compensated for by summing an external offset voltage 
-  * A simple, low-accuracy peak detector can be constructed using a diode and a capacitor +  * Filtering can be used to reduce noise
-  * The diode drop introduces errors in the simple peak detector +
-  * A tradeoff must be made when selecting a capacitor for a peak detector -- smaller is better for high frequencies and larger is better for low frequencies+
   * A comparator is a high-gain amplifier that is often used to provide a binary output indicating whether an input signal is above or below a predetermined threshold   * A comparator is a high-gain amplifier that is often used to provide a binary output indicating whether an input signal is above or below a predetermined threshold
 +  * A comparator can be used to convert a continuously variable signal to a binary signal
   * Operational amplifiers should not be used as comparators   * Operational amplifiers should not be used as comparators
 +  * Hysteresis can be added to a comparator to prevent chattering that occurs with noisy slow-moving input signals
 +
 +**Return to [[university:courses:engineering_discovery|Engineering Discovery Index]]**
university/courses/engineering_discovery/lab_6.1466622374.txt.gz · Last modified: 22 Jun 2016 21:06 by Jonathan Pearson