LM317 Output Voltage Calculator

Enter any two values among R1, R2, and Output Voltage (Vout). Leave the third one blank to calculate it.


Ω




Ω





Note: The LM317 output voltage is calculated using: Vout = 1.25 × (1 + R2 / R1). Ignores Iadj for simplicity.

function calculateLM317() {
const r1 = parseFloat(document.getElementById(“r1”).value);
const r1u = parseFloat(document.getElementById(“r1Unit”).value);
const r2 = parseFloat(document.getElementById(“r2”).value);
const r2u = parseFloat(document.getElementById(“r2Unit”).value);
const vout = parseFloat(document.getElementById(“vout”).value);
const result = document.getElementById(“lm317Result”);

const hasR1 = !isNaN(r1);
const hasR2 = !isNaN(r2);
const hasVout = !isNaN(vout);

if ([hasR1, hasR2, hasVout].filter(Boolean).length !== 2) {
result.textContent = “Please enter any two values and leave one blank.”;
return;
}

if (!hasVout) {
const v = 1.25 * (1 + (r2 * r2u) / (r1 * r1u));
result.textContent = “Calculated Output Voltage = ” + v.toFixed(2) + ” V”;
} else if (!hasR2) {
const r2calc = ((vout / 1.25) – 1) * (r1 * r1u);
result.textContent = “Calculated R2 = ” + r2calc.toFixed(2) + ” Ω”;
} else if (!hasR1) {
const r1calc = (r2 * r2u) / ((vout / 1.25) – 1);
result.textContent = “Calculated R1 = ” + r1calc.toFixed(2) + ” Ω”;
}
}

function resetLM317() {
document.getElementById(“r1”).value = “”;
document.getElementById(“r2”).value = “”;
document.getElementById(“vout”).value = “”;
document.getElementById(“lm317Result”).textContent = “”;
document.getElementById(“r1Unit”).selectedIndex = 0;
document.getElementById(“r2Unit”).selectedIndex = 0;
}


(adsbygoogle = window.adsbygoogle || []).push({});