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:electronics:electronics-lab-opamp-comparator [25 Oct 2018 16:26] – [Further Reading] add LTSpice files Antoniu Miclausuniversity:courses:electronics:electronics-lab-opamp-comparator [16 May 2022 15:22] (current) – [The op-amp as a "comparator":] Doug Mercer
Line 1: Line 1:
-====== Activity: Op Amp as Comparator ======+======Activity: Op Amp as Comparator, For ADALM2000======
  
 ===== Objective: ===== ===== Objective: =====
  
-In this lab we introduce the operational amplifier (op amp) in switching mode configuration, obtaining a op-amp voltage comparator behavior. The voltage comparator circuit has the purpose of highlighting via two different states of the output voltage, the relative state of the two input voltage. The comparison is made using the sign of the difference between the two input voltages, while response is one of the two possible output values, dependent on the sign of that specific difference. +In this lab we introduce the operational amplifier (op amp) in switching mode configuration, obtaining a op-amp voltage comparator behavior. The voltage comparator circuit has the purpose of highlighting via two different states of the output voltage, the relative state of the two input voltage. The comparison is made using the sign of the difference between the two input voltages, while response is one of the two possible output values, dependent on the sign of that specific difference
 + 
 +=====Background:===== 
 + 
 +====The op-amp as a "comparator":==== 
 + 
 +Consider an op-amp used to amplify a signal without feedback as shown in figure 1a. Because no feedback is used, the input signal is amplified by the full open-loop gain of the op-amp. Even a very small input voltage (less than a millivolt either side of Vth) will be enough to drive the output to either the minimum or maximum output voltage, as shown in the plots of Vin and Vout. Thus, in this case because the op-amp -Input is connected to Vth, the output represents the sign of Vin ( "0" if Vin < Vth, "1" if Vin > Vth ) 1, and the circuit is like a one-bit analog to digital converter (ADC), and functions like a voltage comparator. 
 + 
 +{{ :university:courses:alm1k:alm-lab-comp-f7.png?500 |}} 
 + 
 +<WRAP centeralign>Figure 1a, An op-amp used as a comparator</WRAP> 
 + 
 +Op Amps and comparators may seem interchangeable at first glance based on their symbols and pinouts. The Analog Parts Kits is supplied with a variety of op-amps and the AD8561 high speed voltage comparator that was used in other activities. Some designers might be tempted to use or substitute readily available op amps as voltage comparators in their projects. There are very important differences however. Comparators are designed to work without negative feedback or open-loop, they are generally designed to drive digital logic circuits from their outputs, and they are designed to work at high speed with minimal instability. Op amps are not generally designed for use as comparators, their input structures may saturate if over-driven which may cause it to respond comparatively slowly. Many have input stages which behave in unexpected ways when driven with large differential voltages or beyond the specified common mode range. In fact, in many cases, the differential input voltage range of an op amp is limited or clamped to prevent damage to the input stage devices. Note this article on "[[adi>en/analog-dialogue/articles/amplifier-input-protection-friend-or-foe.html|Amplifier Input Protection... Friend or Foe?]]" for more background on this issue. 
 + 
 +<note important>Warning: Using op-amps with built-in input clamps as a voltage comparator may damage the IC!</note> 
 + 
 +Yet many designers still try to use op amps as comparators. While this may work in some cases at low speeds and low resolutions, many times the results are not satisfactory. Not all of the issues involved with using an op amp as a comparator can be resolved by reference to the op amp datasheet, since op amps are not intended for use as comparators. 
 + 
 +The most common issues are speed (as we have already mentioned), the effects of input structures (protection diodes, phase inversion in FET amplifiers such as the ADTL082, and many others), output structures which are not intended to drive logic, hysteresis and stability, and common-mode effects.
  
 For an op-amp comparator we can consider a single input v<sub>D</sub> as the difference betwee v<sup>+</sup> and v<sup>-</sup>. Therefore, the output voltage V<sub>O</sub> can get one of the two possible values: For an op-amp comparator we can consider a single input v<sub>D</sub> as the difference betwee v<sup>+</sup> and v<sup>-</sup>. Therefore, the output voltage V<sub>O</sub> can get one of the two possible values:
Line 19: Line 37:
 ADALM2000 Active Learning Module\\ ADALM2000 Active Learning Module\\
 Solder-less breadboard, and jumper wire kit\\ Solder-less breadboard, and jumper wire kit\\
-2 1 kΩ resistor\\ +10 kΩ resistor\\
-10 kΩ resistor\\+
 1 20 kΩ resistor\\ 1 20 kΩ resistor\\
 1 OP97 ( Low slew rate amplifier supplied with the recent versions of ADALP2000 Analog Parts Kit )\\ 1 OP97 ( Low slew rate amplifier supplied with the recent versions of ADALP2000 Analog Parts Kit )\\
Line 30: Line 47:
 The high intrinsic gain of the op-amp and the output saturation effects can be exploited by configuring the op-amp as a comparator as in figure 1. This is essentially a binary-state decision-making circuit: if the voltage at the “+” terminal is greater than the voltage at the “-” terminal, Vin > Vref , the output goes “high” (saturates at its maximum value). Conversely if Vin < Vref the output goes “low”. The circuit compares the voltages at the two inputs and generates an output based on the relative values. Unlike all the previous circuits there is no feedback between the input and output; we say that the circuit is operating “open-loop”. The high intrinsic gain of the op-amp and the output saturation effects can be exploited by configuring the op-amp as a comparator as in figure 1. This is essentially a binary-state decision-making circuit: if the voltage at the “+” terminal is greater than the voltage at the “-” terminal, Vin > Vref , the output goes “high” (saturates at its maximum value). Conversely if Vin < Vref the output goes “low”. The circuit compares the voltages at the two inputs and generates an output based on the relative values. Unlike all the previous circuits there is no feedback between the input and output; we say that the circuit is operating “open-loop”.
  
-<WRAP centeralign>{{:university:courses:electronics:comp_amp-sch.png?500|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:simple_comp.png?400 |}}</WRAP> 
  
 <WRAP centeralign> Figure 1 Op-Amp as Comparator </WRAP> <WRAP centeralign> Figure 1 Op-Amp as Comparator </WRAP>
Line 40: Line 58:
 Start by shutting off the power supplies and assemble the circuit. As with the summing amplifier circuit earlier, use the second waveform generator output for the DC source Vref , and turn the amplitude to zero and the output offset all the way down so that you can adjust up from zero during the experiment. Start by shutting off the power supplies and assemble the circuit. As with the summing amplifier circuit earlier, use the second waveform generator output for the DC source Vref , and turn the amplitude to zero and the output offset all the way down so that you can adjust up from zero during the experiment.
  
-Again configure the waveform generator Vin for a 2V amplitude sine wave at 1 kHz. With the power supply on and Vref at zero volts, export the output waveform.+Again configure the waveform generator Vin for a 2V amplitude peak-to-peak sine wave at 1 kHz. With the power supply on and Vref at zero volts, export the output waveform.
  
 Now slowly increase Vref and observe what happens. Record the output waveform for Vref = 1V. Keep increasing Vref until it exceeds 2V and observe what happens. Can you explain this? Now slowly increase Vref and observe what happens. Record the output waveform for Vref = 1V. Keep increasing Vref until it exceeds 2V and observe what happens. Can you explain this?
Line 46: Line 64:
 Repeat the above for a triangular input waveform and record your observations for your lab report. Repeat the above for a triangular input waveform and record your observations for your lab report.
  
-{{:university:courses:electronics:comp_amp-bb.png|}}+{{ :university:courses:electronics:simple_comp-bb.png?900 |}}
  
 <WRAP centeralign> Figure 2. Comparator Breadboard Circuit </WRAP> <WRAP centeralign> Figure 2. Comparator Breadboard Circuit </WRAP>
Line 52: Line 70:
 === Procedure: === === Procedure: ===
  
-Use the first waveform generator as source Vin to provide a 2V amplitude, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.+Use the first waveform generator as source Vin to provide a 2V amplitude peak-to-peak, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.
  
 A plot example is presented in Figure 3. A plot example is presented in Figure 3.
Line 63: Line 81:
 ===== Hysteresis Comparator ===== ===== Hysteresis Comparator =====
  
-Hysteresis is considered to be a phenomenon according to which the actual value of a quantity (material) depends on previous values of quantities determining it. It is aproperty of a system such that an output value is not a strict function of the corresponding input, but also incorporates some lag, delay, or history dependence, and in particular the response for a decrease in the input variable is different from the response for an increase in the input variable.+Hysteresis is the dependence of a system's current state on previous values of quantities determining it. The output value is not a strict function of the corresponding input, but also incorporates some lag, delay, or history dependence. In particularthe response for a decrease in the input variable is different from the response for an increase in the input variable.
  
 In this configuration, there are two threshold values V<sub>ThH</sub> and V<sub>ThL</sub> with two output values V<sub>OH</sub> and V<sub>OL</sub>. The threshold values should depend on the output value which is fed back to the input and contributes to the threshold values (positive feedback). Via a resistive divider, a fraction of the output voltage is fed back to the non-inverting input. In this configuration, there are two threshold values V<sub>ThH</sub> and V<sub>ThL</sub> with two output values V<sub>OH</sub> and V<sub>OL</sub>. The threshold values should depend on the output value which is fed back to the input and contributes to the threshold values (positive feedback). Via a resistive divider, a fraction of the output voltage is fed back to the non-inverting input.
Line 77: Line 95:
 Consider the circuit presented in Figure 4. Consider the circuit presented in Figure 4.
  
-<WRAP centeralign>{{:university:courses:electronics:non_inv_hys_comp-sch.png?500|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:noninv_hys_comp.png?400 |}}</WRAP>
  
 <WRAP centeralign> Figure 4 Non-Inverting hysteresis comparator </WRAP> <WRAP centeralign> Figure 4 Non-Inverting hysteresis comparator </WRAP>
Line 99: Line 117:
 Build the following breadboard circuit for the non-inverting hysteresis comparator. Build the following breadboard circuit for the non-inverting hysteresis comparator.
  
-<WRAP centeralign>{{:university:courses:electronics:non_inv_hys_comp-bb.png|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:non_inv_hys_com-bb.png?900 |}}</WRAP>
  
 <WRAP centeralign> Figure 5. Non-Inverting hysteresis comparator breadboard circuit </WRAP> <WRAP centeralign> Figure 5. Non-Inverting hysteresis comparator breadboard circuit </WRAP>
Line 105: Line 123:
 === Procedure: === === Procedure: ===
  
-Use the first waveform generator as source Vin to provide a 6V amplitude, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.+Use the first waveform generator as source Vin to provide a 6V amplitude peak-to-peak, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.
  
 A plot example is presented in Figure 6. A plot example is presented in Figure 6.
Line 118: Line 136:
 <WRAP centeralign> Figure 7. Non-Inverting hysteresis comparator XY plot </WRAP> <WRAP centeralign> Figure 7. Non-Inverting hysteresis comparator XY plot </WRAP>
  
-In Figure 7. you can observe the voltage transfer charactersitic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds). Compare the computed threshold voltage values  with the measured ones.+In Figure 7. you can observe the voltage transfer charactersitic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds).
  
 ===== Inverting Hysteresis Comparator ===== ===== Inverting Hysteresis Comparator =====
Line 126: Line 144:
 Consider the circuit presented in Figure 8. Consider the circuit presented in Figure 8.
  
-<WRAP centeralign>{{:university:courses:electronics:inv_hys_comp-sch.png?500|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:inv_hys_comp.png?400 |}}</WRAP>
  
 <WRAP centeralign> Figure 8. Inverting hysteresis comparator </WRAP> <WRAP centeralign> Figure 8. Inverting hysteresis comparator </WRAP>
Line 147: Line 165:
 Build the following breadboard circuit for the inverting hysteresis comparator. Build the following breadboard circuit for the inverting hysteresis comparator.
  
-<WRAP centeralign>{{:university:courses:electronics:inv_hys_comp-bb.png|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:inv_hys_com-bb.png?900 |}}</WRAP>
  
 <WRAP centeralign> Figure 9. Inverting hysteresis comparator breadboard circuit </WRAP> <WRAP centeralign> Figure 9. Inverting hysteresis comparator breadboard circuit </WRAP>
Line 153: Line 171:
 === Procedure: === === Procedure: ===
  
-Use the first waveform generator as source Vin to provide a 6V amplitude, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.+Use the first waveform generator as source Vin to provide a 6V amplitude peak-to-peak, 1 kHz sine wave excitation to the circuit. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.
  
 A plot example is presented in Figure 10. A plot example is presented in Figure 10.
Line 166: Line 184:
 <WRAP centeralign> Figure 11. Inverting hysteresis comparator XY plot </WRAP> <WRAP centeralign> Figure 11. Inverting hysteresis comparator XY plot </WRAP>
  
-In Figure 11. you can observe the voltage transfer characteristic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds). Compare the computed threshold voltage values with the measured ones.+In Figure 11. you can observe the voltage transfer characteristic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds).
  
 ===== Inverting Hysteresis Comparator with asymmetric thresholds===== ===== Inverting Hysteresis Comparator with asymmetric thresholds=====
Line 174: Line 192:
 Consider the circuit presented in Figure 12. Consider the circuit presented in Figure 12.
  
-<WRAP centeralign>{{:university:courses:electronics:inv_hys_comp_asyth-sch.png?500|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:inv_hys_comp_asy_th.png?400 |}}</WRAP>
  
 <WRAP centeralign> Figure 12. Inverting hysteresis comparator with asymmetric thresholds </WRAP> <WRAP centeralign> Figure 12. Inverting hysteresis comparator with asymmetric thresholds </WRAP>
Line 193: Line 211:
 Build the following breadboard circuit for the inverting hysteresis comparator. Build the following breadboard circuit for the inverting hysteresis comparator.
  
-<WRAP centeralign>{{:university:courses:electronics:inv_hys_comp_asyth-bb.png|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:inv_hys_com_asyth-bb.png?900 |}}</WRAP>
  
 <WRAP centeralign> Figure 13. Inverting hysteresis comparator with asymmetric thresholds breadboard</WRAP> <WRAP centeralign> Figure 13. Inverting hysteresis comparator with asymmetric thresholds breadboard</WRAP>
Line 199: Line 217:
 === Procedure: === === Procedure: ===
  
-Use the first waveform generator as source Vin to provide a 6V amplitude, 1 kHz sine wave excitation to the circuit and second waveform generator as constant 1V voltage reference. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.+Use the first waveform generator as source Vin to provide a 6V amplitude peak-to-peak, 1 kHz sine wave excitation to the circuit and second waveform generator as constant 1V voltage reference. Supply the op amp to +/- 5V from the power supply. Configure the scope so that the input signal is displayed on channel 1 and the output signal is displayed on channel 2.
  
 A plot example is presented in Figure 14. A plot example is presented in Figure 14.
Line 212: Line 230:
 <WRAP centeralign> Figure 15. Inverting hysteresis comparator with asymmetric thresholds XY plot </WRAP> <WRAP centeralign> Figure 15. Inverting hysteresis comparator with asymmetric thresholds XY plot </WRAP>
  
-In Figure 15. you can observe the voltage transfer characteristic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds). Compare the computed threshold voltage values with the measured ones.+In Figure 15. you can observe the voltage transfer characteristic of the non-inverting hysteresis comparator (the arrows drawn indicate the flow of the signal with respect to the thresholds). 
 + 
 +===== Questions ===== 
 + 
 +  - Compute the threshold voltages for all four comparator setups (simple, non-inverting hysteresis, inverting hysteresis, asymmetric thresholds) and compare the results with the ones obtained from the experimental setups.
  
 ===== Extra Activities ===== ===== Extra Activities =====
Line 220: Line 242:
 You can also extend the above example to a circuit with multiple voltage levels as the circuit presented in Figure 16.  You can also extend the above example to a circuit with multiple voltage levels as the circuit presented in Figure 16. 
  
-<WRAP centeralign>{{:university:courses:electronics:optic_indicator_vlevel-sch.png?500|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:voltagelevelindicatorusingled.png?600 |}}</WRAP>
  
 <WRAP centeralign> Figure 16. Voltage Level Indicator using LEDs </WRAP> <WRAP centeralign> Figure 16. Voltage Level Indicator using LEDs </WRAP>
Line 242: Line 264:
 2. Build the breadboard circuit. Supply the op amp to +/- 5V from the power supply. Use the first channel of the Signal Generator to generate the variable input voltage (V<sub>in</sub>) and the second channel to generate the 5V constant reference voltage. 2. Build the breadboard circuit. Supply the op amp to +/- 5V from the power supply. Use the first channel of the Signal Generator to generate the variable input voltage (V<sub>in</sub>) and the second channel to generate the 5V constant reference voltage.
  
-<WRAP centeralign>{{:university:courses:electronics:optic_indicator_vlevel-bb.png|}}</WRAP>+<WRAP centeralign>{{ :university:courses:electronics:optic_indicator_vlevel-bb.png?900 |}}</WRAP>
  
 <WRAP centeralign> Figure 17. Voltage Level Indicator using LEDs </WRAP> <WRAP centeralign> Figure 17. Voltage Level Indicator using LEDs </WRAP>
Line 250: Line 272:
 This type of circuit is also known as Window Comparator. An an application on this subject can be found in the activity: [[university:courses:electronics:electronics-lab-window-comp-tmp01|Temperature Control using Window Comparator]] This type of circuit is also known as Window Comparator. An an application on this subject can be found in the activity: [[university:courses:electronics:electronics-lab-window-comp-tmp01|Temperature Control using Window Comparator]]
  
-==== Further Reading ==== +<WRAP round download>
 ** Lab Resources:** ** Lab Resources:**
-  * LTSpice files: [[ https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/analogdevicesinc/education_tools/tree/master/m2k/ltspice/opamp_comp_ltspice opamp_comp_ltspice]]+  * LTSpice files: [[downgit>education_tools/tree/master/m2k/ltspice/opamp_comp_ltspice | opamp_comp_ltspice]] 
 +  * Fritzing files[[downgit>education_tools/tree/master/m2k/fritzing/opamp_comp_bb opamp_comp_bb]] 
 +</WRAP> 
 + 
 +==== Further Reading ====
  
 Some additional resources on Op Amps as Comparators: Some additional resources on Op Amps as Comparators:
-  * [[http://www.analog.com/media/en/technical-documentation/application-notes/AN-849.pdf|AN-849 - Using Op Amps as Comparators]] +  * [[adi>media/en/technical-documentation/application-notes/AN-849.pdf|AN-849 - Using Op Amps as Comparators]] 
-  * [[http://www.analog.com/en/analog-dialogue/articles/amplifiers-as-comparators.html|Ask The Applications Engineer—31: Amplifiers as Comparators?]] +  * [[adi>en/analog-dialogue/articles/amplifiers-as-comparators.html|Ask The Applications Engineer—31: Amplifiers as Comparators?]] 
-  * [[http://www.analog.com/en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html|Curing Comparator Instability with Hysteresis]] +  * [[adi>en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html|Curing Comparator Instability with Hysteresis]] 
-  * [[http://www.analog.com/en/analog-dialogue/raqs/raq-issue-11.html|Comparators & Op Amps—May They Never Meet]]+  * [[adi>en/analog-dialogue/raqs/raq-issue-11.html|Comparators & Op Amps—May They Never Meet]]
  
  
 **Return to Lab Activity [[university:courses:electronics:labs|Table of Contents]]** **Return to Lab Activity [[university:courses:electronics:labs|Table of Contents]]**
  
university/courses/electronics/electronics-lab-opamp-comparator.1540477581.txt.gz · Last modified: 25 Oct 2018 16:26 by Antoniu Miclaus