Simvik

LDO or buck?

Work out an LDO's heat and junction temperature, and decide if a switcher is needed. An easy embedded C problem (Power supplies and batteries), run and…

easy · Power supplies and batteries · power · regulators · thermal

A linear regulator (LDO) turns (Vin − Vout) × I into heat. Its junction temperature is:

Tj = Tambient + P × θJA

where θJA is the package's thermal resistance in °C per watt.

Write ldo_check(vin_mv, vout_mv, ma, theta_ja, ambient_c, tj_max_c, r): fill r with the dissipated power in milliwatts, the junction temperature in °C (rounded down), and the efficiency in percent (Vout / Vin, rounded down). Return true if the LDO is fine (Tj at most tj_max_c and Vin at least Vout + 300 mV of dropout), false if a buck converter (or a bigger package) is needed.

Starter code

bool ldo_check(uint32_t vin_mv, uint32_t vout_mv, uint32_t ma, uint32_t theta_ja, int ambient_c, int tj_max_c, ldo_t *r) {
  r->mw = vin_mv * ma / 1000u;
  r->tj = ambient_c + (int)(r->mw * theta_ja / 1000u);
  r->efficiency = (int)(vout_mv * 100u / vin_mv);
  return r->tj <= tj_max_c;
}

Example tests

Li-ion cell to 3.3 V

show(3900, 3300, 150, 180, 25);

Expected output:

3900->3300 mV at 150 mA: 90 mW, Tj 41 C, 84% efficient: LDO is fine

12 V to 3.3 V

show(12000, 3300, 200, 180, 40);

Expected output:

12000->3300 mV at 200 mA: 1740 mW, Tj 353 C, 27% efficient: use a buck

Learn it first