Silicon ChipCircuit Surgery - June 2023 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter: Powerful projects
  7. Feature: Technology comes in different shapes and sizes by Max the Magnificent
  8. Feature: Net Work by Alan Winstanley
  9. Project: Arduino Programmable Load by Tim Blythman
  10. Project: 500 WATTS POWER AMPLIFIER by JOHN CLARKE
  11. Project: High-Power Buck-Boost LED Driver by Tim Blythmhman
  12. Feature: CJMCU-7620 Gesture Recognition Module by Jim Rowe
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: AUDIO OUT by Jake Rothman
  17. Feature: PE hands-on product review by Julian Edgar
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the June 2023 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Circuit Surgery Regular clinic by Ian Bell Comparator circuits L ast month, based on a post by user Maddan417 on the EEWeb forum, we discussed problems with a voltage comparator circuit using the LM741 op amp. The 741 is a very old design and consequently has limited performance compared with modern devices. We looked briefly at op amp history and how to simulate the 741 in LTspice since it is not ‘built in’. We discussed some of the general disadvantages of using op amps as comparators and showed an example simulation highlighting problems with the 741’s output voltage and switching speed. However, last month we did not discuss the design of comparator circuits, so this month we will look at comparators andComparators comparatorcircuits circuit design in more detail. Comparators and op amps A comparator is a circuit that compares one analogue signal with another and outputs a binary signal based on the result of the comparison (is one input at a higher or lower voltage than the other?). In effect, it is a one-bit analogue-to-digital converter (ADC). As discussed last month, op amps can be used as comparators – essentially (at least for basic comparators) they are both very-high-gain differential-input amplifiers with responses down to DC. Therefore, for all but a very small range of input voltage differences, the output will be at the lowest or highest voltage available from the device. These two output voltages can represent Boolean 0 and 1. Op amps are optimised for use with negative feedback – often in linear circuits such as amplifiers and filters. For op amps, pushing the outputs to the extreme levels referred to as ‘saturation’ is usually avoided where possible because it tends to degrade performance in linear applications. Also, they tend to be slow in switching operation – as was demonstrated in the simulation last month. Comparators on the other hand are used open loop (no feedback), or with positive feedback, and are optimised to switch vn – vp + Vout – Vin Inverting comparator Vref Fig.1. Comparator symbol and signals. their outputs between the extremes, and to do so quickly. Comparators may have outputs configured very differently from op amps to facilitate interfacing to logic circuits. They may also have positive feedback built-in, although this is often added externally – see the discussion on hysteresis later. Vout + + Vin Vout – Non-inverting comparator Vref Comparator operation The circuit symbol for a comparator is shown in Fig.1. A comparator’s output voltage may be written mathematically as follows: ìVOH if v p > vn Vout = í îVOL if v p < vn Þ logic 1 Þ logic 0 Where vp and vn are the input voltages, as shown on Fig.1, and VOH is the logic 𝑅𝑅# 𝑅𝑅 $ V 1 (or high) and 𝑉𝑉!" = output𝑉𝑉voltage, 𝑉𝑉OL is the %&' + + 𝑅𝑅#output 𝑅𝑅$ + 𝑅𝑅# ( logic 0 (or𝑅𝑅$low) voltage. Basic comparator circuit configurations 𝑅𝑅# 𝑅𝑅$ In many 𝑉𝑉!) =applications, 𝑉𝑉%&'comparators − 𝑉𝑉(are used 𝑅𝑅 + 𝑅𝑅 𝑅𝑅 + 𝑅𝑅#a reference # to compare$an input signal$with voltage generated within the circuit. In such cases we can configure either inverting or non-inverting operation 2𝑅𝑅$ depending 𝑉𝑉" = 𝑉𝑉of − 𝑉𝑉 = 𝑉𝑉inputs is on which the comparator’s !" !) 𝑅𝑅$ + 𝑅𝑅# ( connected to the reference and the input (see Fig.2). A non-inverting comparator has a high output (logic 1) when the input is greater than the 𝑅𝑅 reference. For an inverting # 𝑉𝑉%&' comparator, 𝑅𝑅a high output is produced $ + 𝑅𝑅# when the input is below the reference. Fig.2. Inverting and non-inverting comparator configurations. Fig.3 shows the effect of finite gain and non-zero offset on a comparator’s transfer characteristic (relationship between input voltage difference and output voltage). The effect of the offset and finite gain is to reduce the resolution of the comparator, so that the difference between the inputs must be larger than a certain minimum to give reliable detection. Fig.3 represents the situation for static inputs, where the resolution is approximately VOS + VIH = VOS + VOH/gain, but typically the resolution will get worse for changing input signals. VO VOH – Practical Electronics | June | 2023 𝑉𝑉!" = 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅$ 𝑉𝑉.&' + 𝑉𝑉( 𝑅𝑅# 𝑅𝑅# vp–vn VOL Ideal comparator  Zero offset  Infinite gain VO Comparator characteristics The comparator equation above implies 𝑅𝑅# 𝑉𝑉!) = 𝑉𝑉%&' V . This infinite gain and 𝑅𝑅$ zero + 𝑅𝑅# offset, OS means that an infinitely small voltage change around the reference voltage (Vref) will cause the output to switch (infinite 𝑅𝑅# switching will 𝑅𝑅$ occur gain), and that this 𝑉𝑉*+,- = 𝑉𝑉%&' = 𝑉𝑉!" − 𝑉𝑉 exactly at the 𝑅𝑅applied reference 𝑅𝑅$ + voltage 𝑅𝑅# ( $ + 𝑅𝑅# (zero offset). + – VOL VOS VOH VIL + VIH vp–vn Real comparator  Non-zero offset  Non-infinite gain Fig.3. Response of ideal and non-ideal comparators. 51 Input Overdrive VRef tpd Output VOH 90% 50% 10% VOL tr Time Fig.4. Comparator propagation delay. The switching characteristics are important for comparators and are illustrated in Fig.4, which shows comparator input and output waveforms for a non-inverting configuration with a fixed reference voltage. Comparator switching characterises are similar to logic circuit device characteristics because the output is essentially digital. When the comparator input voltage crosses the reference voltage the comparator output will switch. This will not happen instantaneously – the time taken for the comparator output to reach 50% of the resulting voltage change is the propagation delay. The time taken for the comparator output voltage to rise from 10% to 90% of its range is the rise time. Fall time is similarly defined for the output switching in the opposite direction. The amount of voltage applied to the comparator’s input beyond the switching threshold (reference voltage) is known as the overdrive. Propagation delay and rise time are usually sensitive to overdrive, with increasing overdrive resulting in faster switching times. Comparator speed is also usually dependent on supply voltage. Comparator outputs The behaviour and circuit design requirements related to the output pin of comparators varies from device to device. This is different from standard op amps, where, although the internal circuitry may be different, the behaviour – aiming for an ideal voltage source – is the same. Of course, the performance (deviations from an ideal source) matter in many applications, but fundamentally all op amp outputs operate in the same Comparator positive supply R1 Comparator VCC+ In+ In– Pull-up voltage Q1 NPN Pull-up resistor Output VCC– Ground or negative supply Fig.5. Comparator common-collector output. 52 way. This is not the case for comparators. There are two main types of output: open collector (or drain) and push-pull. There are other differences between comparator devices; for example, some comparators have two complementary outputs (one is the logical NOT of the other – eg, the LT1016) and some have additional functionality which affects the output, such as strobes (eg, LT1011/ LM111) and latches (eg, AD790 and LT1016). Device datasheets should always be consulted to check the type of output, supply requirements and use of any special functionality. Fig.5 and Fig.6 show simplified internal circuitry for open-collector and MOSFET push-pull comparator output stages. The open-collector output (Fig.5) requires a pull-up resistor (R1) to the high-level voltage (VOH logic 1 voltage). To output the low-level voltage (VOL, logic 0 voltage) the comparator turns on the output transistor (Q1), which pulls the voltage down to close to ground, or to the negative rail on a split supply. To output the highlevel voltage the transistor is off, and the resistor pulls the output voltage up to the required level. This approach allows the high-level voltage to be different from the comparator supply voltage, which facilitates voltage translation in circuits where the digital and analogue parts have different supply voltages. A MOSFET can be used in a similar way (open drain). The push-pull output (Fig.6) uses two complementary transistors (NMOS and PMOS). This is a similar configuration to a logic gate output or half-bridge power switch. One of the transistors is on and one is off, switching the output voltage to either the high or low levels, which are typically equal to the comparator’s supply voltages. Some comparators with push-pull outputs have separate supplies (both positive and negative/ground) for the analogue comparison stage and the digital output part. This facilitates interfacing to logic on a different supply voltage from the analogue circuitry. (Note: push-pull outputs can also be built with bipolar transistors.) An advantage of the open-collector output configuration is that multiple comparators outputs can be connected together with a single pull-up resistor, as shown in Fig.7. This logically combines the outputs – as wired-OR or wiredAND, depending on how you look at it. This use of comparators is often referred to as wired-OR, because if any of the comparators’ output transistors are on (ie, the transistor output of U1 OR U2 OR U3 in Fig.7) then the output is pulled low. This is a negative-logic OR. However, if you think of the output voltages as VOL logic 0 and VOH logic 1 (positive logic), then the wired connection acts as an AND, that is all of the comparator outputs have Comparator positive supply VCC+ Comparator M1 In+ Output M2 In– VCC– Ground or negative supply Fig.6. Comparator MOSFET push-pull output. to be outputting logic 1 for the overall output value to be logic 1. Window comparator A similar common requirement is to have a single output indicating when an input voltage is within a particular range (ie, above a lower limit VrefL but below an upper limit VrefU). This is known as a window comparator. It requires two comparators (one inverting and one noninverting), with the outputs combined with an AND function (above-lower AND below-upper). The AND function can be implemented by a logic gate, but it is common to use comparators with opencollector outputs – see Fig.8. Hysteresis A comparator used with a single threshold (reference) value may switch states many times as a noisy, slowly changing input crosses the threshold. This is often undesirable, for example if the number of threshold-crossings is to be counted or you want to avoid ‘chattering’ when the input is close to the threshold. The problem may be overcome by using two thresholds, high and low: VTH and VTL. The difference between VTH and VTL is called the hysteresis (VH). The input-output responses of comparators with hysteresis are shown in Fig.9. When the input increases past VTH the comparator switches, but it does not switch back if the input decreases past VTH. The input must decrease past VTL before the comparator switches again. Fig.7. Commoncollector outputs in wired logic combination. Pull-up voltage R1 – + U1 – + U2 – + U3 Practical Electronics | June | 2023 VCC VrefU + vout R1 VOH – Vin VrefL + Non-inverting VOH vin VOL Vout – Fig.8. Window comparator using comparators with open-collector outputs. A comparator with hysteresis can be made using a single simple comparator by setting the threshold (reference voltage) depending on the comparator’s current output state. The comparator has two output states (two possible output vout VH VTL VTH Inverting VH vin VOL – – + + With hysteresis Without hysteresis Fig.10. Alternative comparator symbols. VTL VTH Fig.9. Switching characteristics of comparators with hysteresis. voltages VOL and VOH), which set the two thresholds. This arrangement uses positive feedback – the output voltage is fed back to shift the threshold. If the input noise level is known, then the hysteresis can be set slightly larger than this. The comparator will then not switch (or very rarely switch) as a result of the noise. Some comparators have built-in hysteresis (for example 500µV for AD790), otherwise hysteresis can be added using external resistors. We will discuss the design of these circuits in detail (operation component value calculation) after comparing the behaviour of a comparator, with and without hysteresis, using a simulation. Although comparators are often shown in schematics using the symbol in Fig.1, the more specific symbols shown in Fig.10 can also be used. These distinguish comparators from op amps and indicate if there is built in hysteresis or not. Fig.11. LTspice simulation schematic to show the difference between circuits with and without hysteresis. Fig.12. Response of the two comparators from the simulation schematic in Fig.11. The upper plot pane shows a basic comparator switching multiple times as the threshold is crossed. The lower plot pane shows that use of hysteresis cleans up the switching. Practical Electronics | June | 2023 53 Fig.13. A zoom in on two of the threshold crossings from Fig.11 to show the waveform at the switching point in more detail. The threshold voltages are also shown. The change in the threshold for the hysteresis comparator can be seen in the lower plot pane (magenta trace). Hysteresis comparison simulation Fig.11 shows an LTspice simulation schematic for comparing comparator circuits with and without hysteresis. The circuit uses the LT1018 to implement two inverting comparators. The LT1018 has an internal pull-up in its output stage – it supports wired logic but does not need an external pullup resistor. U1 is used as a basic comparator without hysteresis. The input voltage is compared to the voltage on the positive input of the comparator (node Th_basic) – the switching threshold. This voltage will be very close to reference voltage Vref, supplied by V4 (voltage on node Ref, 1.6V). It will change if the input bias current of the comparator changes, but the headline figure for bias current for the LT1018 is 15nA, corresponding with a 15µV drop across R6, and any changes when the device switches are likely to be smaller than this. Thus, the voltage on Th_basic is effectively constant. U2 is configured as a comparator with hysteresis using positive feedback via R5 (and R4). At first glance, the circuit might look like an op amp amplifier, but note the feedback is to the positive (non-inverting) input terminal. The input voltage is compared to the voltage on the positive input of the comparator (node Th_hysteresis). Due to the feedback, this threshold voltage will change significantly when the output voltage of the comparator changes. The simulation creates a 4.0Vpk-pk, 200Hz sinewave on node in_noiseless using voltage source V1. A randomly varying voltage of up to 0.4V pk-pk is added to the sinewave using Comparators circuits behavioural voltage source B1 with expression: V=V(In_noiseless)+0.40*white(50k*time) The random values are provided by the LTspice mathematic operation white(x), which generates a random number between −0.5 and 0.5 and smoothly transitions between values. The value of white(x) changes with each integer value of x. The value used here (50k*time) changes to a new integer every 20µs of simulation time. It approximates random noise on the 200Hz sinewave. 54 Fig.12 and Fig.13 show the result of applying the same noisy signal to a basic comparator (the circuit using U1 in Fig.11) and one with hysteresis (the U2 circuit). The basic comparator switches multiple times as the noisy signal crosses the threshold, whereas the comparator with hysteresis switches cleanly. Fig.12 shows that the behaviour of the basic comparator as it switches is different each time due to the random nature of the noise. Fig.13 shows more detail for one threshold crossing and includes plots of the threshold voltages. For the basic comparator, the threshold (Th_basic) remains constant – it actually changes by about 6µV when the compactor switches, but this is far too small to see on the scale plotted. For the comparator with hysteresis, the threshold voltage (Th_hysteresis) changes by about 320mV when the comparator switches – this is of the same order as the noise amplitude. Circuit design Fig.14 shows an inverting comparator with hysteresis – the same configuration as in Fig.11. Since the thresholds depend on the comparator’s output voltages these should ideally be accurately defined. For push-pull outputs this should not be a problem (outputs equal to the supplies), but where pull-up resistors are used these may need to be included in the design calculations. We will assume that output voltages are well defined in the following discussion. The circuit in Fig.14 uses an external reference voltage (Vref) to help set the thresholds. We assume Vref is from a voltage source with a low source resistance compared to R1, or that R1 is the source resistance and that it is of a known and fixed value. The switching point Vcomp depends on Vref and Vout. Vref will usually be fixed but Vout depends on the current state of the comparator. Vout can take one of two values, which we will ìVOH if v p > vn Þ logic 1 assume Vout = íto be ±VO (the positive and negative outputs apply to if v p < vnInitially, Þ logiclet 0 us assume that Vin < Vcomp split-supply îVOL circuits). so Vout = +VO. If Vin is slowly increased this condition remains until Vin = Vcomp = VTH (see Fig.9), where: 𝑉𝑉!" = 𝑉𝑉 = 𝑅𝑅# 𝑅𝑅$ 𝑉𝑉 + 𝑉𝑉 𝑅𝑅$ + 𝑅𝑅# %&' 𝑅𝑅$ + 𝑅𝑅# ( Practical Electronics | June | 2023 𝑅𝑅# 𝑉𝑉 − 𝑅𝑅$ 𝑉𝑉 𝑅𝑅 𝑅𝑅𝑅𝑅$$++ 𝑉𝑉𝑅𝑅!" =𝑅𝑅𝑅𝑅## 𝑉𝑉 +𝑅𝑅𝑅𝑅## 𝑉𝑉 $$++ 𝑅𝑅$ + 𝑅𝑅# %&' 𝑅𝑅$ + 𝑅𝑅# ( – Vin Vcomp Vref R1 Vout + R2 ref Vcomp + Vout 2𝑅𝑅 2𝑅𝑅$$ 𝑉𝑉𝑉𝑉 𝑉𝑉2𝑅𝑅 𝑉𝑉 $ Vin𝑉𝑉𝑉𝑉 ""== !" !"−−𝑉𝑉𝑉𝑉 !) !)== 𝑅𝑅 𝑅𝑅 𝑉𝑉 = 𝑉𝑉 − 𝑉𝑉 =R𝑅𝑅𝑅𝑅## (( 𝑉𝑉( $!) $++ " R !" 1 2𝑅𝑅 + 𝑅𝑅 $ # VCC R2 Vin 𝑅𝑅$ 𝑅𝑅0 𝑅𝑅/$0 = 𝑅𝑅$ + 𝑅𝑅0 Vref R1 – Vout + R3 Fig.15. Non-inverting comparator with Gnd 𝑅𝑅/$0 hysteresis. 𝑉𝑉!) = 𝑉𝑉 𝑅𝑅𝑅𝑅## 𝑅𝑅 + 𝑅𝑅# ( 𝑅𝑅 𝑉𝑉 𝑉𝑉 /$0 # %&' %&' analysis proceeds in a similar way, noting This equation is obtained by applying 𝑅𝑅𝑅𝑅$$++𝑅𝑅𝑅𝑅## 𝑉𝑉%&' Fig.16. A potential divider can be used 𝑅𝑅R$1 + 𝑅𝑅always that the comparator switches at the potential divider equation twice # in conjunction with a feedback resistor V and adding the results. First to find the = V , the relationship of V to V v v if > Þ logic 1 ì OH comp ref comp p n uits Vout = í to set comparator thresholds – singlecontribution of V V to V with V changes with the value of V , and, comp out in O VOL if v p ref < vn Þ logic 0 𝑅𝑅# 𝑅𝑅0 î supply 𝑅𝑅/#0circuit = shown. 𝑅𝑅##in = VTH or Vin = VTL at = 0 and then to find the contribution by definition,𝑅𝑅V 𝑅𝑅 𝑅𝑅 𝑉𝑉 𝑉𝑉 = = 𝑉𝑉 𝑉𝑉 # + 𝑅𝑅0 # !) !)thresholds.%&' of V out to V comp with V ref = 0. This is the two So, for 𝑅𝑅𝑉𝑉𝑅𝑅$!) =𝑅𝑅𝑅𝑅## %&' 𝑉𝑉%&'the higher $++ 𝑅𝑅 + 𝑅𝑅 $ # threshold, using superposition with the an application of vtheÞ circuit This resistance forms a potential divider logic 1 theory ìVOH if vÞ p >logic n 1 ìVsuperposition VOH =ifí v p >𝑅𝑅vn theorem. potential divider formulae, as before, we with R1 to set the upper threshold: out Vout = í $ VOL if# v p𝑉𝑉< vn+ Þ𝑅𝑅logic î= 𝑉𝑉!" 𝑉𝑉0( output v p < vn at ifswitching Þ%&' logic 0= VTH the get (with split supplies): V 𝑅𝑅$ comp îVOLOn 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅 + 𝑅𝑅# 𝑉𝑉!" = 𝑉𝑉 𝑅𝑅𝑅𝑅## 𝑅𝑅𝑅𝑅$$ changes to V out = −V O,$ changing the 𝑅𝑅 + 𝑅𝑅/#0 ( 𝑅𝑅!" 𝑅𝑅($ 𝑉𝑉*+,𝑉𝑉*+,-==𝑉𝑉𝑉𝑉 𝑉𝑉𝑉𝑉 𝑉𝑉𝑉𝑉 $ # −− %&' %&'== ( 𝑅𝑅$$++ 𝑅𝑅𝑉𝑉𝑅𝑅$!" + + 𝑅𝑅 𝑅𝑅 𝑉𝑉*+,= 𝑉𝑉𝑅𝑅%&' =𝑅𝑅𝑅𝑅## !" − 𝑉𝑉 switching point to a new value, 𝑅𝑅$ + 𝑅𝑅# $ #𝑅𝑅#$ + 𝑅𝑅# ( Vcomp = VTL: The switching points for the circuit in 𝑅𝑅# 𝑅𝑅$ 𝑅𝑅# = 𝑅𝑅$ + Rearranging, to make VTH the subject: Fig.16 are not necessarily symmetrical 𝑉𝑉!" 𝑅𝑅# 𝑉𝑉%&' 𝑅𝑅$ 𝑉𝑉( 𝑉𝑉!" = 𝑉𝑉%&' 𝑉𝑉 + 𝑅𝑅 𝑅𝑅# 𝑉𝑉%&' −𝑅𝑅 𝑉𝑉!)𝑅𝑅 =𝑅𝑅 $ ++ 𝑅𝑅# 𝑅𝑅$ around the open circuit voltage of the 𝑅𝑅$ + 𝑅𝑅#$ + 𝑅𝑅# ($𝑅𝑅$ + #𝑅𝑅# 𝑉𝑉( # 𝑅𝑅$ + 𝑅𝑅 𝑉𝑉!" = 𝑉𝑉%&' + 𝑉𝑉 𝑅𝑅𝑅𝑅$$++𝑅𝑅𝑅𝑅## 𝑅𝑅𝑅𝑅$$ R , R potential divider. For 𝑅𝑅$ 1+ 𝑅𝑅2# 𝑅𝑅$ + 𝑅𝑅# + 𝑅𝑅/1 (example, if 𝑅𝑅𝑉𝑉 + 𝑅𝑅+ 𝑉𝑉𝑉𝑉 $𝑉𝑉 #+ 𝑉𝑉𝑉𝑉 !" !"== .&' .&' (( 𝑅𝑅$ 𝑅𝑅 𝑅𝑅 𝑅𝑅 𝑅𝑅 𝑉𝑉 = 𝑉𝑉 + 𝑉𝑉 ## !" ## .&' we have VO = 5V and choose R1 = 5kΩ This is calculated in the same way as 𝑅𝑅# 𝑅𝑅# ( and R2 = 25kΩ we get a potential divider VTH but with V = −V . V will now out O out 𝑅𝑅# 𝑅𝑅$ 𝑅𝑅$the 𝑉𝑉𝑅𝑅!)# = 𝑉𝑉%&' − input 𝑉𝑉( below 2𝑅𝑅$ falls at 𝑉𝑉−VO−until voltage of 833mV, with nothing else Similarly: 𝑉𝑉!) = stay 𝑉𝑉 𝑅𝑅%&' +!"𝑅𝑅− = = 𝑅𝑅($ + 𝑅𝑅# 𝑉𝑉( $𝑉𝑉 #𝑅𝑅 𝑉𝑉+ !) 𝑅𝑅 𝑅𝑅V$comp + 𝑉𝑉𝑅𝑅"# again. connected to it. If we have a feedback The difference in the $ # 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅𝑅𝑅$$++𝑅𝑅𝑅𝑅## 𝑅𝑅𝑅𝑅$$ resistor R3 = 100kΩ then RP13 is 4.762kΩ, switching points – the hysteresis, VH – 𝑅𝑅 + 𝑅𝑅 𝑅𝑅 𝑉𝑉𝑉𝑉 = = 𝑉𝑉 𝑉𝑉 − − 𝑉𝑉 𝑉𝑉 $ # $ !) !) .&' ( 𝑅𝑅## (− 𝑉𝑉!)𝑅𝑅𝑅𝑅#=# .&' 𝑉𝑉𝑅𝑅.&' 𝑉𝑉( v p > vn Þ logic 1 ìVgiven is R OH if by: 𝑅𝑅 𝑅𝑅 P23 is 20kΩ and the threshold voltages # # Vout = í are V TL = 0.800V and V TH , = 1.00V We can use VO = 0 in the VTH formula for if v p < vn Þ logic 2𝑅𝑅$ 0 OL îV𝑉𝑉 2𝑅𝑅$= = 𝑉𝑉 − 𝑉𝑉 𝑉𝑉 a single-supply version. (using the above formula). We have a 𝑉𝑉" = 𝑉𝑉!" "− 𝑉𝑉!)!" = 𝑅𝑅!)# 𝑉𝑉 𝑉𝑉($ + 𝑅𝑅# ( 𝑅𝑅 𝑅𝑅 + 𝑅𝑅 𝑅𝑅## %&' 𝑅𝑅$$ + total hysteresis of 200mV, but the lower threshold (in this example) is much The switching is symmetrical about the Potential dividers closer to the open-circuit potential average Vref for the circuits in Fig.14 and Fig.15 𝑅𝑅# of VTH and𝑅𝑅V $ TL, which is: 𝑉𝑉!" = 𝑉𝑉%&'𝑅𝑅+ 𝑉𝑉( divider voltage than the upper threshold. can be obtained from a potential divider # 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅$ +𝑅𝑅𝑅𝑅 ## 𝑅𝑅𝑉𝑉#%&' 𝑉𝑉 As noted above, use of comparators connected between the supplies. Ideally, 𝑅𝑅 + 𝑅𝑅 %&' 𝑉𝑉 = 𝑉𝑉 𝑅𝑅$ + 𝑅𝑅# !)$ 𝑅𝑅$# + 𝑅𝑅# %&' with pull-up resistors may affect the to prevent the threshold-setting network accuracy of the above formula. This loading the potential divider and If R2 is much larger than R1 (which is not 𝑅𝑅# 𝑅𝑅$ of VTH and VTL is will tend to happen if the pull-up influencing the reference voltage, the unusual), the average 𝑉𝑉!) = 𝑉𝑉 − 𝑅𝑅 𝑉𝑉( # + 𝑅𝑅 𝑅𝑅$ + 𝑅𝑅𝑉𝑉#𝑅𝑅#%&' 𝑅𝑅 resistor (RPU) is not much smaller than potential divider resistors would need approximately equal to V . Under these $ # 𝑉𝑉%&' ref 𝑅𝑅$ !) = 𝑉𝑉 𝑅𝑅# Circuit Surgery A 𝑉𝑉 𝑅𝑅%&' + 𝑅𝑅# 𝑉𝑉!" !) = to have relatively low resistance. conditions the comparator switches at the feedback resistor. Under these 𝑉𝑉*+,=𝑅𝑅𝑉𝑉%&' = − 𝑉𝑉 $ ( $ + 𝑅𝑅# 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅$ + 𝑅𝑅# Bell better approach is to Ian actually use the points VH/2 above conditions the formulae can be adjusted and below Vref. For interaction between a potential divider to use the sum of the feedback and pullthe circuit in Fig.11, the switching points 16/04/23 2𝑅𝑅$(1.71V and 1.39 V) – and feedback resistor to set the two up resistors, instead of just the feedback are 1.548 ±0.161V 𝑉𝑉" = 𝑉𝑉!" − 𝑉𝑉!) = 𝑅𝑅 𝑉𝑉( 𝑅𝑅$ Comparators Circuits - Update # 𝑅𝑅 + 𝑅𝑅 $𝑅𝑅not #centred threshold voltages using the circuit resistor value, where relevant. For note that this is exactly on 𝑅𝑅 𝑅𝑅 # $ 𝑉𝑉*+,= 𝑉𝑉 = 𝑉𝑉 − 𝑉𝑉 𝑅𝑅 + 𝑅𝑅 %&' ( # !" 𝑉𝑉*+,- = 𝑉𝑉%&'the = 1.6V 𝑉𝑉$!" 𝑉𝑉($$ + 𝑅𝑅 𝑉𝑉(𝑅𝑅# $ +−𝑅𝑅#𝑉𝑉.&' + 𝑅𝑅 shown in Fig.16. example, for the non-inverting reference. 𝑅𝑅𝑉𝑉$!" += 𝑅𝑅 # 𝑅𝑅# 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅# For a single-supply circuit (as in Fig.16) comparator (Fig.15): If the comparator is run from a single the comparator’s output voltage is either supply the output (ideally) switches 𝑅𝑅 𝑅𝑅# + 𝑅𝑅$ + 𝑅𝑅%& 𝑅𝑅# +VO or 0. When the comparator output between #+V 0 rather than +VO and 𝑉𝑉!" = 𝑉𝑉'() − 𝑉𝑉 𝑉𝑉and O+ %&' 𝑅𝑅 𝑅𝑅 𝑅𝑅 $ # $ 𝑅𝑅 + 𝑅𝑅 𝑅𝑅 + 𝑅𝑅%& * 𝑅𝑅The +# 𝑅𝑅formula $ %& $ $𝑅𝑅 # + 𝑅𝑅 + 𝑅𝑅𝑉𝑉 $.!" $.&' –V𝑅𝑅O𝑉𝑉 is 0V, R3 is effectively connected to ground for+VTH𝑅𝑅$𝑉𝑉is the same, = 𝑅𝑅 ( $ # 𝑉𝑉!" = 𝑅𝑅#+ 𝑉𝑉𝑉𝑉.&' 𝑅𝑅# 𝑉𝑉( ( − =𝑉𝑉.&' 𝑅𝑅𝑉𝑉#!)zero Finally, in common with many circuits, but the removes in parallel with R1. The parallel value of 𝑅𝑅# 𝑅𝑅# the −V 𝑅𝑅# O term from comparators often require good supply the VTL equation, so it becomes: these resistors (RP13) is, using the formula decoupling close to the device, for two parallel resistors: 𝑅𝑅# 𝑉𝑉!) = 𝑅𝑅 + 𝑅𝑅𝑉𝑉%&' Finally, in common with many circuits, comparators oftenswitching require goodis supply decoup particularly when fast 𝑅𝑅 $ 𝑅𝑅# #𝑅𝑅 $ 𝑅𝑅$𝑅𝑅𝑅𝑅$0𝑅𝑅0 𝑅𝑅$𝑉𝑉!) + 𝑅𝑅=𝑅𝑅#$ + 𝑉𝑉$.&' − 𝑉𝑉( the device, particularly when fast switching is required. Datasheets will often provide a required. Datasheets will often provide 𝑅𝑅 = 𝑅𝑅 = /$0 /$0 𝑉𝑉!) = 𝑉𝑉.&' 𝑅𝑅#− 𝑉𝑉( 𝑅𝑅# 𝑅𝑅$𝑅𝑅$++𝑅𝑅0𝑅𝑅0 𝑅𝑅# than R1 the lower decoupling requirements.advice on decoupling requirements. # much larger If R2𝑅𝑅is 𝑅𝑅$ 𝑅𝑅0 threshold (VTL) is close to Vref, rather This𝑅𝑅/$0 resistance forms a potential divider = 𝑅𝑅 𝑅𝑅0lower threshold: $+ with R2 to set than V ref𝑅𝑅#being approximately at the the 𝑅𝑅$ 𝑉𝑉*+,- = 𝑉𝑉centre 𝑉𝑉 − two thresholds, 𝑉𝑉 %&' = between 𝑅𝑅/$0 𝑅𝑅/$0 𝑅𝑅$ + 𝑅𝑅# !" the 𝑅𝑅$ + 𝑅𝑅# ( 𝑉𝑉!)== 𝑉𝑉!) 𝑉𝑉 𝑉𝑉 as it is with the split supply circuit. 𝑅𝑅/$0++𝑅𝑅#𝑅𝑅#( ( 𝑅𝑅/$0 This may be a source of confusion with Simulation files 𝑅𝑅/$0 𝑉𝑉!) =the comparator 𝑉𝑉( single-supply circuits. When output is VO, R3 𝑅𝑅/$0 + 𝑅𝑅# Most, but not every month, LTSpice 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅$ is effectively connected to the supply in is used to support descriptions and 𝑉𝑉!" = 𝑉𝑉.&' + 𝑉𝑉( parallel with Non-inverting comparator 𝑅𝑅20. The parallel value of 𝑅𝑅#𝑅𝑅𝑅𝑅#R 𝑅𝑅# 𝑅𝑅# 0 analysis in Circuit Surgery. 𝑅𝑅 = 𝑅𝑅 = /#0 /#0 these resistors The non-inverting comparator with 𝑅𝑅0P23) is: 𝑅𝑅#𝑅𝑅#++𝑅𝑅(R The examples and files are available 0 hysteresis is shown in Fig.15 – we just 𝑅𝑅# 𝑅𝑅0 for download from the PE website. 𝑅𝑅/#0 = swap the input and reference. The 𝑅𝑅# + 𝑅𝑅0 𝑅𝑅$ + 𝑅𝑅# 𝑅𝑅$ 𝑉𝑉!) = 𝑉𝑉.&' − 𝑉𝑉( 𝑅𝑅$𝑅𝑅$ 𝑅𝑅# Electronics𝑅𝑅#| June | 2023 Practical 55 𝑉𝑉!"== 𝑉𝑉!" 𝑉𝑉 𝑉𝑉 𝑅𝑅/#0( ( 𝑅𝑅$𝑅𝑅$++𝑅𝑅/#0 𝑅𝑅$ rcuits Fig.14. Inverting comparator with hysteresis. 𝑅𝑅𝑅𝑅## 𝑅𝑅𝑅𝑅$$ 𝑅𝑅%&' 𝑉𝑉𝑉𝑉 𝑉𝑉𝑉𝑉 𝑉𝑉𝑉𝑉𝑅𝑅$ # −− !) !)== %&' 𝑅𝑅𝑉𝑉𝑅𝑅$!) + + 𝑅𝑅 𝑅𝑅 𝑅𝑅 𝑅𝑅 = 𝑉𝑉 −𝑅𝑅𝑅𝑅## (( 𝑉𝑉( $ ## $$++ %&' 𝑅𝑅$ + 𝑅𝑅# – 𝑅𝑅$ + 𝑅𝑅# V