unfried.
Streak:0 days XP:0

Design rules

Circuit design

The sizing equations and rules of thumb for each building block, with their limits.

54 entries in 10 units. Free to use and share.

Jump to a unit (10 units)

Unit 1 LEDs and resistors

LED resistor

R
series resistorΩ
Vsupply
supply voltageV
Vf
LED forward voltage; red about 2 V, green 2.1 V, blue and white about 3 VV
I
LED currentA

Applies: One LED or a series string; subtract every LED's Vf⁠.

Taught in Why the LED needs a resistor

E12 values and rounding toward safe

E12 resistors are 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680 and 820 Ω, and the same digits at 10× and 1/10×. For a current maximum, round R up and check it 5 % low (0.95R⁠). For a current minimum, round R down and check it 5 % high.

Taught in Round toward safe

Resistor heat

P
power in the resistorW
VR
voltage across the resistorV
I
currentA

Applies: Keep it under half the rating. 0603 is 1/10 W, 0805 1/8 W, 1206 1/4 W, on a board at 70 °C or cooler.

Taught in Resistors get hot

One resistor per LED

Parallel LEDs each need their own resistor; with a shared one, the lowest-Vf LED takes most of the current. A series string can share one if the supply is well above the sum of the Vf values.

Taught in One resistor per LED

An MCU pin in the loop

A 3.3 V output acts like 3.3 V in series with about 25 Ω (25–40 Ω on real parts). Count it in the loop and keep each pin under about 20 mA. The load sets the current, not the pin.

Taught in The pin has a resistor inside

Unit 2 Reading datasheets

Absolute maximum and operating conditions

Absolute maximum is the damage line; never design to it. Design inside the recommended operating conditions. A typical 3.3 V MCU runs VDD 3.0–3.6 V (absolute max 4.0 V), 20 mA per pin (absolute max 25 mA) and 80 mA for all pins (absolute max 120 mA).

Taught in The damage line

Typical is not a promise

Only min and max are guaranteed. For an LED current maximum use the min Vf⁠; for a current minimum use the max Vf⁠; for supply budgets use the max IDD. Label typical-based numbers as estimates.

Taught in Typical is not a promise

Every number has a condition

"VOH ≥ VDD − 0.4 V at IOH = 8 mA" says nothing about 15 mA; read the graph. A worst-case pin at 85 °C acts like 3.3 V behind about 50 Ω. Footnotes are conditions too.

Taught in Every number has a condition

Resistor derating

Pusable
power allowedW
Prated
rated powerW
T
board temperature, between 70 and 155°C

Applies: Resistors that keep full power to 70 °C and reach zero at 155 °C. Half the rating is left near 112 °C.

Taught in Every number has a condition

Pinouts

Pinouts belong to the part number, not the package. In a top view, pins count counter-clockwise from the pin 1 mark; bottom views are mirrored.

Taught in Same package, different pins

Five rows that decide

VDD operating range, VIN absolute max (VDD + 0.3 V on standard pins, more on FT pins), VIH and VIL, IDD max, and the application circuit.

Careful: A 5 V CMOS input needs VIH = 3.5 V, more than a 3.3 V output gives; 74HCT needs only 2.0 V.

Taught in Five rows that decide

Unit 3 Inputs: buttons, pull-ups, noise

Every input needs a defined level

A CMOS input is about 10 pF with under 1 µA of leakage. With no path to a rail it floats, picks up mains hum and draws extra current in sleep. This unit's MCU reads 0 at or below 0.99 V and 1 at or above 2.31 V; internal pull-ups are 30–50 kΩ.

Taught in The pin that reads your hand

Sizing a pull-up

V
released input levelV
Ileak
input leakageA
R
pull-upΩ

Applies: Keep V at or above 2.31 V, so 1 µA allows up to 990 kΩ. Pressed, it wastes 3.3 V/R⁠; 4.7–100 kΩ covers most buttons and 10 kΩ is a common default.

Taught in Sizing a pull-up

Internal pull-ups and long wires

τ
edge time constants
R
pull-upΩ
C
input and cable capacitanceF

Applies: 40 kΩ with a 3 m cable (1 nF) gives 40 µs. With a long cable, fast edge or noisy neighbor, add 4.7–10 kΩ outside.

Taught in Internal pull-ups and long wires

RC debounce

t
time to the thresholds
τ
time constant RCs
Vth
thresholdV
VDD
supplyV

Applies: Longer than the bounce, under about 20 ms. 10 kΩ and 1 µF reach 2.0 V in 9.3 ms. Follow it with a Schmitt input (up at 2.0 V, down at 1.2 V).

Taught in Debounce: RC plus Schmitt

Series resistor on a cable input

Iclamp
clamp diode currentA
Vfault
fault voltage on the cableV
VDD
supplyV
Vf
clamp diode dropV
R
series resistorΩ

Applies: Between the connector and the pin. Keep it well under the pull-up; a TVS takes the kilovolts.

Careful: The built-in clamps are for handling (about 1.3 A), not an 8 kV zap (about 30 A).

Taught in Cables, clamps and a series resistor

Unit 4 Decoupling and bypass

Dip across a wire

v
voltage dipV
L
inductance, about 1 nH per mmH
i
currentA
t
times

Applies: Fast current edges. A 10 cm wire at 10 mA/ns drops 1.0 V.

Taught in Why a chip needs local charge

Decoupling sag

ΔV
sagV
Q
charge per spikeC
C
effective capacitanceF

Applies: The cap sits at the pin. 0.4 nC from 100 nF is 4 mV.

Careful: The same cap at the far end of a wire does nothing for spikes.

Taught in Why a chip needs local charge

Placement and loop inductance

The spike loop runs cap → VDD pin → core → ground → cap, about 1 nH per mm including the ground leg. Put the cap next to the pin with a via in its ground pad. At 10 mA/ns a 2 mm loop costs about 27 mV and a 30 mm loop about 0.23 V.

Taught in Placement: loop inductance

Self-resonance

f
self-resonant frequencyHz
L
ESL; about 0.5 nH in 0402, 0.7 nH in 0603, 1.2 nH in 1206H
C
capacitanceF

Applies: Above it a cap acts as its ESL. Use 100 nF in a small package at each pin and 10 µF bulk nearby.

Taught in 100 nF close, bulk nearby

DC bias derating

X5R and X7R ceramics lose capacitance with DC voltage. This unit's 10 µF 6.3 V X5R 0603 holds 7.5 µF at 2 V, 5.5 µF at 3.3 V and 4 µF at 5 V. Datasheet minimums mean effective capacitance at the working voltage. C0G doesn't derate but stops near 0.1 µF.

Taught in DC bias: your 10 µF is 4 µF

Hot-plug spikes

Plugging into ceramic-only input caps is a step into an LC, overshooting toward twice the step. Damp it with a bulk electrolytic whose ESR is near L/C⁠, or rate the input parts for twice the step.

Taught in Hot-plug spikes

Unit 5 Grounding and layout habits

Copper resistance

R
trace resistanceΩ

Applies: 1 oz copper; 2 oz halves it. A 100 mm × 0.5 mm trace is 0.1 Ω. Copper gains about 0.4 % per °C.

Taught in Ground is a wire with resistance

Ground bounce and the star point

A heavy load's return current lifts every ground it shares copper with, by I×R plus L di/dt on fast edges. Give each heavy load its own return and join them only at the supply connector.

Taught in Ground bounce

Return current follows the signal

At DC it splits by resistance; on fast edges it runs in the copper right under the trace. A slot under a fast trace forces a detour of about 1 nH per mm. Slow signals can cross a slot.

Taught in Return current follows the signal

Trace width (IPC-2221)

I
currentA
k
0.048 outer, 0.024 innerno unit
ΔT
temperature rise°C
A
cross-section, square mils (1 oz = 1.378 mil thick)mil²

Applies: 0.5–3 oz copper, up to 35 A, rises of 10–100 °C. A first estimate; it ignores nearby planes.

Taught in Trace width and current

Layout review order

  1. Heavy returns reach the connector without crossing the MCU's ground. 2. 100 nF next to each VDD pin. 3. Unbroken plane under fast signals; crystals away from switch nodes. 4. Every power trace sized for its current.

Taught in Layout review

Unit 6 Driving loads

MOSFET for your gate voltage

P
heatW
I
drain currentA
RDS(on)
on-resistance at a Vgs the pin reachesΩ

Applies: Fully on. From 3.3 V, read the 2.5 V line; the AO3400 is 48 mΩ there.

Careful: The 2N7000 and IRF540N stay partly on at 3.3 V and overheat.

Taught in The low-side MOSFET done right

Gate resistor and pull-down

Put 100–470 Ω in series with the gate; its peak is 3.3 V/(25 Ω+RG)⁠. Add 10–100 kΩ from gate to source so the load stays off while the pin is undriven.

Taught in The low-side MOSFET done right

Flyback clamp

E
energy dumped each turn-offJ
L
coil inductanceH
I
coil currentA

Applies: With no clamp it goes into the MOSFET in avalanche. Put a diode across the coil, stripe to +; drain peak ≈ supply + diode + clamp, and a higher clamp releases faster.

Taught in Flyback diodes

Motor start current

I
stall currentA
V
supplyV
Rwinding
winding resistanceΩ

Applies: At rest, with no back-EMF. Size the switch, fuse and wiring for it, and give the motor its own wires.

Taught in Motors: start-up current and droop

High-side switching

An N-MOSFET on top with a 3.3 V gate leaves its load about 2 V. Use a P-MOSFET, source on the rail, with a small NPN or N-MOSFET pulling the gate down and 10 kΩ holding it off. Keep |Vgs| inside its rating.

Taught in High-side switching

Dead time

Turn-off lags while the gate discharges (about 150 ns for an IRLZ44N with 100 Ω). Leave dead time longer than the delay, or put a diode across each gate resistor, anode at the gate.

Taught in H-bridges and shoot-through

Unit 7 Protection

Reverse polarity

A series diode costs Vf×I⁠; at 1 A a 1N4007 drops 0.93 V and an SS34 0.42 V. A P-MOSFET with drain to the connector, source to the load and gate to ground costs about 10 mΩ. Add a 12 V gate zener on 24 V or surge-prone inputs.

Taught in Reverse polarity

Resettable fuses

Hold current is the most it promises to carry; trip current the least that's promised to trip it; between them nothing is promised. The label is the hold current, and it falls as the board warms.

Careful: A PTC is far too slow for a 1 ms surge.

Taught in Fuses and PTCs

TVS and series resistor

I
pin clamp currentA
Vclamp
TVS clamp voltageV
R
series resistorΩ

Applies: The TVS at the connector, on a short pad with a via. Contact ESD peaks at 3.75 A per kV.

Taught in ESD and TVS diodes

Back-powering through pins

A pin's clamp diode feeds VDD whenever the pin is more than about 0.6 V above it. A series resistor limits it; keep R×Cpin well under the bit time. Buffers with Ioff block it.

Taught in Back-powering through I/O pins

Inrush

Ipeak
peak current at plug-inA
V
supplyV
Rloop
cable and ESRΩ

Applies: An empty capacitor. A soft-start P-MOSFET with a gate capacitor limits it; the cap fills at I=C dV/dt⁠.

Taught in Inrush

Unit 8 Interfacing between chips

Noise margins

VOH,VOL
driver's guaranteed high and lowV
VIH,VIL
receiver's thresholdsV

Applies: Both must be ≥ 0, and the driver's supply under the input's absolute max.

Taught in Logic thresholds across voltages

Logic families

Input max is 3.6 V for a standard MCU pin (5.5 V on FT pins) and 5.5 V for 74HC and 74HCT.

FamilyHigh, VOH / VIHLow, VOL / VIL
3.3 V MCU2.9 V / 2.31 V0.4 V / 0.99 V
74HC at 5 V4.4 V / 3.5 V0.1 V / 1.5 V
74HCT at 5 V4.4 V / 2.0 V0.1 V / 0.8 V

Taught in Logic thresholds across voltages

Divider level shifter

τ
time constants
R1,R2
divider resistorsΩ
Cpin
pin capacitanceF

Applies: One way, 5 V down to 3.3 V; 10–90 % takes 2.2τ. Fine for a UART, not for MHz clocks unless the resistors are small.

Taught in Divider level shifters

BSS138 bidirectional shifter

Gate to the low supply, source to the low side, drain to the high side, a pull-up on each side. The MOSFET passes lows only; each high comes from its own pull-up.

Taught in The MOSFET bidirectional shifter

I²C pull-up window

tr
rise time, 30 % to 70 %s
Rp
pull-upΩ
Cb
bus capacitanceF
VDD
bus supplyV

Applies: Rise limits are 1000 ns (standard), 300 ns (fast) and 120 ns (Fm+). At 3.3 V, 200 pF and fast mode the window is 967 Ω to 1.77 kΩ.

Careful: At 400 pF the window closes; cut capacitance, slow down or use Fm+ parts.

Taught in Sizing I²C pull-ups

ADC kickback

ΔV
step when sampling startsV
V
input voltageV
CS
sample capacitorF
Cpin
capacitor on the pinF

Applies: A high-resistance divider into an ADC. Leakage moves the pin by Ileak⋅(R1∥R2)⁠, so keep the divider current about 100× it.

Taught in Analog front end into an ADC

Unit 9 Power supply design

Power budget

Peak is every load that can be on at once; it sizes the regulator (rated at least 1.25× the peak) and the battery. Average is each load times its on fraction; it sets battery life.

Taught in The power budget

LDO heat and junction temperature

P
heatW
Vin
inputV
Vout
outputV
I
load currentA
Tj
junction temperature°C
Ta
ambient°C
θJA
thermal resistance; SOT-23 200, SOT-223 60 °C/W in this unit°C/W

Applies: Check dropout at the lowest input, heat at the highest input and hottest box, and Iq if it sleeps. Limit about 125 °C.

Taught in Choosing an LDO

Buck efficiency

η
efficiencyno unit
Pout
output powerW
Pfixed
fixed switching lossW
I
currentA
R
resistive lossΩ

Applies: Light-load mode (PFM) cuts the fixed loss at mA loads, at the cost of ripple; force PWM on noise-sensitive boards.

Taught in Choosing a buck

The hot loop

Input cap → VIN → switch → diode or low-side switch → ground carries the jumping current; budget 1 nH per mm. Put the input cap and diode against the IC, with at least 10 µF in and 22 µF out.

Taught in Buck layout: the hot loop

Sleep budget

Asleep, every path from battery to ground counts. Switch or enlarge dividers, pull lines the way they rest, drive LEDs from a pin, and pick a µA-Iq regulator.

Taught in Battery-powered: the sleep budget

Unit 10 Design review and capstone

Readable schematics

Use T-junctions, never 4-way points. Net labels join by exact text, so 3V3 and +3V3 are different nets. Supplies at the top, grounds pointing down, signals left to right.

Taught in Schematics people can read

Review checklist

PassQuestion
Power inPolarity protected? What does it cost?
RailsRegulator sized for the peak? A small cap at every VDD pin?
Reset stateWhat does each load do while its pin is an input?
Pull-upsInside the rise-time and sink-current window?
LoadsLED resistors, flyback diodes the right way round?
RatingsDerated for the worst case?

Taught in The review checklist

Derating rules

Capacitor rating at least 1.5× the working voltage (2× for tantalum); resistor power at most 50 % of rating; current at most 70–80 %. Design to the operating range, never to absolute max.

Taught in Derating and margins

Bring-up order

Inspect; measure ohms from each rail to GND unpowered; power from a bench supply with the current limit a little above the expected draw; check each rail; blink; then one peripheral at a time.

Careful: Current pinned at the limit with volts near zero is a short.

Taught in Bring-up