Parts

LM393 dual comparator: pinout, the pull-up, hysteresis, the LM339 and the LM2903

By

The LM393 is two comparators in one 8-pin package. Pin 1 is the first output, pins 2 and 3 its inverting and non-inverting inputs, pin 4 is ground, pins 5 and 6 the second comparator's inputs, pin 7 its output and pin 8 is VCC. That is the LM358's pin order, but the outputs are open collector: they pull down and never drive high, so each output needs a pull-up resistor.

This page covers the pull-up, the input range, and the feedback resistor that stops a slow signal from making the output chatter, worked through for a 5 V comparator feeding a 3.3 V board. It also covers the LM339 (the quad, with its supply pins moved) and the LM2903. Every figure comes from TI's LM393 sheet (SLCS005AH, April 2025) and its LM339 sheet (SLCS006Z, May 2025).

Datasheet: Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH) (PDF)Ask Datasheet Guru about the LM393DR

Advertisement

Pinout by package

LM393P DIP-8 · TI1=1OUT 2=1IN- 3=1IN+ 4=GND 5=2IN+ 6=2IN- 7=2OUT 8=VCC
top view, notch upLM393P181OUTVCC271IN-2OUT361IN+2IN-45GND2IN+

Top view, notch up: pin 1 is top left and the count runs down the left side, then up the right.

The SOIC (LM393DR) and the LM2903 use the same pin order.

Source: Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 3 (Figure 4-1, D, DGK, JG, P, PS, DDF and PW packages, top view, and Table 4-1 pin functions); Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 1 (device information: LM393 in PDIP (8), 9.81 mm × 6.35 mm, also SOIC, VSSOP, SO and TSSOP)

LM339N DIP-14 · TI1=1OUT 2=2OUT 3=VCC 4=2IN- 5=2IN+ 6=1IN- 7=1IN+ 8=3IN- 9=3IN+ 10=4IN- 11=4IN+ 12=GND 13=4OUT 14=3OUT
top view, notch upLM339N1141OUT3OUT2132OUT4OUT312VCCGND4112IN-4IN+5102IN+4IN-691IN-3IN+781IN+3IN-

Top view, notch up. VCC is pin 3 and GND is pin 12; the outputs sit on pins 1, 2, 13 and 14.

TI notes that some makers swap the names of channels 1 and 2; the pins are the same.

Source: Texas Instruments LM339B, LM2901B, LM339, LM239, LM139, LM2901 Quad Differential Comparators (SLCS006Z), p. 4 (Figure 5-1, D, DB, N, NS and PW packages, top view, and Table 5-1 pin functions)

Which one do you have?

The 393 is the dual and the 339 the quad. An A after the number (LM393A, LM339A) marks a part sorted for lower offset. A B (LM393B, LM339B) is TI's newer die, covered under substitutes. The last letter is the package: P or N is the through-hole DIP, D the SOIC. An LM393P is the plain dual in an 8-pin DIP.

The LM2903 and the LM293 sit in the same datasheet with the same pins; only the temperature range and a few limits change. An LM2903 is rated for −40 to 125 °C, so it turns up in cars and outdoor boards.

Absolute maximum ratings

TI allows 36 V across the LM393 and recommends 2 to 30 V. Either input may go from 0.3 V below ground to 36 V, whatever the supply, and the differential limit is the full ±36 V. That is unusual: you can feed a 12 V signal into a comparator running from 5 V without damage.

Absolute maximum and recommended ratings, TI SLCS005AH and SLCS006Z
ParameterLM393PDIP-8LM339NDIP-14
Supply voltage, absolute maximum VCC36 V36 V
Supply voltage, recommended VCC2 to 30 V2 to 30 V
Input voltage, either input VI−0.3 to 36 V−0.3 to 36 V
Differential input voltage VID±36 V±36 V
Output voltage (pull-up rail) VO−0.3 to 36 V36 V
Output current IO20 mA20 mA
Output short circuit to groundunlimitedunlimited
Thermal resistance, junction to air, DIP RθJA114.9 °C/W114.9 °C/W
Operating temperature TA0 to 70 °C0 to 70 °C
ESD, human-body model V(ESD)±2000 Vnot in this table

The output can be pulled up to anything up to 36 V, which is how a 5 V comparator drives a 12 V relay driver or a 3.3 V microcontroller pin. It may be shorted to ground indefinitely; TI warns that a short to VCC can overheat and destroy it. An input pulled more than 0.3 V below ground turns on a parasitic transistor and can make the output wrong until the current stops.

Input range, output and speed

At VCC = 5 V and 25 °C unless marked (min/max unless marked typical)
ParameterLM393PDIP-8LM339NDIP-14
Input offset voltage VIO25 °C; 0 to 70 °C2 typ, 5 mV max; 9 mV max2 typ, 5 mV max; 9 mV max
Input bias current IIB25 °C; 0 to 70 °C; flows out of the pin25 typ, 250 nA max; 400 nA max25 typ, 250 nA max; 400 nA max
Common-mode input range VICR25 °C; 0 to 70 °C0 to VCC − 1.5 V; to VCC − 2 V0 to VCC − 1.5 V; to VCC − 2 V
Output low voltage VOLsinking 4 mA; 25 °C, hot130 typ, 400 mV max; 700 mV max150 typ, 400 mV max; 700 mV max
Output sink current IOLVOL = 1.5 V6 mA min6 min, 16 mA typ
Output leakage when off IOHVOH = 5 V, 25 °C0.1 typ, 50 nA max0.1 typ, 50 nA max
Voltage gain AVDVCC = 15 V, RL ≥ 15 kΩ50 min, 200 V/mV typ50 min, 200 V/mV typ
Response time5 mV overdrive; TTL step; 5.1 kΩ to 5 V, 15 pF1.3 µs; 0.3 µs typ1.3 µs; 0.3 µs typ
Supply current, no load ICCVCC = 5 V0.45 typ, 1 mA max, both0.8 typ, 2 mA max, all four

The inputs work from 0 V up to 1.5 V below VCC at 25 °C, and up to 2 V below over 0 to 70 °C. On 5 V that is 0 V to 3.5 V, or 3 V when warm. TI also notes that only one input has to be inside that range. As long as the reference sits there, the other input may go all the way to VCC and the output still gives the right answer.

LM3935 V, 25 °C50?in 0 to 3.5 Vout: pull-up sets the highLM3935 V, 0 to 70 °C50?in 0 to 3 Vout: pull-up sets the highsupplyinput rangeoutput swing
Figure 1. Where the inputs may go on a single 5 V supply. Keep the reference input inside the bar; the other input may go higher.

The output transistor sinks at least 6 mA with 1.5 V across it, and at 4 mA it sits at 130 mV typical, 400 mV at most (700 mV when hot). When it is off it leaks 50 nA at most. Response time is 1.3 µs for a 100 mV step that overdrives the input by 5 mV, and 0.3 µs for a full logic-level step. The whole package draws 0.45 mA typical, 1 mA at most, on 5 V.

−+inside the LM393+3.3 V10 kΩoutoff: 3.23 Von: near 0 V
Figure 2. The output can only pull down. The resistor you add sets the high level, so it can be a different rail from the chip's own supply.

What it is good for

  • Turning an analog level into a logic signal: a light sensor, a thermistor divider, a battery voltage against a threshold.
  • Level shifting. The comparator runs from 5 V or 12 V and its pull-up goes to the 3.3 V of the microcontroller that reads it.
  • Zero-crossing and window detectors. Two outputs pulled up through one resistor form a wired-AND, so both comparators of one LM393 make a window.
  • Overcurrent and undervoltage trips, where the output shuts something down.

It is the wrong part for edges that must arrive faster than its 1.3 µs response time, for a logic output with no room for a resistor, and for anything that needs a linear output. For an amplifier, use the LM358, which has the same pins and a push-pull output. The LM358 vs LM393 page covers what breaks when you swap them.

Worked example: a 5 V threshold with hysteresis into a 3.3 V board

One half of an LM393 on 5 V watches a sensor voltage on pin 2. Its output goes to an input pin of a 3.3 V microcontroller and should go low when the sensor passes about 2.5 V, without chattering while the signal drifts across that point.

1. Set the middle. 10 kΩ from 5 V and 10 kΩ to ground put pin 3 at 2.5 V. That is inside the 3 V input limit even when warm, so the sensor on pin 2 may swing all the way to 5 V.

2. Pick the pull-up. 10 kΩ to 3.3 V. TI writes the 400 mV output-low limit at 4 mA, which allows a pull-up as small as (3.3 V − 0.4 V) / 4 mA = 725 Ω. Ten times that keeps the low level close to 0 V and wastes little current.

3. Add feedback. 100 kΩ from pin 1 to pin 3. With the output off, the pull-up feeds a little current into pin 3 through it, and pin 3 rises to 2.535 V; the output itself sits at 3.23 V, which a 3.3 V input reads as high. With the output on, the same resistor pulls pin 3 down to 2.381 V.

4. Read off the hysteresis. The sensor has to climb past 2.535 V to pull the output low, then fall below 2.381 V to let it go: 154 mV apart. Taking the output-low level at the 400 mV limit instead of 0 V raises the lower threshold to 2.4 V and leaves 135 mV.

5. Check it against the errors. The offset is 9 mV at most over 0 to 70 °C, so even the smaller band is 15 times the offset. The input bias current, 400 nA at most, flows out of pin 3 into the 4.76 kΩ the resistors present and lifts both thresholds by about 1.9 mV.

6. Check the current. With the output low it sinks 354 µA: the pull-up's share plus a little through the feedback resistor. That is far below the 6 mA TI guarantees.

3 2 1 8 4 10 kΩ +5 V R2 10 kΩ 100 kΩ R4 10 kΩ +3.3 V +5 V U1A LM393 signal to MCU
Figure 3. The threshold circuit on half an LM393 (pins 1, 2 and 3), drawn as ngspice checked it: pin 3 sits at 2.535 V with the output off and 2.381 V with it on, and the output sinks 354 µA. The second half (pins 5, 6, 7) is free.
154 mV band01232.002.252.502.753.00high 3.23 Vrising: 2.535 Vfalling: 2.381 Vinput on pin 2, VV
Figure 4. The output changes at a different input voltage going up than coming down. Noise smaller than the band cannot flip it back.
1 mV10 mV100 mVBias current400 nA × 4.76 kΩ1.9 mVOffset9 mV max, hot9 mVBand, worstoutput low 400 mV135 mVBandoutput low 0 V154 mVDC error at the + input, log scale
Figure 5. The hysteresis band is more than ten times the offset, so the part's own errors cannot make the output chatter.

Fit 100 nF from pin 8 to ground, close to the package. Without hysteresis a slow input crossing the threshold can make the output switch many times as noise rides on it; the comparator lesson shows why.

Worked example in numbers

Trips going up
2.535 V
Releases going down
2.381 V
Hysteresis
154 mV
Output high
3.23 V

LM339: the quad, with the supplies moved

The LM339 puts four of the same comparators in a 14-pin DIP, with the same input range, offset, bias current and response time in TI's tables. Watch the supply pins: VCC is pin 3 and GND is pin 12, and the four outputs sit on pins 1, 2, 13 and 14. TI also notes that some makers swap the names of channels 1 and 2; the pins themselves are the same.

LM393 (DIP-8)18V+273645V−LM339 (DIP-14)114213312V+V−4115106978top view, notch up
Figure 6. The supply pins are not where the LM393 or the LM324 keep them.

The whole LM339 draws 0.8 mA typical and 2 mA at most on 5 V, and its output sinks 16 mA typical at 1.5 V. Tie the inputs of any unused comparator to ground so it sits in a known state.

LM2903: the same dual for −40 to 125 °C

The LM2903 uses the LM393's pins and the same data sheet. It is rated from −40 to 125 °C against 0 to 70 °C, and pays for it with a wider offset: 7 mV maximum at 25 °C and 15 mV over temperature, against 5 and 9 mV. In the example above the worst band of 135 mV is still nine times that 15 mV, so the same resistors work.

Advertisement

Tips and checks

  • Every output needs its own pull-up unless you want two outputs to share one as a wired-AND. With no resistor the output just floats.
  • Pull up to the voltage of whatever reads the output, not the comparator's own supply. A 5 V pull-up into a 3.3 V microcontroller pin overdrives it.
  • Keep the reference input below VCC − 2 V. The signal input can go higher, as long as the other one stays in range.
  • Add hysteresis for any input that changes slowly or carries noise. A feedback resistor ten times the divider resistance gives about 150 mV here.
  • Never let an input go more than 0.3 V below ground. A series resistor of a few kilohms protects an input that comes from off the board.

Substitutes

The LM393A, LM393B and LM2903 drop into the same socket. The LM393B is the one to buy for new work: lower offset, lower bias current, less supply current and better ESD. For four comparators use the LM339, and rewire the supply.

Pin numbers as on the DIP-8 or SOIC-8 top view, notch or dot at pin 1
PartPinsVerdict
LM393A1OUT … 4 GND, 8 VCCThe same comparator sorted for offset: 1 mV typical and 2 mV maximum at 25 °C in TI’s table, against 5 mV. Drop-in where the threshold must be tight.Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 3; Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 9
LM393B1OUT … 4 GND, 8 VCCTI’s newer die in the same pinout and a stated drop-in replacement: 2 to 36 V, 0.37 mV offset, 3.5 nA bias, 200 µA per comparator, 1 µs, 2 kV ESD, −40 to 85 °C.Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 1; Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 4
LM29031OUT … 4 GND, 8 VCCThe same dual for −40 to 125 °C in the same sheet and pinout. Offset 7 mV maximum at 25 °C and 15 mV hot, against the LM393’s 5 and 9 mV.Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 4; Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 10

Bench check: is it working?

  1. Power the chip from 5 V, fit 10 kΩ from pin 1 to 5 V and put 2.5 V on pin 3 from two equal resistors.
  2. Put 2 V on pin 2. Pin 1 should read close to 5 V. Raise pin 2 to 3 V: pin 1 should drop to a few tens of millivolts.
  3. Remove the pull-up and measure pin 1 with the input at 2 V. A multimeter reads nothing useful, which is normal: the output is off and floating.
  4. Measure the supply current with no load: about 0.45 mA, 1 mA at most. Much more points to a damaged part or an input taken below ground.

What we'd do

Use the LM393 wherever an analog level has to become a logic signal, pull each output up to the supply of whatever reads it, and add a feedback resistor so the band is at least ten times the 9 mV offset. Buy the LM393B for new boards, and use the LM2903 when the board lives outdoors or in a car.

Questions people ask

What is the LM393 pinout?

Pin 1 output A, 2 inverting input A, 3 non-inverting input A, 4 ground, 5 non-inverting input B, 6 inverting input B, 7 output B, 8 VCC. The DIP and SOIC use the same order.

Why does the LM393 need a pull-up resistor?

Its outputs are open collector. The transistor can pull the pin low but nothing inside drives it high, so a resistor to a supply makes the high level.

What pull-up value should I use?

On 3.3 V, anything from about 725 Ω up. 10 kΩ is a common choice: it keeps the low level near 0 V and costs 330 µA while the output is low. Smaller values give faster rising edges.

Can an LM393 run from 3.3 V?

Yes. TI recommends 2 to 30 V. On 3.3 V the inputs work from 0 V to 1.8 V at 25 °C, 1.3 V when warm, so the reference has to sit low.

What is the difference between the LM393 and the LM358?

Same pins, different outputs. The LM358 is an op-amp with a push-pull output meant for feedback; the LM393 is a comparator with an open-collector output meant to switch, and it does so in about a microsecond. More in LM358 vs LM393.

Buying LM393 in India

The LM393P in DIP-8 and the LM339N in DIP-14 are stocked by most Indian component sellers. Ask for TI or another named maker, and check one from each batch with the bench test above before it goes into a board. Our guide to buying electronic components in India compares ten online sellers and covers how to spot fakes.

Advertisement

One email a month from the bench

New circuits, lessons, part guides and calculators, on the first Sunday of each month.

We'll send one email to confirm. Every email has a one-click unsubscribe. Privacy policy

Used in these lessons

Lessons that go deeper

Datasheets this page was checked against

Makers revise datasheets. If the copy you download has a newer revision and a number here disagrees with it, the datasheet wins, and we would like to hear about it.