When designing an ac and dc power supply to convert 120VAC mains to a stable low-voltage DC rail, the default choice for 90% of modern embedded, IoT, and relay-driven loads is an isolated switching AC-DC module like the Mean Well IRM series. You should only choose a linear transformer-and-LDO topology if your load draws under 100mA and requires ultra-low noise (sub-5mV ripple) for precision 16-bit ADCs. For everything else, switching topologies win on thermal management, physical size, and efficiency.

This guide breaks down the exact math for headroom, thermal derating, and input protection, terminating in a concrete decision matrix so you can pick the right architecture and part number for your next build.

Linear vs. Switching Topology: The Efficiency and Heat Reality

The choice between linear and switching architectures dictates your thermal design, enclosure constraints, and EMI filtering requirements. Below is a direct comparison for a typical 120VAC to 12VDC conversion at 1.5A (18W output).

Criteria Linear (Transformer + Bridge + LDO) Switching (Isolated Flyback AC-DC Module)
Efficiency 40% - 55% (Transformer core losses + LDO dropout) 80% - 88% (High-frequency PWM switching)
Heat Dissipation High (Requires large extruded aluminum heatsinks) Low (Heat spread across PCB copper pours)
Output Noise/Ripple Ultra-low (< 1mV RMS, 120Hz ripple) Higher (50mV - 150mV p-p at 50kHz - 130kHz)
Mains Sag Tolerance Poor (Dropout risk if VAC sags > 5%) Excellent (Regulates down to 85VAC input)
BOM Cost & Size $15-$25, Bulky (heavy iron core transformer) $12-$20, Compact (potting compound enclosed)
Warning: Never use non-isolated buck capacitive dropper circuits for any ac and dc power supply that a human might touch or that interfaces with grounded sensors. Capacitive droppers tie your DC ground directly to the AC mains hot/neutral, creating a lethal shock hazard and destroying downstream microcontrollers via ground loops.

Designing the AC and DC Power Supply: A 12V @ 1.5A Example

Let us run the exact headroom and dropout math for a 120VAC to 12VDC @ 1.5A (18W) mixed-signal load (e.g., an ESP32 gateway driving four 12V mechanical relays and reading analog sensors). We will evaluate a linear attempt first to demonstrate why it fails in real-world conditions, then specify the switching alternative.

The Linear Attempt: Headroom and Dropout Math

To get 12VDC at 1.5A linearly, you might select a 15VAC 2A transformer (e.g., Hammond 165L15), a KBPC2010 bridge rectifier, a 2200µF 25V filter capacitor, and an LM338 adjustable linear regulator.

  • Peak DC Voltage: 15VAC × 1.414 = 21.2V. Minus 1.4V bridge diode drop = 19.8V peak.
  • Ripple Voltage: V_ripple = I / (2 × f × C). At 1.5A, 120Hz (full-wave), and 0.0022F: 1.5 / (120 × 0.0022) = 5.68V peak-to-peak ripple.
  • Minimum Valley Voltage: 19.8V - 5.68V = 14.12V.
  • Regulator Headroom: 14.12V (min input) - 12V (output) = 2.12V headroom.

The LM338 requires a typical dropout voltage of 1.5V to 2.0V at 1.5A. At nominal 120VAC, this circuit barely functions. However, the NEC allows a 5% voltage drop on branch circuits. If your mains sags to 114VAC, the transformer output drops proportionally. Your new peak is 18.75V, and your new valley voltage drops to 13.07V. Your headroom shrinks to 1.07V. The LM338 will drop out of regulation, passing 120Hz AC ripple directly into your 12V DC rail, causing brownouts on your ESP32 and chattering relays.

The Switching Solution: Specifying the Module

To eliminate mains sag vulnerability and heatsink requirements, we switch to an isolated flyback topology. The Mean Well IRM-20-12 provides 12V at 1.67A (20W). It accepts 85-264VAC input, meaning it will maintain a rock-solid 12.0V output even if your shop mains sags to 90VAC during heavy motor startups. Efficiency is rated at 86%, meaning total system heat dissipation is only ~3.2W, easily managed by the module's internal potting compound and PCB conduction.

Input Protection, Ripple Filtering, and Thermal Derating

Selecting the power module is only half the design. You must protect the AC input and manage the high-frequency noise inherent to switching supplies.

AC Input Protection Specs

Switching power supplies draw a massive inrush current (often 20A to 40A for a few milliseconds) as the internal bulk DC bus capacitors charge. If you use a standard fast-blow fuse, it will nuisance-trip on every power-up.

Tip: Always use a time-delay (slow-blow) fuse for the AC input of a switching supply. For a 20W module, a 250V 250mA Slow-Blow Fuse (e.g., Littelfuse 372 series) is ideal. Pair this with a 275VAC Metal Oxide Varistor (MOV) like the Littelfuse TMOV20RP275E placed directly across the Line and Neutral terminals, upstream of the fuse, to clamp transient surges.

Managing Switching Ripple for Analog Loads

The IRM-20-12 specifies a maximum ripple and noise of 150mV peak-to-peak at the switching frequency (typically around 65kHz). For digital relays and microcontrollers, this is irrelevant. However, if your 12V rail powers a 16-bit ADC or a precision load cell amplifier, 150mV of high-frequency noise will destroy your signal-to-noise ratio.

The Fix: Do not switch back to a linear supply. Instead, add a post-regulation Pi-filter. Place a 10µH shielded power inductor (e.g., Wurth Elektronik 744774210) in series with the 12V output, flanked by two 100µF X7R MLCC capacitors to ground. This LC filter will attenuate the 65kHz switching noise by over 40dB, dropping the ripple to < 5mV while maintaining the 86% efficiency of the switching front-end.

Thermal Derating: The Enclosure Trap

Datasheet wattage ratings assume open-frame convection at 25°C ambient. In reality, you will mount this ac and dc power supply inside a sealed plastic or metal project box. According to the Mean Well IRM series derating curves, output capacity drops linearly starting at 50°C ambient, reaching 50% capacity at 80°C.

If your sealed enclosure sits in a 40°C attic or control panel, internal self-heating will push the ambient air around the module to 60°C. At 60°C, the IRM-20-12 is derated to roughly 80% capacity (16W). If your load draws 18W, the module will trigger its internal over-temperature protection and shut down cyclically. Always bump up one size class for enclosed installations. For an 18W enclosed load, specify the Mean Well IRM-30-12 (30W nominal, derating to 24W at 60°C) to guarantee reliable continuous operation.

The Decision Tree: Picking Your Exact AC-DC Architecture

Use this decision matrix to finalize your topology and select the exact part number for your BOM. Do not over-engineer with linear supplies unless the noise criteria strictly demand it.

Load Profile & Constraints Recommended Topology Concrete Part Pick (12VDC Example)
Current: < 100mA
Noise: < 5mV required (Precision ADCs)
Enclosure: Open or large metal chassis
Linear (Transformer + Bridge + Ultra-Low Noise LDO) 15VAC 0.5A Transformer + TI LT3042 (20V, 200mA, 0.8µV RMS noise LDO)
Current: 100mA - 500mA
Noise: Standard digital (< 150mV)
Enclosure: Sealed PCB box
Switching (Compact PCB-mount Flyback) Hi-Link HLK-PM12 (12V, 3W / 250mA) or Mean Well IRM-10-12 (10W)
Current: 500mA - 2.5A
Noise: Standard digital / Relays
Enclosure: Sealed box, high ambient temp
Switching (Derated Industrial AC-DC Module) Mean Well IRM-30-12 (30W nominal, derated for 60°C internal ambient)
Current: > 3A
Noise: High power motors / LED strips
Switching (DIN Rail or Enclosed Chassis) Mean Well HDR-60-12 (60W, DIN rail mount) or LRS-75-12 (Enclosed chassis)

Default Recommendation: For the vast majority of prosumer, IoT, and automation projects drawing between 500mA and 2A, the Mean Well IRM series is the definitive pick. It provides the necessary isolation (4000VAC withstand), built-in short-circuit and over-temperature protection, and UL62368-1 certification, eliminating the liability and thermal headaches of rolling your own discrete linear or switching circuits. Pair it with a slow-blow fuse, an MOV, and a Pi-filter if your analog sensors demand it, and your power rail will remain stable through mains sags, surges, and thermal spikes.