Parts
LM393 dual comparator: pinout, the pull-up, hysteresis, the LM339 and the LM2903
By Bulan Sarkar
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
Pinout by package
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)
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.
| Parameter | LM393PDIP-8 | LM339NDIP-14 |
|---|---|---|
| Supply voltage, absolute maximum VCC | 36 V | 36 V |
| Supply voltage, recommended VCC | 2 to 30 V | 2 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 V | 36 V |
| Output current IO | 20 mA | 20 mA |
| Output short circuit to ground | unlimited | unlimited |
| Thermal resistance, junction to air, DIP RθJA | 114.9 °C/W | 114.9 °C/W |
| Operating temperature TA | 0 to 70 °C | 0 to 70 °C |
| ESD, human-body model V(ESD) | ±2000 V | not 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
| Parameter | LM393PDIP-8 | LM339NDIP-14 |
|---|---|---|
| Input offset voltage VIO25 °C; 0 to 70 °C | 2 typ, 5 mV max; 9 mV max | 2 typ, 5 mV max; 9 mV max |
| Input bias current IIB25 °C; 0 to 70 °C; flows out of the pin | 25 typ, 250 nA max; 400 nA max | 25 typ, 250 nA max; 400 nA max |
| Common-mode input range VICR25 °C; 0 to 70 °C | 0 to VCC − 1.5 V; to VCC − 2 V | 0 to VCC − 1.5 V; to VCC − 2 V |
| Output low voltage VOLsinking 4 mA; 25 °C, hot | 130 typ, 400 mV max; 700 mV max | 150 typ, 400 mV max; 700 mV max |
| Output sink current IOLVOL = 1.5 V | 6 mA min | 6 min, 16 mA typ |
| Output leakage when off IOHVOH = 5 V, 25 °C | 0.1 typ, 50 nA max | 0.1 typ, 50 nA max |
| Voltage gain AVDVCC = 15 V, RL ≥ 15 kΩ | 50 min, 200 V/mV typ | 50 min, 200 V/mV typ |
| Response time5 mV overdrive; TTL step; 5.1 kΩ to 5 V, 15 pF | 1.3 µs; 0.3 µs typ | 1.3 µs; 0.3 µs typ |
| Supply current, no load ICCVCC = 5 V | 0.45 typ, 1 mA max, both | 0.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.
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.
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.
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.
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.
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.
| Part | Pins | Verdict |
|---|---|---|
| LM393A | 1OUT … 4 GND, 8 VCC | The 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 |
| LM393B | 1OUT … 4 GND, 8 VCC | TI’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 |
| LM2903 | 1OUT … 4 GND, 8 VCC | The 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?
- 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.
- 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.
- 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.
- 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.
One email a month from the bench
New circuits, lessons, part guides and calculators, on the first Sunday of each month.
Used in these lessons
Lessons that go deeper
Datasheets this page was checked against
- Texas Instruments, LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH) (SLCS005AH, October 1979, revised April 2025)
- Texas Instruments, LM339B, LM2901B, LM339, LM239, LM139, LM2901 Quad Differential Comparators (SLCS006Z) (SLCS006Z, October 1979, revised May 2025)
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.