The comparator · 06 of 11

The input range

The LM393 compares voltages from 0 up to about 1.5 V below its supply, not up to the supply. From 3V3 that is about 1.8 V, and the top 45 % of the knob sets a threshold it cannot be trusted to find. The input may go higher, as long as the knob stays in range.

Not all the way to VCC

The input range
VCC
Knob, % of its travel40 %, 1.32 V
Input2.31 V
Range ends
1.80 V
Usable knob
bottom 55 %
Answer
HIGH
The input is above the range, but the knob is inside it, so the answer is still right: HIGH. A light sensor in sunshine can go here safely, as long as the threshold stays low.

Every comparator has a window of input voltages it can compare. ON's datasheet calls it the input common-mode range, and for the LM393 it runs from 0 V to VCC − 1.5 V at 25 °C. The inputs are built from PNP transistors, which work down to ground and run out of room near the top.

From 3V3 that is about 1.8 V. From 5V it is about 3.5 V. Above it, the datasheet makes no promise about the answer.

The rule is gentler than it sounds

The datasheet adds one line that makes this livable: if one input goes above the range, the output is still right, as long as the other input stays inside it. Only when both are above is the answer undefined.

So there are three cases, and the figure shows each:

  • Both inside. The ordinary case; the answer is right.
  • The input above, the knob inside. Still right. A light sensor in sunshine, or a potentiometer turned to the top, does no harm here.
  • The knob above. Right only while the input stays low. The moment the input climbs to meet the threshold, which is the only moment the threshold exists for, both are above the range and the answer is no longer promised.

Which part of the knob works

The knob divides VCC, so a fixed share of its travel is out of range:

VCCRange endsUsable knobOut of range
3V3about 1.8 Vthe lower 55 %the top 45 %
5Vabout 3.5 Vthe lower 70 %the top 30 %

Across the LM393's rated 0 to 70 °C, the datasheet lowers the ceiling to VCC − 2.0 V: 1.3 V from 3V3. Leave some room below 1.8 V if the board will live somewhere cold or warm.

For most sensors this costs nothing. A TK20 light sensor switching at dusk needs a threshold of about a tenth of a volt. It matters for a block whose interesting range is high, such as a potentiometer you want to trip near the top of its turn: from 3V3, the TK29 cannot find a threshold up there. On an Uno, VCC is 5V and the range reaches 3.5 V; on a 3.3 V board, read ANA and compare in the sketch instead.

When it does not work

Past about halfway, the knob stops doing anything.

From 3V3, halfway round is about 1.65 V and the comparator's range ends at about 1.8 V. Past there the threshold is out of range and DIG may stick or switch somewhere unexpected. Keep the knob in the lower half from 3V3, the lower 70 % from 5V.

It worked on the bench and misbehaves in the shed.

The range shrinks when the chip is cold or hot: ON's datasheet gives VCC − 1.5 V at 25 °C and VCC − 2.0 V across 0 to 70 °C. A threshold set just under 1.8 V from 3V3 can fall outside it. Leave some room, or, on an Uno, run from 5V.

My light sensor goes up to 2.9 V. Is that a problem?

Not by itself. One input above the range is fine as long as the other is inside it, and a threshold for dusk sits far below 1.8 V. It becomes a problem only if you also set the knob above 1.8 V, which is the one thing to avoid.

Where this goes next

Four wires, a block in IN, and a sketch that prints the decision and the number side by side.

The first read

Edit this page — content/books/analog-to-digital-signal/the-input-range.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Analog to Digital Signal

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum