C711 of 57
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C7 · Lesson 11 · Interfacing logic to the world

Driving LEDs, crossing between 5 V and 3.3 V, and how many inputs one output can feed

A logic output is not an ideal voltage source: lesson 1 showed its high level sagging as it sources current, and lesson 10 let several outputs share a wire. Real boards connect logic to LEDs, to chips on a different supply, and to more inputs than the datasheet example shows. A 5 V signal wired straight into a 3.3 V chip can feed current through its protection diodes and latch it up or slowly damage it; a 3.3 V output may not reach a 5 V CMOS input's high threshold at all. Each crossing has a small, calculable fix: a resistor, a divider, a transistor, or a buffer with the right thresholds.

  • A 5 V square wave drives a 3.3 V chip's input through a resistive divider (1.8 kΩ over 3.3 kΩ). The capacitor is the input's and the wiring's capacitance.
  • The divider scales 5 V to about 3.2 V, safely inside the 3.3 V chip's range. But it also has a Thevenin resistance, and with the input capacitance that slows the edges.
  • Raise both resistors to save power and watch the edges round off. At some point a fast signal no longer reaches its levels before it changes.

Predict

A 3.3 V microcontroller's output (guaranteed at least 2.4 V high) drives a 5 V chip from the 74HC family, whose inputs need 3.5 V to read high. What happens?

Name it

Driving an LED

A logic output can source or sink a few milliamps. Size the series resistor from the output's guaranteed level at that current:

R=VOH−VFILED(sourcing),R=VDD−VF−VOLILED(sinking)

Check the chip's total current limit too: a port of eight LEDs at 10 mA each may exceed it. For more current, use the output to switch a transistor.

Higher voltage into a lower-voltage input

Inputs have protection diodes to their supply. A 5 V signal into a 3.3 V input turns on the upper diode, pushing current into the 3.3 V rail. Datasheets limit this injection current, often to 1 mA or so, and a chip that's powered off can be powered through its inputs. Options:

  • A series resistor limits the injected current: R≥(Vin−VDD−Vdiode)/Imax.
  • A divider scales the level: Vout=VinR2/(R1+R2), with Thevenin resistance R1‖R2 charging the input capacitance, so edges rise with τ=(R1‖R2)C and a 10 to 90% time of 2.2τ.
  • A 5 V-tolerant input, which some chips offer on chosen pins.

Lower voltage into a higher-voltage input

The output's high level must exceed the input's VIH:

  • Use a part with TTL-compatible thresholds (74HCT, 74ACT): VIH = 2.0 V on a 5 V supply.
  • Use an open-drain output with a pull-up to the higher supply (lesson 10).
  • Use a MOSFET level shifter: an NMOS with its gate at the lower supply and pull-ups on both sides. It works in both directions, which suits I²C, but its rising edges are only as fast as the pull-ups can charge the bus: tr≈2.2RC.

Noise margins and fan-out

The noise margins between a driver and a receiver are NMH=VOH−VIH and NML=VIL−VOL; both must be positive, with room for ground noise. Fan-out is how many inputs one output can drive. For families with real input currents it's

N=min⁡(IOL|IIL|,IOHIIH)

For CMOS inputs, which draw almost no DC current, the limit is capacitance: each input adds a few picofarads, and the edges slow down.

Worked example

A 3.3 V microcontroller pin holds at least 2.9 V while sourcing 8 mA. It drives a red LED that drops 2.0 V at that current. What resistor, and what current with the nearest E12 value above?

Show the solution
  1. Size the resistor. Use the guaranteed high level, 2.9 V: R=2.9−2.08mA=112Ω
  2. Round up to E12. The next E12 value up is 120 Ω, giving about 2.9−2.0120Ω=7.5mA (a little more in practice, since the pin's high level rises as its current falls).
  3. Why the guaranteed VOH matters. With 3.3 V the calculation gives 162 Ω, and the LED would get less current than planned on a weak part, but never more.

Answer 112 Ω; the E12 value above it, 120 Ω, gives about 7.5 mA.

Worked example

A 5 V sensor output drives a 3.3 V microcontroller pin with 10 pF of input and trace capacitance. Design a divider from E12 values, and find its edge time. Compare a single series resistor that limits injection to 1 mA, with the clamp at 3.6 V.

Show the solution
  1. Divider output. A 1.8 kΩ over 3.3 kΩ divider gives V=5×3.35.1=3.24V inside the 3.3 V range.
  2. Divider edge time. Its Thevenin resistance is 1.8‖3.3 = 1.16 kΩ, so τ=1.16kΩ×10pF=11.6ns and the 10 to 90% rise is 25.6 ns: fine up to a few megahertz.
  3. Divider current. It draws 5/5.1 kΩ ≈ 1 mA whenever the signal is high.
  4. Series resistor. R≥5−3.61mA=1.4kΩ With 1.5 kΩ, τ = 15 ns.
  5. Series resistor's cost. It draws nothing while the signal is low, but while it's high it relies on the clamp diode carrying up to 0.9 mA into the 3.3 V rail, which the datasheet must allow and the rail must absorb.

Answer 1.8 kΩ over 3.3 kΩ gives 3.24 V and a 25.6 ns rise, drawing about 1 mA while high; a 1.5 kΩ series resistor gives τ = 15 ns but sends up to 0.9 mA through the clamp diode while high.

Worked example

An I²C bus between a 3.3 V and a 5 V device uses a MOSFET level shifter with 10 kΩ pull-ups on each side. With 50 pF on the 5 V side, what's the rise time there, and is it fast enough for 100 kHz I²C (1 µs maximum) and 400 kHz (300 ns)?

Show the solution
  1. Rise time with 10 kΩ. tr≈2.2RC=2.2×104×50×10−12=1.1μs slightly too slow even for 100 kHz.
  2. With 4.7 kΩ. A 4.7 kΩ pull-up gives 0.52 µs, fine at 100 kHz.
  3. For 400 kHz. It needs about 2.2 kΩ or less (0.24 µs), at the cost of more current when the line is low: 5V2.2kΩ=2.3mA within the 3 mA I²C devices must sink.

Answer 1.1 µs, slightly too slow even for 100 kHz; 4.7 kΩ (0.52 µs) works at 100 kHz, and 400 kHz needs about 2.2 kΩ or less.

Check

An output guaranteed at 2.9 V high while sourcing 10 mA drives an LED with 1.8 V across it. What series resistor sets that current?

Write units the way you normally would: 1.5 Ω, 1500 mΩ and 0.0015 kΩ are the same answer.

Check

A 5 V signal drives a 1.8 V chip's input through a series resistor. The clamp diode conducts at 0.3 V above the supply, and the datasheet allows 2 mA of injection. What's the smallest safe resistor?

Write units the way you normally would: 1.5 Ω, 1500 mΩ and 0.0015 kΩ are the same answer.

Check

A 5 V signal drives a divider of 1.8 kΩ over 2.2 kΩ into an input with 22 pF.

(a)

What's the high level at the input?

Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.

(b)

What's its 10 to 90% rise time?

Check

A driver guarantees VOH = 2.9 V and VOL = 0.5 V; the receiver needs VIH = 2 V and VIL = 1.5 V. What's the high-level noise margin? (Negative means it fails.)

Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.

Check

An output can sink 8 mA low and source 1 mA high. Each input it drives draws 0.1 mA low and 40 µA high. How many inputs can it drive?

Check

A pull-up of 4.7 kΩ charges a bus of 50 pF. What's the 10 to 90% rise time, in µs?

Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.

Check

A 3.3 V FPGA must drive a 5 V 74HC-family counter's clock input. Which fix is cleanest?

Check

Choose a divider from E24 values (10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91, times any power of ten from 100 Ω to 1 MΩ) that brings Vin = 12 V down to at most Vout_max = 3.3 V and as close as possible to Vout = 3 V, with Thevenin resistance at most Rmax = 50 kΩ. Set R1, R2 (ohms) and v (the output voltage). Break ties by the smaller Thevenin resistance.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

A 5 V Arduino's output is wired straight to a 3.3 V sensor's input. The sensor works, but its 3.3 V rail measures 3.6 V whenever the Arduino's output is high and the sensor's own regulator is lightly loaded. Explain what's happening and how to fix it.

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.