If you need a stable, low-cost circuit current source for bench testing, LED driving, or sensor biasing in the 10mA to 100mA range, the definitive default choice is a TL431 shunt regulator paired with a 2N3904 NPN transistor. While the LM317 is famous for this role, it requires nearly 3V of dropout headroom just for the regulator, plus the load voltage. The TL431 topology operates with significantly lower headroom, offers superior thermal stability compared to discrete Zener diodes, and costs pennies. Below is the complete design framework, node-by-node topology, and breadboard verification sequence to build a precision 20mA source.

The Decision Tree: Which Current Source Topology Wins?

Before wiring anything, you must match your load requirements to the correct topology. A naive resistor-and-voltage-source approach fails the moment your load resistance changes or your supply sags. Use this decision matrix to select your architecture.

Topology Target Current Min Headroom Voltage Thermal Drift Verdict
TL431 + NPN BJT 5mA – 100mA ~3.5V + V_load Very Low (50 ppm/°C) DEFAULT PICK for general bench/DIY use.
LM317 (3-terminal) 100mA – 1.5A ~3.0V (regulator) + V_load Low Choose only for high-current (>100mA) loads.
Op-Amp + MOSFET 1μA – 5A ~1.0V + V_load Ultra-Low (Depends on Op-Amp) Choose for ultra-precision lab equipment or <1mA micro-currents.
Simple Resistor N/A High High Never use. Current varies wildly with load and temperature.

Topology Deep-Dive: TL431 and NPN BJT (Node-by-Node)

The TL431 is an adjustable shunt regulator that acts as a precision voltage reference. By locking the voltage across a sense resistor, we lock the current through it—and consequently, through the load. Here is the exact node mapping for the circuit:

  • V_IN: Main DC supply (e.g., 12V). Must be at least 3.5V plus your expected load voltage.
  • Node_BIAS: The junction connecting the bias resistor (R_BIAS), the TL431 Cathode, and the Base of the NPN transistor (Q1).
  • Node_EMIT: The junction connecting the Emitter of Q1, the TL431 Reference (Ref) pin, and the top of the sense resistor (R_SENSE).
  • Node_LOAD: The junction connecting V_IN, the positive terminal of your load, and the Collector of Q1. (The load sits between V_IN and the Collector).
  • GND: The common ground connecting the TL431 Anode and the bottom of R_SENSE.
Bench Insight: Why tie the TL431 Ref pin to the Emitter instead of the base? The TL431 regulates its Cathode-to-Anode impedance to maintain exactly 2.495V between its Ref pin and Anode. By placing the Ref pin at Node_EMIT, the IC forces the voltage across R_SENSE to be exactly 2.495V. The Base-Emitter junction of the 2N3904 sits outside the feedback loop, meaning its V_BE temperature drift (~-2mV/°C) is entirely eliminated from the current calculation.

Component Selection and Design Walkthrough (20mA Target)

Let's design a rock-solid 20mA circuit current source to drive a sensor or a string of indicator LEDs. We will assume a 12V V_IN supply.

1. Sizing the Sense Resistor (R_SENSE)

The TL431 internal reference is nominally 2.495V. Using Ohm's Law:

R_SENSE = V_REF / I_TARGET = 2.495V / 0.020A = 124.75 Ω

The Pick: Use a 124 Ω, 1% tolerance, 1/4W metal film resistor (standard E96 series value). This yields an actual current of 20.12mA. The power dissipated is I²R = (0.02)² * 124 = 49.6mW, well within the 250mW rating of a standard 0207 axial resistor.

2. Sizing the Bias Resistor (R_BIAS)

R_BIAS must supply enough current to keep the TL431 in regulation (minimum cathode current, I_K(min), is 1mA) while also providing base drive to the 2N3904. Assuming a conservative transistor Beta (hFE) of 100, the base current is 20mA / 100 = 0.2mA. Total required current = 1.2mA. We'll design for 2mA to ensure stability across temperature.

Voltage at Node_BIAS is V_REF + V_BE = 2.495V + 0.65V = 3.145V.
Voltage drop across R_BIAS = 12V - 3.145V = 8.855V.
R_BIAS = 8.855V / 0.002A = 4427 Ω.

The Pick: Use a standard 4.7 kΩ, 1/4W resistor. This provides ~1.88mA of bias current, safely above the 1mA TL431 minimum while keeping power dissipation low.

3. Selecting the Transistor (Q1)

The Pick: Texas Instruments TL431 for the reference, and an ON Semiconductor 2N3904 (TO-92 package) for Q1. The 2N3904 handles up to 200mA and 40V V_CEO. At 20mA and a 12V supply, worst-case power dissipation (if the load is shorted) is 12V * 20mA = 240mW, which is safely below the TO-92's ~625mW limit without a heatsink.

Behavior Matrix and Extreme Failure Modes

A true constant current source must maintain its output despite environmental and load variations. Here is how the TL431 topology reacts to real-world perturbations, and what happens when things go wrong.

Variable Changed Effect on Output Current Physical Mechanism
V_IN increases (12V → 15V) No change (stays 20.12mA) Extra voltage drops across Q1 (V_CE increases). TL431 maintains Node_EMIT at 2.495V.
Load Resistance increases No change (until headroom limit) Q1 V_CE shrinks to compensate. If V_IN - V_load < 3.5V, Q1 saturates and current drops.
Ambient Temp increases (+25°C → +60°C) Drops slightly (~0.1%) TL431 V_REF has a slight positive tempco; R_SENSE has a slight positive tempco. They partially cancel.

What Breaks at the Extremes?

  • Shorted Load (Load = 0Ω): The circuit survives. Current remains pinned at 20.12mA. Q1 absorbs the full 12V across its Collector-Emitter junction. Power dissipation is 241mW. The TO-92 case will get warm (~50°C) but will not fail.
  • Open Load (Load = ∞): Current drops to 0mA. Node_LOAD floats up to V_IN. Q1 V_CE drops to 0V. The circuit sits idle safely.
  • Shorted R_SENSE (Accidental breadboard jumper): Catastrophic failure mode. Node_EMIT drops to 0V. The TL431 Ref pin sees 0V and turns off completely (starving the cathode). Q1 base is pulled high through R_BIAS, driving Q1 into hard saturation. The load is now subjected to full V_IN limited only by the load's own resistance, likely destroying the load.

Step-by-Step Breadboard Testing and Verification

Do not trust the math until you verify it on the bench. Follow this exact sequence to test your circuit current source safely.

  1. Power Down: Ensure your bench power supply is turned off and set to current-limit mode (e.g., 100mA limit) to protect against wiring errors.
  2. Wire the Reference: Insert the TL431. Connect Anode to GND. Connect R_BIAS (4.7kΩ) from the positive rail to the Cathode. Leave the Ref pin floating for now.
  3. Wire the Pass Element: Insert the 2N3904 (flat side facing you: Emitter, Base, Collector). Connect Base to TL431 Cathode. Connect Emitter to one leg of R_SENSE (124Ω). Connect the other leg of R_SENSE to GND.
  4. Close the Feedback Loop: Connect the TL431 Ref pin directly to the 2N3904 Emitter (Node_EMIT). Keep this lead as short as possible to prevent high-frequency oscillation.
  5. Insert the DMM: Set your digital multimeter to the mA range. Place it in series between the positive rail and your load (a 1kΩ trimpot works perfectly for testing).
  6. Power On and Sweep: Turn on the 12V supply. Read the DMM. It should read ~20.1mA. Slowly turn the trimpot from 0Ω to 1kΩ. The DMM reading should remain locked at 20.1mA until the trimpot exceeds ~400Ω (at which point the 12V supply runs out of headroom: 12V - 3.5V = 8.5V / 20mA = 425Ω).

Final Recommendation: The Default 20mA Build

When designing a circuit current source for general electronics, LED biasing, or sensor excitation, stop second-guessing the topology. The TL431 + 2N3904 architecture provides the best balance of precision, low headroom, and component cost.

Your Final BOM:

Build it exactly as specified, respect the 3.5V + V_load headroom requirement, and you will have a current source that holds within 1% accuracy from freezing to boiling temperatures. For currents exceeding 100mA, scale R_SENSE down and upgrade Q1 to a TIP31C on a small heatsink, but for 90% of bench tasks, this exact configuration is the definitive solution.