The LM317 current regulator maintains a fixed output current by using a single sense resistor configured between the output and adjust pins, calculated as R = 1.25V / I_out. While famous as a variable voltage regulator, the LM317 is an exceptionally robust constant current source for low-noise, low-current (<500mA) applications like LED driving, battery charging, and precision bench loads. However, because it is a linear topology, it burns excess voltage as heat. If your input-to-output voltage differential exceeds 4V at currents above 300mA, the LM317 will require aggressive heatsinking or you must switch to a buck topology.
Linear vs. Switching: Topology Comparison for Constant Current
Choosing between a linear regulator (LM317) and a switching buck driver (like the PT4115 or LM3404) comes down to four variables: efficiency, heat dissipation, output noise, and bill of materials (BOM) cost. Linear regulators act as variable resistors, dropping excess voltage as heat. Switching regulators use an inductor and a high-frequency MOSFET to chop and store energy, maintaining high efficiency across wide voltage differentials.
| Parameter | LM317 (Linear) | PT4115 (Switching Buck) | LM3404 (Switching Buck) |
|---|---|---|---|
| Efficiency | V_out / V_in (Typ. 30-60%) | 85% - 92% | 88% - 95% |
| Heat Dissipation | High (Requires heatsink >1W) | Low (SOT-89 package) | Low (SOIC-8 package) |
| Output Ripple/Noise | < 100µV (Ultra-low) | 20mV - 50mV (Switching noise) | 15mV - 30mV (Switching noise) |
| BOM Cost & Complexity | ~$0.40 (IC + 1 Resistor) | ~$0.90 (IC + Inductor + Schottky) | ~$1.80 (IC + Inductor + Schottky + Caps) |
| Max Continuous Current | 1.5A (Thermally limited) | 1.2A | 1.2A (Internal FET) |
Design Example: 350mA Constant Current LED Driver
Let's design a 350mA constant current driver for a high-power Cree XML2 LED using an LM317T (TO-220 package). We will use a standard 12V DC wall adapter as our input source.
1. Input/Output Specifications
- Input Voltage (V_in): 12.0V nominal
- LED Forward Voltage (V_f): 3.2V (at 350mA)
- Target Current (I_out): 350mA (0.35A)
2. Sense Resistor Calculation
The LM317 maintains a precise 1.25V reference between the VOUT and ADJ pins. By placing a resistor between these pins, we set the current.
R_sense = 1.25V / I_out
R_sense = 1.25V / 0.35A = 3.57Ω
Since 3.57Ω is not a standard E24 value, we will use a 3.6Ω resistor. This yields an actual current of 1.25V / 3.6Ω = 347mA, which is perfectly safe for a 350mA rated LED.
Power Rating: P = I² × R = (0.35)² × 3.6 = 0.44W. We must select a 1W thick-film or wirewound resistor (e.g., Vishale Dale RH0103R600FE02) to ensure it runs cool. Never use a standard 1/4W carbon film resistor here; it will drift and fail.
3. Dropout and Headroom Math
A common failure mode is insufficient input voltage. The LM317 requires headroom to regulate.
- Sense Voltage: 1.25V
- Internal Dropout Voltage: ~2.5V (at 350mA, per the TI LM317 Datasheet)
- Total Regulator Headroom: 3.75V
Minimum V_in required = V_f (3.2V) + Headroom (3.75V) = 6.95V. Our 12V supply provides 8.8V of excess headroom, meaning the LM317 will regulate perfectly. If we were using a 5V USB supply, the LM317 would drop out of regulation and current would fall to roughly 150mA.
4. Pinout Warning
Thermal Derating and the Heatsink Trap
Linear regulators destroy excess energy as heat. The power dissipated by the LM317 (P_D) is the voltage dropped across the IC multiplied by the current.
P_D = (V_in - V_f - V_sense) × I_out
P_D = (12V - 3.2V - 1.25V) × 0.35A = 7.55V × 0.35A = 2.64W
The Bare TO-220 Failure Mode
A standard TO-220 package in free air has a junction-to-ambient thermal resistance (θ_JA) of roughly 65°C/W.
Temperature Rise = 2.64W × 65°C/W = 171.6°C rise.
Add a 25°C ambient room temperature, and the silicon junction hits 196°C. The LM317's internal thermal shutdown will trigger at ~165°C, causing the LED to strobe or shut off entirely. You must use a heatsink.
Calculating the Required Heatsink
Let's set a maximum junction temperature (T_J) of 110°C to provide a safe margin below the 125°C continuous rating, assuming a worst-case ambient (T_A) of 40°C inside an enclosed project box.
- Max Allowable θ_JA: (110°C - 40°C) / 2.64W = 26.5°C/W
- θ_JC (Junction-to-Case): 2.0°C/W
- θ_CS (Case-to-Sink with thermal paste): 0.5°C/W
- Required θ_SA (Sink-to-Ambient): 26.5 - 2.0 - 0.5 = 24.0°C/W
Concrete Pick: An Aavid Thermalloy 577202B00000G extruded aluminum heatsink (rated at ~15°C/W) will keep the junction comfortably around 80°C. Apply a thin layer of Arctic Silver 5 or standard silicone thermal compound between the tab and the heatsink, and use an insulating mica pad if the heatsink mounts to a grounded chassis.
Ripple, Noise, and Input Protection Requirements
When designing with the LM317 as a constant current source, you must manage both noise expectations and fault protection.
Ripple and Noise Expectations
The LM317 offers exceptional Power Supply Rejection Ratio (PSRR) of roughly 80dB at 120Hz, meaning it will easily strip ripple from an unregulated transformer-bridge rectifier power supply. Output current ripple is typically in the microvolt range. However, PSRR degrades above 10kHz. If your input supply has high-frequency switching noise (e.g., from a cheap buck converter wall wart), add a 10µF ceramic capacitor and a 100nF X7R ceramic capacitor in parallel directly at the VIN pin to ground.
Mandatory Protection Diodes
According to Electronics Tutorials and the TI datasheet, when driving inductive loads or when using large output capacitors, you must protect the internal junctions.
- Reverse Input Protection: Place a 1N4007 diode in series with the input supply to prevent reverse polarity wiring from frying the IC.
- Output-to-Input Flyback Diode: If the input supply is shorted to ground while a large capacitor is on the output, the capacitor will discharge backward through the LM317's internal junction, destroying it. Solder a 1N4148 signal diode with the cathode at VIN and anode at VOUT to safely bypass this reverse current.
Decision Matrix: Should You Use the LM317 or a Switching Driver?
Do not default to the LM317 simply because it is in your parts bin. Use this decision tree to select the correct topology for your specific load requirements.
| Condition / Constraint | If YES... | If NO... |
|---|---|---|
| Is the load current < 500mA? | Proceed to next question. | STOP. Use a switching buck driver (e.g., LM3404MA). The LM317 will require an impractical heatsink. |
| Is (V_in - V_load) < 4V? | Proceed to next question. | STOP. Use a switching buck driver (e.g., PT4115). Linear dissipation will exceed 2W and waste battery life. |
| Must output noise be < 1mV? | PICK LM317. Linear topology is mandatory for precision analog/RF loads. | Proceed to next question. |
| Is BOM cost and board space the absolute highest priority? | PICK LM317. Requires only 1 resistor. Switching drivers require inductors and Schottky diodes. | PICK LM3404. Better thermal performance and efficiency for general commercial LED lighting. |
Final Concrete Recommendations
- Default Pick for Bench/Prototyping (<300mA): LM317T (TO-220). It is indestructible, cheap ($0.30), and easy to heatsink. Perfect for laser diode testers and small battery charging circuits.
- Default Pick for High-Power LEDs (>500mA): LM3404MA (SOIC-8). It handles up to 1.2A, requires minimal external components, and operates at 90%+ efficiency, eliminating the need for bulky aluminum heatsinks on your PCB.
- Default Pick for Ultra-Precision (<50mA): Skip the LM317. The 50µA adjust pin current introduces a 1% error at 5mA. Use a dedicated precision current source IC like the REF200 or build an op-amp + MOSFET transconductance loop.






