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.
Four output types: which transistor exists, where does the current go?
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.
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.
Three devices, one line: whoever pulls, the line drops
- 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.
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.
I²C bus: pull-up, capacitance and speed
| Mode | fSCL | tr(max) | IOL @ 0,4 V | Cb(max) | Note |
|---|---|---|---|---|---|
| Standard-mode (Sm) | 100 kHz | 1000 ns | 3 mA | 400 pF | Most forgiving mode |
| Fast-mode (Fm) | 400 kHz | 300 ns | 3 mA | 400 pF | Default for most sensors |
| Fast-mode Plus (Fm+) | 1 MHz | 120 ns | 20 mA | 550 pF | Only if every device supports Fm+ |
| SMBus | 10–100 kHz | 1000 ns | 4 mA (high power) | 400 pF | Low-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.
3.3 V MCU → 24 V PLC input: open-collector level shifter
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:
- Transistor onI = 24 V / 2.2 kΩ11 mA
- Resistor lossP = 24² / 22000.26 Wexceeds a 1/4 W resistor
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.
- Series resistorR = (3.3 − 2.0 − 0.3) V / 5 mA200 Ω
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.
| Part | Output | Max voltage | Sink current | Typical pull-up / note |
|---|---|---|---|---|
| LM393 / LM339 (comparator) | NPN open-collector | 36 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 V | CTR 50–600 % | 4.7–10 kΩ; slow (tr in µs), slower with larger R |
| Hall switch, encoder | NPN OC / open-drain | 24–30 V | ~20–25 mA | Sensor on 5–24 V, pull-up on the MCU side; active-low |
| ULN2003A / ULN2803A | Darlington OC, 7/8 channels | 50 V | 500 mA/channel | Relays, solenoids, steppers; internal flyback diodes to COM; VCE(sat) ≈ 0.9–1.3 V |
| Regulator PG, charger STAT | Open-drain | ~6–20 V | a few mA | 10–100 kΩ; STAT pins can sink an LED directly |
Typical datasheet values; they vary by vendor.
ULN2803A with a 24 V relay: on-time and decay through the COM diode
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.
3-wire sensor → PLC input; try the 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 voltage | ON current | OFF voltage | OFF current | Use |
|---|---|---|---|---|---|
| Type 1 | 15–30 V | 2–15 mA | ≤ 5 V | ≤ 0.5 mA | Mechanical contacts, 3-wire sensors |
| Type 2 | 11–30 V | 6–30 mA | ≤ 5 V | ≤ 2 mA | 2-wire sensors with leakage |
| Type 3 | 11–30 V | 2–15 mA | ≤ 5 V | ≤ 1.5 mA | Modern 2- and 3-wire sensors (most common) |
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.
Events on a 12 V vehicle rail
- 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
| Type | Current | Needs | Speed | Typical uses | Pitfalls |
|---|---|---|---|---|---|
| Push-pull | Sources + sinks | Nothing | Both edges fast | GPIO, SPI, UART, gate drive | Tying two outputs = short circuit; pull-up to a higher voltage = back-feed |
| Open-drain | Sinks | Pull-up | Fast fall, R·C rise | I²C, INT̅, RESET̅, level shifting, LEDs | Pin abs-max (5 V-tolerant?), pull-up too large/small |
| Open-collector | Sinks | Pull-up | Fast fall, R·C rise; saturation storage delay | LM393, PC817, Hall, ULN2803, NPN sensors | VCE(sat) 0.1–1.3 V; logic inverts |
| Open-emitter | Sources | Pull-down / grounded load | Fast rise, R·C fall; no saturation | ECL/PECL, emitter followers, PNP-style sensors/outputs | Loses VBE; VOH too low at low supply |
| Open-source | Sources | Pull-down | Fast rise, R·C fall | Rare; high-side switches in power | An 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.
- Lower bound (current)Rmin = (3.3 − 0.4) V / 3 mA967 Ω
- Upper bound (speed)Rmax = 300 ns / (0.8473 · 200 pF)1.77 kΩ
- Choicemiddle of the window1.5 kΩ
- Rise timetr = 0.8473 · 1.5 kΩ · 200 pF254 nsbelow 300 ns; 1.8 kΩ would give 305 ns
- LOW currentI = 3.3 V / 1.5 kΩ2.2 mAbelow the 3 mA limit
- Resistor lossP = 3.3² / 15007.3 mW
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?
- Power the sensor from 12 V and GND. The grounds must be common.
- 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.
- LOW currentI = 3.3 V / 10 kΩ0.33 mAfar below the sensor limit
- LOW thresholdVIL = 0.3 · 3.3 V0.99 VVOL ≈ 0.1–0.2 V, comfortably below
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.
- Coil currentI = (24 − 0.8) V / 1100 Ω21 mA
- Loss per channelP = 0.8 V · 21 mA17 mW
- All 8 channelsP = 8 · 17 mW0.135 W
- Temperature riseΔT = 0.135 W · 65 °C/W≈ 9 °CSOIC-18; check θJA in the datasheet
- 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:
- Loss per channelP = 1.2 V · 0.25 A0.3 W
- All 4 channelsP = 4 · 0.3 W1.2 W
- Temperature riseΔT = 1.2 W · 65 °C/W≈ 78 °Cmarginal at 50 °C ambient
Next: driving the transistor behind these outputs yourself. The BJT drive and MOSFET drive chapters size the base resistor and the gate drive.