10.5.2 Solution

Comparators may be used, combined with a variable voltage divider bridge, to generate the correct output. The LMV339 (a low voltage variant of the LM339) is one option. It is inexpensive at less than $1 each (at single quantity). The datasheet from National Semi detailed how to add hysteresis. A single chip is enough for two quadrature encoders, although we will need a number of resistors (3 per comparator, yielding a total of 12 for the whole set up).

The basic circuit is illustrated as follows:

\includegraphics{comphyster}

Here's how it works. When the output of the comparator is high, the voltage at the non-inverting terminal is as follows:


\begin{displaymath}
V_h=\mathrm{VCC}\frac{\mathrm{R3}}{\mathrm{R3}+\frac{1}{1/\mathrm{R2}+1/\mathrm{R5}}}
\end{displaymath} (10.1)

When the output of the comparator is low, the voltage at the non-inverting terminal is as follows:


\begin{displaymath}
V_l=\mathrm{VCC}\frac{\frac{1}{1/\mathrm{R3}+1/\mathrm{R5}}}{\mathrm{R2}+\frac{1}{1/\mathrm{R3}+1/\mathrm{R5}}}
\end{displaymath} (10.2)

This means the input voltage must drop below $V_l$ for the output to switch to high, and the input voltage must rise above $V_h$ for the output to switch to low. This logic appears to be inverted, hence the name ``inverted''.

Note that the ``pull-up'' resistor, R1, is necessary because the comparator has an open-collector type output. Without a pull-up resistor, the device cannot drive the output high (pin 2 of IC1A). R4, the load resistor, is not actually there. It is merely a symbol that renotes the impedence of the load (in our case, it is in the range of mega Ohms).

Copyright © 2006-02-15 by Tak Auyeung