Electronic Design

A Window Comparator Can Create The Simplest Electronic Key

Today’s digital technology has given birth to many systems that are useful for electronic key applications. Some utilize digital keyboard access, serial burst data sent via radio, and other elegantly digital and highly secure schemes. But for some applications, reverting back to the analog world yields a refreshingly simple and easy to build solution: a window comparator, used to read the value of one or more resistors, which then drives a relay.

The window comparator is built with two linear LM311 ICs (see the figure). The LM311’s output has an NPN transistor (pin 7 = collector, pin 1 = emitter). The output transistors of the two LM311s (Q-U1 and Q-U2) are connected in series to create a logical AND. Therefore, the relay is driven and the user contacts are closed only when both transistors are in conduction, enabling the electronic key function. U1 has its (+) input connected to VIN (the input jack) and its (−) input connected to VTH1. U2 has its (−) input connected to VIN, and its (+) input connected ad VTH2.

The two threshold voltages (VTH1, VTH2) are obtained from the divider formed by RY1, RY2, and RY3. In the prototype, these values are 10k, 1k, and 10k, respectively, resulting in an upper threshold (VTH1) of 6.3 V and a lower threshold (VTH2) of 5.7 V.

Only when VIN is 6 V (or more precisely, if 6.3 V > VIN > 5.7 V) will the window comparator trip and the coil of relay be energized. To create this unlocking condition, a special jack must be plugged into J1. The jack must contain a two-resistor divider (RX2, RX3) with the correct values to generate the required 6-V output.

There are many values of RX2-RX3 that will produce the proper output. But, the selected resistor values need to be high enough to reduce the current, yet low enough to reduce impedance and the risk of RF-noise disturbances (i.e., low kilohm values). The value of C2 can be increased to create a delay in the “unlock” function, to make “lock picking” more difficult.

The size of the window depends on the RY2 value in conjunction with RY1 and RY3 (see the table). To calculate the resistor values yourself, the formulas are determined simply by Ohm’s law as follows:

Vth1 = 12 / (RY1 + RY2 + RY3) *
   (RY2 + RY3)

Vth2 = 12 / (RY1 + RY2 + RY3) *

VIN = 12 / (RX1 + RX2 + RXXX) *


RXXX = 1 / \[(1/RX3) + (1/RX4)\]

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.