\documentclass[12pt]{article}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\setlength{\textheight}{23cm}
\setlength{\textwidth}{15cm}
\setlength{\topmargin}{-2cm}
\setlength{\oddsidemargin}{0cm}
\usepackage{graphicx}
\raggedbottom

\begin{document}

\begin{center}
\textbf{Physics 120  \smallskip - \smallskip David Kleinfeld \smallskip - \smallskip Spring 2019}
\end{center}

\setcounter{section}{0}

 \section{Notes on Comparators and Schmidt Trigger}
The Comparator is a special circuit (Figure 1) that incorporates an Op-Amp at high gain together with an internal inverter (A in Figure 1) and a NPN transistor (B in Figure 1) at the output. The voltage levels that are switched at the output are controllable, so that decisions on an analog input ($V_-$ in Figure 1) relative to a threshold level  ($V_+$ in Figure 1) may be transformed into voltages used to control different logic families, e.g., TTL uses 0 V and 3.2 V as logic "0" and "1".  

\includegraphics[width=8cm]{Comparator_1}
{\bf Figure 1.}

\section{Basic comparator}
For the comparator circuit below (Figure 1), the collector of the NPN output transistor is connected to $V_{CC}$ though a resistor, $R_3$, and the emitter is connected to ground, so that we have:
\begin{eqnarray}
V_{out} &=&  0 \; \; \; \; \; \; V_-  > V_+ \\
            &>&  0\; \; \; \; \; \; V_-  < V_+ \nonumber .
\end{eqnarray}
The threshold level is 
\begin{equation}
V_+ = V_{CC} \frac{R_2}{R_1 + R_2},
\end{equation}
and any noise in the input is reflected as a chattering of voltage levels in the output (Figure 2).

\includegraphics[width=8cm]{Comparator_2}
{\bf Figure 2.}

\section{Comparator with feedback}
Let's now add a feedback resistor, $R_4$, so that the threshold will depends on the value of the output, $V_{out}$ (Figure 3). There are two critical ingredients to make this work.  First, the threshold must drop after the initially crossing of the input, $V_-$, as it increases past $V_+$. Contrawise, the threshold must increase when the input first decrease below $V_+$. This supplies hysteresis.  We can achieve this goal noting that the comparator output decreases, i.e., from $V_{CC}$ to 0 as the input crosses the threshold from below (Figure 2), and vice versa.  The second ingredient is that the value of the feedback is small, i.e., $R_4 >> R_1$, $R_4 >> R_2$, and $R_4 >> R_3$, so that the maximum output voltage is not substantially shifted from $V_{CC}$.

\includegraphics[width=8cm]{Comparator_3}
{\bf Figure 3.}

Kirchoff's Current Law gives
\begin{equation}
0 = \frac{V_+ - V_{CC}}{R_1} +  \frac{V_+}{R_2} +  \frac{V_+ - V_{out}}{R_4} 
\end{equation}
so that
\begin{eqnarray}
V_+ &=&  \frac{R_2 R_4 V_{CC} + R_1 R_2 V_{out} }{R_1 R_2 R_4} \\
             &=&  \frac{R_2}{R_1 + R_2} \; \; \frac{V_{CC} + \frac{R_1}{R_4} V_{out}}{1+\frac{1}{R_4}\frac{R_1 R_2}{R_1 + R_2}}  \nonumber \\
             &\approx&   \frac{R_2}{R_1 + R_2} \;  \left( V_{CC} + \frac{R_1}{R_4} V_{out} \right)  \left( 1-\frac{1}{R_4}\frac{R_1 R_2}{R_1 + R_2} \right)  \nonumber .
\end{eqnarray}
where in the last step we used $1/(1+x) \approx 1-x$ for small values of $x$.

\subsection{Case of $V_{out}$ = 0}
\begin{equation}
V_+ =   \frac{R_2}{R_1 + R_2} V_{CC}  \left( 1-\frac{R_1}{R_4} \; \frac{R_2}{R_1 + R_2} \right).
\end{equation}

\subsection{Case of $V_{out}$ $>$ 0}
We begin with Kirchoff's Current Law for the output, i.e.,
\begin{equation}
0 = \frac{V_{out} - V_{CC}}{R_3} +  \frac{V_{out} - V_+}{R_4} .
\end{equation}
Then
\begin{equation}
V_{out} =   \frac{R_4}{R_3 + R_4} V_{CC} + \frac{R_3}{R_3 + R_4} V_+   .
\end{equation}
and
\begin{eqnarray}
V_+ &\approx&   \frac{R_2}{R_1 + R_2}  \left( V_{CC} + \frac{R_1}{R_3 + R_4} V_{CC} +  \frac{R_1 R_3}{R_4 (R_3 + R_4)} V_{CC} \right)  \left( 1-\frac{1}{R_4} \frac{R_1 R_2}{R_1 + R_2} \right) \\
  &\approx&   \frac{R_2}{R_1 + R_2} V_{CC} \left( 1 + \frac{R_1}{R_4} - \frac{R_1 R_2}{R_4(R_1 + R_2)} \right)   \nonumber \\
  &\approx&   \frac{R_2}{R_1 + R_2} V_{CC} \left( 1 + \frac{R_1}{R_4} \; \frac{R_1}{R_1 + R_2} \right)   \nonumber.
\end{eqnarray}
where we dropped terms proportional to $1/R_4^2$. Note that, to the same approximation, the value of $V_{out}$ of diminished so that
\begin{eqnarray}
V_{out} &=&  0 \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \; \;    V_-  > V_+ \\
            &=&  V_{CC} \left(1-\frac{R_3}{R_4} \; \frac{R_2}{R_1 + R_2} \right) \; \; V_-  < V_+ \nonumber .
\end{eqnarray}
The key result is that feedback adds hysteresis that shifts the threshold, and provides immunity to noise, independent of the detailed values of the components. The width of the hysteresis scales as $R_1$/$R_4$. An example with $R_1$ = $R_2$ = $R_3$ and $R_4$ = 5$R_1$ is shown in Figure 4.

\includegraphics[width=8cm]{Comparator_4}
{\bf Figure 4.}

\end{document}
