DIY Guide to Building a Custom Universal Battery Charger Circuit

Start with a LM317 linear regulator at the core of your circuit. Configure it for adjustable output by pairing it with a 1kΩ trimpot and a 240Ω resistor on the ADJ pin. This setup supports voltages from 3.7V to 12.6V, covering most lithium-ion cells, nickel-metal hydride packs, and lead-acid units. Add a 1N4007 diode on the input to prevent reverse polarity damage.
Use a P-channel MOSFET (IRF9540) as a high-side switch to handle currents up to 20A. Gate it with a TL431 shunt regulator to clamp the voltage at your target level. For current sensing, insert a 0.1Ω shunt resistor between the MOSFET source and ground–measure voltage across it with an OP07 op-amp to display charging progress via an LED bar graph.
Isolate different cell chemistries with a CD4066 analog switch. Route a 3.3V logic signal from an ATtiny85 microcontroller to select the appropriate charging profile: constant current for Li-ion, pulse charging for NiMH, or trickle for SLA. Add thermal protection by mounting a 10kΩ NTC thermistor near the MOSFET drain; program the microcontroller to cut power if temperature exceeds 85°C.
For safety, include a polyfuse (15A) in series with the input and a varistor (14V) across the output to absorb voltage spikes. Place 10µF electrolytic capacitors at both input and output stages to smooth ripple–ensure they’re rated for at least 25V. Label terminal connections clearly: V+, V-, and NC (No Connect) for rare 9-cell NiMH configurations.
Adaptive Power Supply Circuit Design
Integrate a LT3741 or LTC4020 controller for multi-chemistry support, allowing voltage ranges from 1.2V to 24V with current regulation up to 5A. Connect the output to a TP4056 module in parallel for lithium-based cells, ensuring a 2A max charge rate per channel. Use a IRFZ44N MOSFET for switching between chemistries–gate voltage should not exceed 20V to prevent damage.
For nickel chemistries (NiMH/NiCd), add a LM358 op-amp in a delta-V detection configuration. Set the reference voltage at 10mV below peak to trigger charge termination. Include a 1N4007 diode to protect against reverse polarity, and a 100μF electrolytic capacitor on the input to stabilize fluctuating power sources. Test load conditions with a 5Ω/10W resistor to verify thermal dissipation.
Component Selection and Safety
Opt for 1% tolerance resistors (e.g., Yageo RC series) to maintain precise cutoff thresholds. Use a polyfuse (e.g., Bourns MF-R110) at the input to prevent overcurrent. For inductor selection, Coilcraft SER2918 provides 4.7μH at 6A saturation, critical for buck-boost topologies. Always isolate high-voltage sections with optocouplers (PC817) if combining AC and DC inputs.
Core Parts for Assembling a Multi-Device Power Adapter

Select a switching regulator IC capable of handling 3–20V input with 0.5–3A output, such as the LM2596 or MP2307. Pair it with a Schottky diode (1N5822 or SB560) to prevent reverse current flow; the component’s forward voltage drop should stay below 0.5V at the target amperage. Add a 100µH power inductor with a saturation current rating at least 20% above the circuit’s peak draw–typically 1.5A–2.5A for most handheld gadgets. Include a 220µF, 25V electrolytic capacitor at the output and a 100nF ceramic capacitor across the IC’s input pins to filter high-frequency noise.
Precision Control and Safety Elements

Incorporate a dual op-amp (LM358 or MCP6002) configured as a comparator to monitor voltage levels; set the reference at 1.25V via a 10kΩ trimpot tied to the feedback pin of the regulator IC. Use a 5A polyswitch (Resettable PTC fuse) for overcurrent protection, placed in series with the positive rail. For cell-specific termination, add a microcontroller (ATTiny85) programmed with voltage thresholds: 4.20V for Li-ion, 3.65V for LiFePO4, or 1.52V per NiMH segment. Include 0.1Ω sense resistors (2W) in parallel to track current flow; this allows the controller to cut power when charging completes within ±50mV of the target voltage.
Step-by-Step Wiring Guide for Adjustable Voltage Regulation
Begin by connecting the input power source to the LM317 voltage regulator’s IN pin (pin 3), ensuring polarity matches the DC supply. Use a 1N4007 diode across the input and output to protect against reverse voltage spikes–anode to ground, cathode to IN. For stabilization, solder a 1μF electrolytic capacitor between the input and ground, observing correct polarity to prevent short circuits.
Attach the feedback network to the ADJ pin (pin 1). Combine a 240Ω resistor (R1) between OUT (pin 2) and ADJ, then pair it with a 5kΩ potentiometer (R2) between ADJ and ground. This resistive divider sets the output range–calculate values using Vout = 1.25 * (1 + R2/R1). For precision, replace R2 with fixed resistors if targeting specific voltages (e.g., 3.3V, 5V, 12V). Verify connections with a multimeter before powering on.
| Component | Value | Purpose |
|---|---|---|
| R1 | 240Ω | Fixed resistor for reference |
| R2 | 5kΩ (potentiometer) | Adjustable resistance for Vout |
| C1 (input) | 1μF | Input smoothing |
| C2 (output) | 10μF | Output ripple reduction |
| D1 | 1N4007 | Reverse voltage protection |
Cap the circuit with a 10μF electrolytic capacitor between the OUT pin and ground to minimize ripple. For currents above 500mA, mount the LM317 on a heatsink using thermal paste–thermal resistance shouldn’t exceed 4°C/W. Test under load: attach a 10Ω resistor (1W min) to the output, measure voltage across it, and adjust R2 until the desired value is reached. Record settings for repeatable configurations.
Common Mistakes to Avoid When Assembling the PCB

Reverse polarity protection omission is a critical error that destroys components instantly. Even a brief connection of input voltage in reverse can fry diodes, capacitors, and ICs–especially linear regulators like LM317, which lack internal safeguards. Add a Schottky diode (e.g., 1N5822) in series with the input or use a dedicated polarity protection IC (e.g., TPS2660). Verify orientation of all polarized parts before soldering: electrolytic capacitors, MOSFETs, and LEDs have clear markings–silkscreen on the board should match datasheet pinouts. Test continuity between ground and power rails with a multimeter before applying voltage.
Overlooking thermal management in high-current paths causes premature failure. Dissipating 5W through a TO-220 package without a heatsink raises junction temperatures above 120°C, degrading efficiency and lifespan. Calculate power dissipation for each active component (P = I²R for MOSFETs, P = (Vin-Vout)*Iout for regulators) and size heatsinks accordingly. Use thick copper pours (2oz or thicker) for traces carrying >3A, and apply thermal vias under power components to improve heat transfer to the board’s backside. Operate prototypes with a thermal camera or thermocouple to confirm temperatures remain below 80°C.
Selecting the Appropriate Power Supply and AC-DC Converter for Energy Storage Systems
For lead-acid units, choose a toroidal or EI-core transformer with a secondary voltage 1.5–2V higher than the nominal cell voltage. A 12V pack requires a 15VAC RMS output to account for diode drops and ripple compensation. Bridge rectifiers rated at 3–5× the expected DC load current prevent overloading during peak demands (e.g., 10A diodes for a 3A continuous load).
- Lithium-ion/cobalt/manganese chemistries demand tighter regulation. Use a center-tapped transformer with dual 12V secondaries and a full-wave rectifier (two diodes per secondary) to minimize voltage sag below 3.0V/cell during charge termination. Install Schottky diodes (VF ≈ 0.3V) instead of standard silicon types to reduce heat dissipation in high-current (5A+) setups.
- Nickel-metal hydride packs tolerate wider input ranges. A single-phase, 18VAC transformer suffices for 12V packs when paired with a bridge rectifier. Add a 0.1Ω series resistor post-rectification to limit inrush current to 2C (where C = nominal capacity in Ah).
- For low-voltage applications (e.g., 1.2V NiCd cells), a step-down transformer with a 3VAC secondary and half-wave rectifier maintains simplicity. However, include a 1000µF smoothing capacitor to suppress ripple exceeding 5% of the DC output.
Select transformer VA ratings based on the peak power draw, not average load. A 20VA transformer suits a 15W continuous output, but increase to 40VA if the system includes cold-cranking amps (CCA) or pulse-discharge requirements. For European mains (230VAC), prioritize transformers with
- Rectifier choice dictates thermal management needs. Bridge configurations halve the transformer secondary current but double forward losses. For currents >5A, mount diodes on a heatsink with thermal compound, ensuring
- Integrate a snubber circuit (22Ω + 0.1µF in series) across rectifier diodes to suppress voltage spikes from switching transients, especially with inductive loads like motor-driven portables.
- High-frequency designs (20kHz+) reduce transformer core size but mandate fast-recovery diodes (
Monitoring circuits should sample the rectified output after the smoothing capacitor but before the series pass element. Place a 10kΩ resistor in parallel with the filter cap to discharge stored energy within 2 seconds of power-down, complying with IEC 60335 safety standards. For rechargeable alkaline chemistries, add a reverse-polarity protection diode (1N4007) rated for 10× the maximum charge current.
For multi-chemistry designs, implement a tapped secondary or auxiliary winding:
- Main winding: 18VAC for lead-acid/gel cells.
- Tapped at 12VAC: Lithium variants (via relay or MOSFET switch).
- Auxiliary 6VAC winding: NiCd/NiMH trickle charging.
Use a 1:1.414 turns ratio for the tapped section to maintain consistent RMS-to-peak conversion efficiency across ranges.
Component derating extends reliability:
- Transformers: 30% VA margin for continuous operation at 50°C ambient.
- Rectifiers: 1.5× average current rating; 2.5× for pulsed loads.
- Capacitors: 16V rating for 12V outputs; 25V for ripple >5Vp-p.
For outdoor deployments, encapsulate the transformer in epoxy and specify diodes with a 10kV surge rating (e.g., 1N4007G) to withstand lightning-induced transients.