Electrical Conduit Size Calculator Direct

function calculateConduit() if (wires.length === 0) document.getElementById('resultArea').innerHTML = `<div class="conduit-size-result" style="background:#f1f5f9;">⚠️ No wires added</div>`; document.getElementById('fillDetails').innerHTML = ''; return; const conduitType = document.getElementById('conduitType').value; let sparePercent = parseFloat(document.getElementById('sparePercent').value); if (isNaN(sparePercent)) sparePercent = 0; const totalWireArea = computeTotalArea(); const numWires = wires.length; const fillLimit = getFillPercentLimit(numWires); const requiredArea = totalWireArea / fillLimit; const spareMultiplier = 1 + (sparePercent / 100); const finalRequiredArea = requiredArea * spareMultiplier; const areaMap = conduitAreas[conduitType]; if (!areaMap) document.getElementById('resultArea').innerHTML = `<div class="conduit-size-result">Error: conduit data</div>`; return; let selectedSize = null; for (let sz of tradeSizes) if (areaMap[sz] >= finalRequiredArea) selectedSize = sz; break; const fillPercentActual = (totalWireArea / (selectedSize ? areaMap[selectedSize] : 0.01)) * 100; const fillPercentLimited = fillLimit * 100; const resultDiv = document.getElementById('resultArea'); const fillDetailsDiv = document.getElementById('fillDetails'); const warningDiv = document.getElementById('warningMsg'); if (selectedSize) let conduitInnerArea = areaMap[selectedSize]; resultDiv.innerHTML = ` <div class="conduit-size-result"> Trade Size: <strong>$selectedSize"</strong> $conduitType<br> <span style="font-size:1rem;">(inner area: $conduitInnerArea.toFixed(3) in²)</span> </div> `; fillDetailsDiv.innerHTML = ` <div class="fill-percent">📐 Calculated fill: $fillPercentActual.toFixed(1)% (max allowed $fillLimit*100%)</div> <div>⚡ Total conductor area: $totalWireArea.toFixed(4) in² else resultDiv.innerHTML = `<div class="conduit-size-result" style="background:#ffe6e5; color:#a1301a;">❌ No standard conduit size up to 4" fits these wires.<br>Consider larger conduit or reducing wires.</div>`; fillDetailsDiv.innerHTML = `<div>Total area needed: $finalRequiredArea.toFixed(4) in² exceeds max 4" conduit area ($areaMap["4"]?.toFixed(3) )</div>`; warningDiv.style.display = 'none';

function computeTotalArea() let total = 0; for (let w of wires) const areaObj = wireAreas[w.size]; if (areaObj && areaObj[w.insulation]) total += areaObj[w.insulation]; else if (areaObj && areaObj["THHN"]) total += areaObj["THHN"]; else total += 0.0133; // fallback return total; electrical conduit size calculator

function renderWireInputs() const container = document.getElementById('wiresContainer'); if (!container) return; container.innerHTML = ''; wires.forEach((wire, idx) => const div = document.createElement('div'); div.className = 'wire-entry'; div.innerHTML = ` <div class="wire-header"> <span>🔌 Conductor #$idx+1</span> <button class="btn-remove" data-idx="$idx" type="button">Remove</button> </div> <div class="wire-controls"> <select class="wire-size" data-idx="$idx"> $Object.keys(wireAreas).map(sz => `<option value="$sz" $wire.size === sz ? 'selected' : ''>AWG $sz</option>`).join('') </select> <select class="wire-insulation" data-idx="$idx"> <option value="THHN" $wire.insulation === 'THHN' ? 'selected' : ''>THHN / THWN</option> <option value="XHHW" $wire.insulation === 'XHHW' ? 'selected' : ''>XHHW</option> </select> </div> `; container.appendChild(div); ); // attach remove events document.querySelectorAll('.btn-remove').forEach(btn => btn.addEventListener('click', (e) => const idx = parseInt(btn.getAttribute('data-idx')); wires.splice(idx, 1); renderWireInputs(); ); ); // attach change listeners for dynamic updates document.querySelectorAll('.wire-size').forEach(sel => sel.addEventListener('change', (e) => const idx = parseInt(sel.getAttribute('data-idx')); wires[idx].size = sel.value; ); ); document.querySelectorAll('.wire-insulation').forEach(sel => sel.addEventListener('change', (e) => const idx = parseInt(sel.getAttribute('data-idx')); wires[idx].insulation = sel.value; ); ); function calculateConduit() if (wires

function getFillPercentLimit(numWires) if (numWires === 1) return 0.53; if (numWires === 2) return 0.31; return 0.40; // 3+ wires 'selected' : ''&gt

// initialization function init() wires.push( size: "12", insulation: "THHN" ); wires.push( size: "12", insulation: "THHN" ); renderWireInputs(); document.getElementById('addWireBtn').addEventListener('click', addWire); document.getElementById('calculateBtn').addEventListener('click', calculateConduit); calculateConduit(); // default calculation

let wireCount = 0; let wires = []; // store each wire object size, insulation

<hr> <h3>📘 Conduit Fill Reference Table (for common wires)</h3> <div style="overflow-x:auto;"> <table> <thead> <tr><th>Wire Size (AWG/kcmil)</th><th>THHN/THWN Area (in²)</th><th>XHHW Area (in²)</th><th>Trade Size 3/4" EMT (40% fill max area)</th></tr> </thead> <tbody> <tr><td>14 AWG</td><td>0.0097</td><td>0.0123</td><td>0.213 in²</td></tr> <tr><td>12 AWG</td><td>0.0133</td><td>0.0160</td><td>0.213 in²</td></tr> <tr><td>10 AWG</td><td>0.0211</td><td>0.0243</td><td>0.213 in²</td></tr> <tr><td>8 AWG</td><td>0.0366</td><td>0.0410</td><td>0.213 in²</td></tr> <tr><td>6 AWG</td><td>0.0507</td><td>0.0590</td><td>0.346 in² (1" EMT)</td></tr> <tr><td>4 AWG</td><td>0.0824</td><td>0.0937</td><td>0.598 in² (1¼" EMT)</td></tr> </tbody> </table> <p class="note" style="margin-top:8px;">⚠️ Full NEC Chapter 9 Table 4 & 5 used in calculator logic for 1/2" to 4" conduit.</p> </div> </div>