Basic Electronics, Chapter 8: Challenge 1 solution (levels, margins and pull-ups) Formulas: NML = VIL - VOL NMH = VOH - VIH a connection works if VOH(driver) >= VIH(receiver) and VOL(driver) <= VIL(receiver) divider: Vout = Vin x R2 / (R1 + R2) rise time (10 % to 90 %) = 2.2 x R x C I2C rise time (30 % to 70 %) = 0.8473 x R x C pull-up limits: Rp(min) = (Vcc - VOL) / IOL Rp(max) = tr / (0.8473 x C) (a) Noise margins (values from the table in section 1) 74HC at 3.3 V driving a 74HC input at 3.3 V: VIL = 0.99, VIH = 2.31, VOL = 0.1, VOH = 3.2 NML = 0.99 - 0.1 = 0.89 V NMH = 3.2 - 2.31 = 0.89 V 74HC at 5 V driving a 74LS input: driver VOL = 0.1, VOH = 4.4; receiver (74LS) VIL = 0.8, VIH = 2.0 NML = 0.8 - 0.1 = 0.7 V NMH = 4.4 - 2.0 = 2.4 V works, with big margins ESP32 pin (3.3 V) driving a 74HC at 5 V: driver VOH = 2.64, VOL = 0.33; receiver VIH = 3.5, VIL = 1.5 NMH = 2.64 - 3.5 = -0.86 V NEGATIVE: fails (a HIGH may not be read as HIGH). Not allowed. ESP32 pin driving a 74HCT at 5 V: receiver VIH = 2.0, VIL = 0.8 NMH = 2.64 - 2.0 = 0.64 V NML = 0.8 - 0.33 = 0.47 V works (but keep the wire short: the margins are modest) 74LS output driving a 74HC input at 5 V: driver VOH = 2.7, VOL = 0.5; receiver VIH = 3.5, VIL = 1.5 NMH = 2.7 - 3.5 = -0.8 V fails: this is why the 74HCT family was invented. (NML = 1.5 - 0.5 = 1.0 V is fine) (b) 5 V to 3.3 V divider Target Vout = 3.3 V: R2 / (R1 + R2) = 3.3 / 5 = 0.66 -> R2 = 0.66 R1 / 0.34 = 1.94 k for R1 = 1 k. E12 values: 1.8 k -> Vout = 5 x 1.8 / 2.8 = 3.214 V (OK, below 3.3 V) 2.2 k -> Vout = 5 x 2.2 / 3.2 = 3.438 V (above 3.3 V: avoid; still under the 3.6 V absolute maximum, but with no margin) Choose R2 = 1.8 k: Vout = 3.21 V. (An E24 value, 2.0 k, would give 3.33 V.) Rise time: the source resistance seen by the pin is R1 || R2 = 1000 x 1800 / 2800 = 643 ohm. 15 pF load: 2.2 x 643 x 15e-12 = 21 ns fine for signals up to several MHz 100 pF wire: 2.2 x 643 x 100e-12 = 141 ns limits the signal to about 1 to 2 MHz; for a longer wire use a buffer chip (74LVC) instead of a divider A LOW stays 0 V; a divider only works in this direction (5 V to 3.3 V), and loads the 5 V output with 5 V / 2.8 k = 1.8 mA. (c) Open-drain bus Rp(min) = (5 - 0.4) / 3 mA = 4.6 / 0.003 = 1.53 k (smaller than this and the sensor cannot hold the wire down to 0.4 V) Rp(max) = 1 us / (0.8473 x 200 pF) = 1e-6 / 1.6946e-10 = 5.90 k (larger and the wire rises too slowly) Choose the E12 value 3.3 k (between the limits): rise time = 0.8473 x 3.3 k x 200 pF = 0.56 us current when pulled low = (5 - 0.4) / 3.3 k = 1.39 mA (well under the sensors' 3 mA) Mistaken push-pull device driving HIGH while a sensor holds the wire LOW: total resistance = 65 + 130 = 195 ohm current = 5 V / 195 = 25.6 mA (far above the sensor's 3 mA rating: it can be damaged) wire voltage = 5 V x 130 / 195 = 3.33 V neither a valid LOW (needs below VIL) nor a valid HIGH: the bus is corrupted. (the real on-resistance of the sensor output rises with current, so the real answer varies; the lesson is that two outputs fighting waste current and give an invalid level) Checklist - Always check BOTH inequalities (HIGH and LOW), and the over-voltage limit of the receiver. - 3.3 V output into a 5 V CMOS input: use a 74HCT/74AHCT at 5 V. 5 V output into a 3.3 V input: divider, 74LVC or MOSFET shifter. - Open-drain pull-up: between (Vcc - VOL)/IOL and tr/(0.8473 C). - Never connect two push-pull outputs to one wire.