Output types: push-pull, open-drain, open-collector, open-emitter

A normal output has two transistors: one pulls up, one pulls down. An “open” output has only one of them; a resistor or the load itself completes the missing half. Level shifting, I²C, shared lines and 24 V sensors all rely on that difference.

FundamentalsChapter 04b

What does “open” mean?

A CMOS output has two stacked MOSFETs. The upper P-MOS connects the pin to VDD, the lower N-MOS connects it to GND. This is a push-pull output (the older BJT name is totem-pole).

Remove the upper transistor and the output can only pull down. Writing a 1 leaves the pin connected to nothing (Hi-Z). A pull-up resistor sets the level.

Push-pull

Two transistors. Sources and sinks, fast both ways. No external resistor. Two outputs must never be tied together.

Open-drain

Only the low N-MOS. Sinks current. Needs a pull-up. I²C, interrupt and reset lines.

Open-collector

Same idea with an NPN: the collector is the pin. Sinks current. LM393, optocouplers, Hall sensors, ULN2803.

Open-emitter

Only the upper NPN. Sources current. Needs a pull-down or a grounded load. Loses one VBE.

Open-source rare

Only an upper MOSFET. Rare as a logic output; its power-side cousin is the high-side switch.

Lab

Four output types: which transistor exists, where does the current go?

Model: push-pull Ron = 30 Ω (P) / 20 Ω (N), open-drain Ron = 25 Ω. Open-collector NPN: VCE ≈ 0.05 V + I·4 Ω, at most ~100 mA. Open-emitter: base at VS, VBE ≈ 0.65 V @ 1 mA. Valid levels: VOL ≤ 0.3·VS, VOH ≥ 0.7·VS. Copper dots are load current.
Open-drain / open-collector:   VOL = VPU · Ron / (R + Ron)    Isink = (VPU − VOL) / R    PR = (VPU − VOL)² / R
Open-emitter:   VOH = VB − VBE ≈ VS − 0,7 V    Isource = VOH / RPD The transistor’s edge is fast; the resistor’s edge follows R·C and is slow. A smaller resistor speeds up that edge but wastes current while the transistor is on.

Sinking and sourcing

  • Sinking: current flows from the load into the pin and through the transistor to GND. The other end of the load is at the positive supply.
  • Sourcing: current flows from the supply through the transistor out of the pin into the load. The other end of the load is at GND.
  • Open-drain/collector only sinks, open-emitter only sources. Push-pull does both.
Do not pull a push-pull output up to a higher voltage Pull a 3.3 V push-pull pin up to 5 V and, with the pin high, the P-MOS body diode and the ESD diode conduct. Current flows from 5 V into the 3.3 V rail and back-feeds the regulator. To pull up to another voltage, set the pin to open-drain (it must be 5 V-tolerant) or use an external transistor.

Wired-AND: one wire, many devices

Several open-drain outputs can share one wire and one pull-up. If none conducts, the line is HIGH; if any one conducts, it is LOW. No transistor pushes the line up, so nothing can short.

In positive logic this is an AND. With active-low signals it reads as an OR, which is why both names are used.

Lab

Three devices, one line: whoever pulls, the line drops

VDD = 3.3 V, RP = 4.7 kΩ, N-MOS Ron = 25 Ω, P-MOS Ron = 30 Ω. Red dots are contention current. The plot shows the last 6 seconds; dashed lines are VIL = 0.3·VDD and VIH = 0.7·VDD.
  • I²C / SMBus: SDA and SCL are open-drain. Arbitration and clock stretching only work because of wired-AND.
  • Interrupt lines (INT̅, ALERT̅): many sensors share one MCU pin. When the line falls, the MCU polls who asked.
  • Reset lines (nRST): a supervisor, the debugger and a button can all pull the same line safely. Most MCUs’ nRST pin is already open-drain.
  • Power good / fault: a shared PG line is HIGH only when every regulator is good.

Choosing I²C pull-ups: rise time and current

Two limits set the pull-up. Too large a resistor slows the rising edge. Too small a resistor exceeds IOL when LOW, and VOL climbs above 0.4 V.

The transistor pulls the falling edge quickly. The rising edge is the pull-up charging the bus capacitance: an RC curve.

tr (30 % → 70 %) = R·C·ln(0,7/0,3) = 0,8473 · R · C
Rmax = tr(max) / (0,8473 · Cb)     Rmin = (VPU − VOL(max)) / IOL I²C specification (NXP UM10204): VOL ≤ 0.4 V @ IOL = 3 mA (Sm/Fm), 20 mA (Fm+). R must lie between Rmin and Rmax. If the window closes, reduce capacitance, lower the speed or use a bus buffer.
Lab

I²C bus: pull-up, capacitance and speed

Yellow trace (CH1) is the bus voltage; the dashed blue trace is the ideal SCL (50 % duty). The low side is modelled as Ron = 0.4 V / IOL. tr is the 0.3·VPU → 0.7·VPU time. The lower plot is the allowed resistor window for the chosen C.
ModefSCLtr(max)IOL @ 0,4 VCb(max)Note
Standard-mode (Sm)100 kHz1000 ns3 mA400 pFMost forgiving mode
Fast-mode (Fm)400 kHz300 ns3 mA400 pFDefault for most sensors
Fast-mode Plus (Fm+)1 MHz120 ns20 mA550 pFOnly if every device supports Fm+
SMBus10–100 kHz1000 ns4 mA (high power)400 pFLow-power class 350 µA; 35 ms timeout

Starting values (short on-board bus, ≤ 100 pF, 3.3 V):

  • 100 kHz: 4.7–10 kΩ
  • 400 kHz: 2.2–4.7 kΩ
  • Module pull-ups add in parallel: three 4.7 kΩ = 1.57 kΩ.
  • The MCU’s internal 30–50 kΩ pull-up is almost never enough.

Level shifting and LED driving

An open-drain output’s HIGH is whatever the pull-up goes to, not its own supply. A 3.3 V MCU can drive 5 V logic by pulling up to 5 V. With an external transistor the same works for 12 V or 24 V.

  • The logic usually inverts: MCU 1 → transistor on → output LOW.
  • The off transistor sees the full pull-up voltage.
The pin’s absolute maximum voltage Open-drain mode does not make a pin high-voltage tolerant. The absolute maximum is usually VDD + 0.3 V; only 5 V-tolerant pins (“FT” on STM32) survive 5.5 V. Above 5 V use an external N-MOS (2N7002, BSS138) or NPN (MMBT3904).
Lab

3.3 V MCU → 24 V PLC input: open-collector level shifter

PLC input: a resistor drawing the chosen current at 24 V (Rin = 24 V / Iin) plus its optocoupler LED; many real inputs are current-limited. Thresholds IEC 61131-2 Type 1: ON ≥ 15 V and ≥ 2 mA, OFF ≤ 5 V. NPN: MMBT3904, RB = 1 kΩ, βmin ≈ 30. N-MOS: BSS138, RDS(on) ≈ 1.3 Ω @ 3.3 V.

Driving a PLC input through a pull-up is a poor compromise. The pull-up and the input resistance form a voltage divider. Keeping HIGH above 15 V needs a small RPU, but a small resistor gets hot:

VPU24 VRPU2.2 kΩ
  1. Transistor onI = 24 V / 2.2 kΩ11 mA
  2. Resistor lossP = 24² / 22000.26 Wexceeds a 1/4 W resistor
Driving a PLC input through a pull-up is wasteful. Use the sourcing output the input expects.

The clean fix is a sourcing output: a PNP/P-MOS high-side or a ready-made high-side switch IC. No current is wasted and the logic does not invert.

Driving an LED by sinking

The LED’s anode goes through a resistor to the positive supply, its cathode to the pin. The LED lights when the pin is LOW: active-low. Older MCUs (8051, some AVRs) could sink more than source, so classic circuits do it this way.

R = (VLED+ − VF − VOL) / ILED
VLED+3.3 VVF2.0 V (red)VOL0.3 VILED5 mA
  1. Series resistorR = (3.3 − 2.0 − 0.3) V / 5 mA200 Ω
Use 200 Ω. The pin sinks only 5 mA.

Careful: if the LED goes to 5 V but the pin is 3.3 V push-pull, 1.7 V remains across LED and resistor even with the pin HIGH. A red LED glows faintly and current flows into the pin to VDD.

Open-collector parts

Many ICs make their output open-collector on purpose. The output can be pulled up to whatever the receiver wants, and lines can be shared.

PartOutputMax voltageSink currentTypical pull-up / note
LM393 / LM339 (comparator)NPN open-collector36 V≥ 6 mA (typ. 16 mA)4.7–10 kΩ to 3.3 V, even with a 12 V supply
PC817 (optocoupler)Phototransistor (OC)VCEO 35 VCTR 50–600 %4.7–10 kΩ; slow (tr in µs), slower with larger R
Hall switch, encoderNPN OC / open-drain24–30 V~20–25 mASensor on 5–24 V, pull-up on the MCU side; active-low
ULN2003A / ULN2803ADarlington OC, 7/8 channels50 V500 mA/channelRelays, solenoids, steppers; internal flyback diodes to COM; VCE(sat) ≈ 0.9–1.3 V
Regulator PG, charger STATOpen-drain~6–20 Va few mA10–100 kΩ; STAT pins can sink an LED directly

Typical datasheet values; they vary by vendor.

Animation

ULN2803A with a 24 V relay: on-time and decay through the COM diode

Coil: 24 V, 1.1 kΩ, L ≈ 1 H (τ ≈ 0.9 ms). VCE(sat) ≈ 0.8 V, COM diode VF ≈ 0.8 V. At turn-off the coil current circulates through the COM diode; the output is clamped at 24 V + VF. Without COM connected, the spike exceeds the 50 V rating.

For more on inductive loads see the inductive loads chapter.

Open-emitter: emitter follower, ECL and “PNP” sensors

An open-emitter output has only the upper NPN; the emitter is the pin. The transistor is an emitter follower: the output sits one VBE (~0.7 V) below the base and sources current. A pull-down or a grounded load provides LOW.

The transistor never saturates, so it is very fast. That is why ECL and LVPECL clock drivers use open-emitter outputs: ~800 mV swing, 50 Ω termination to VCC − 2 V.

What is an industrial “PNP” sensor?

A PNP sensor’s output is the collector of a PNP whose emitter sits at +24 V. It plays the open-emitter role: it only drives towards +24 V (sourcing). An NPN sensor is a classic open-collector (sinking).

Because the PNP saturates, the drop is not a VBE; it is usually specified as ≤ 2 V.

Industrial 24 V: PNP (sourcing) vs NPN (sinking)

Proximity sensors are usually 3-wire:

  • Brown (BN): +24 V
  • Blue (BU): 0 V
  • Black (BK): signal

A PNP sensor connects the black wire to +24 V on detection; the PLC input carries the current to 0 V (sink input). An NPN sensor pulls the black wire to 0 V; the other end of the input is at +24 V (source input).

The input type must match the sensor. Many PLCs select it by tying the group common (COM/1M) to 0 V or to 24 V.

Lab

3-wire sensor → PLC input; try the fault

Sensor output drop 2 V, PLC input 4.7 kΩ (≈ 4.7 mA at 24 V). Input voltage is measured across the input terminals (PNP: I0.0–M, NPN: L+–I0.0). Fault: the black wire is crushed onto chassis tied to 0 V. Industrial sensor outputs are short-circuit protected.
PNP fails safe on a wiring fault
  • If the signal wire touches earthed chassis, a PNP input goes OFF: the machine stops on the safe side.
  • With NPN the same fault turns the input ON: the PLC sees an object that is not there.
  • Outputs work the same way: a short to chassis cannot open a sourcing-driven valve.
  • Europe prefers PNP; NPN is still common in Japan. Check the type code when ordering.
IEC 61131-2 (24 V DC)ON voltageON currentOFF voltageOFF currentUse
Type 115–30 V2–15 mA≤ 5 V≤ 0.5 mAMechanical contacts, 3-wire sensors
Type 211–30 V6–30 mA≤ 5 V≤ 2 mA2-wire sensors with leakage
Type 311–30 V2–15 mA≤ 5 V≤ 1.5 mAModern 2- and 3-wire sensors (most common)
“24 V” really means 18–30 V and more Use 40–60 V class transistors, a TVS at the input (e.g. SMBJ33A), series resistance and reverse-polarity protection. IEC 61131-2 expects 19.2–30 V operation; in the field, cables and coils add spikes of tens of volts. A 30 V MOSFET dies at the first inductive spike.

Automotive 12 V: the battery is not “12 V”

A car’s “12 V” rail wanders between 6 V and over 35 V. Design for the events, not the nominal value.

  • Engine running: 13.5–14.4 V. Normal range 9–16 V.
  • Cold crank: dips to ~6 V, lower in bad conditions.
  • Load dump: the battery cable comes off and a pulse lasts hundreds of ms. Unsuppressed 80–100 V, centrally clamped ~35 V (ISO 16750-2 Test B).
  • Others: reverse battery (−14 V), jump start (24 V, 1 min), ISO 7637-2 fast pulses.
Animation

Events on a 12 V vehicle rail

Time axis is illustrative; the events happen separately. Green band: 9–16 V. Dashed grey: unclamped load dump (~90 V); copper: clamped (~35 V). A 40 V MOSFET survives with little margin, 60 V is safe. Reverse battery needs a series diode, a P-MOS or an ideal-diode controller.
  • High-side is preferred. The body is the negative return. A wire touching the body cannot switch the load on, and an off load sits at 0 V, which reduces corrosion.
  • Smart high-side switches (Infineon PROFET, ST VN/VNQ, TI TPS1H/TPS2H): integrate the N-MOS, charge pump, current limit, thermal shutdown and current sense. The MCU drives one pin and reads back faults.
  • Low-side is still used for injectors and some solenoids and relays. Both ends of the load go to the ECU.
  • Discrete design: VDS ≥ 40 V (preferably 60 V), AEC-Q101 parts, a TVS at the input, reverse-polarity protection. More in topologies and overcurrent.

Comparison

TypeCurrentNeedsSpeedTypical usesPitfalls
Push-pullSources + sinksNothingBoth edges fastGPIO, SPI, UART, gate driveTying two outputs = short circuit; pull-up to a higher voltage = back-feed
Open-drainSinksPull-upFast fall, R·C riseI²C, INT̅, RESET̅, level shifting, LEDsPin abs-max (5 V-tolerant?), pull-up too large/small
Open-collectorSinksPull-upFast fall, R·C rise; saturation storage delayLM393, PC817, Hall, ULN2803, NPN sensorsVCE(sat) 0.1–1.3 V; logic inverts
Open-emitterSourcesPull-down / grounded loadFast rise, R·C fall; no saturationECL/PECL, emitter followers, PNP-style sensors/outputsLoses VBE; VOH too low at low supply
Open-sourceSourcesPull-downFast rise, R·C fallRare; high-side switches in powerAn N-MOS needs a gate above the supply

Worked examples

1 · Which pull-up for a 3.3 V, 200 pF, 400 kHz I²C bus?

The resistor must sit between the current limit and the rise-time limit.

VPU3.3 VCb200 pFfSCL400 kHz (Fm)tr(max)300 nsIOL3 mA
  1. Lower bound (current)Rmin = (3.3 − 0.4) V / 3 mA967 Ω
  2. Upper bound (speed)Rmax = 300 ns / (0.8473 · 200 pF)1.77 kΩ
  3. Choicemiddle of the window1.5 kΩ
  4. Rise timetr = 0.8473 · 1.5 kΩ · 200 pF254 nsbelow 300 ns; 1.8 kΩ would give 305 ns
  5. LOW currentI = 3.3 V / 1.5 kΩ2.2 mAbelow the 3 mA limit
  6. Resistor lossP = 3.3² / 15007.3 mW
Use 1.5 kΩ pull-ups. Remove hidden module pull-ups or include their parallel value.

You can dial the same values into the I²C lab above.

2 · How to connect a 12 V-powered NPN Hall sensor to a 3.3 V MCU?
  1. Power the sensor from 12 V and GND. The grounds must be common.
  2. Tie the pull-up to 3.3 V, not 12 V. With a 12 V pull-up the MCU pin sees 12 V and pumps current through its ESD diode into the 3.3 V rail.
VPU3.3 VR10 kΩSensor sink≤ 20 mA
  1. LOW currentI = 3.3 V / 10 kΩ0.33 mAfar below the sensor limit
  2. LOW thresholdVIL = 0.3 · 3.3 V0.99 VVOL ≈ 0.1–0.2 V, comfortably below
A 10 kΩ pull-up to 3.3 V is enough. The output is active-low: you read 0 when the magnet is present.

For cables over 1 m, drop R to 2.2–4.7 kΩ. Add a series 1 kΩ and 1 nF to GND at the pin (τ = 1 µs). Use a Schmitt-trigger input if possible.

3 · Can a ULN2803A drive a 24 V relay coil?

A Darlington drops ~1 V, so we check how hot the package gets with all eight channels on.

V24 VCoil1.1 kΩVCE(sat)0.8 VθJA65 °C/W
  1. Coil currentI = (24 − 0.8) V / 1100 Ω21 mA
  2. Loss per channelP = 0.8 V · 21 mA17 mW
  3. All 8 channelsP = 8 · 17 mW0.135 W
  4. Temperature riseΔT = 0.135 W · 65 °C/W≈ 9 °CSOIC-18; check θJA in the datasheet
The ULN2803A drives these relays easily. Even with all 8 on, it warms by only 9 °C.
  • Input: there is an internal 2.7 kΩ series resistor; 3.3 V gives ≈ 0.7 mA of base current. The datasheet asks only 2.7 V even at 250 mA, so 3.3 V logic is enough.
  • COM: tie it to +24 V. At turn-off the output clamps at ≈ 25 V, below the 50 V rating.
  • Faster release: add an ~18 V zener between COM and +24 V. The clamp becomes ≈ 43 V, still below 50 V.

The same check for a 24 V / 250 mA solenoid gives a different answer:

I250 mAVCE(sat)1.2 VChannels4θJA65 °C/W
  1. Loss per channelP = 1.2 V · 0.25 A0.3 W
  2. All 4 channelsP = 4 · 0.3 W1.2 W
  3. Temperature riseΔT = 1.2 W · 65 °C/W≈ 78 °Cmarginal at 50 °C ambient
The ULN2803A is marginal for these solenoids. Use a low-RDS(on) N-MOS: 3 mW per channel at 50 mΩ.

Next: driving the transistor behind these outputs yourself. The BJT drive and MOSFET drive chapters size the base resistor and the gate drive.