Wirebarn Calculator
.wirebarn-calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 8px;
padding: 25px;
max-width: 700px;
margin: 20px auto;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
color: #333;
}
.wirebarn-calculator-container h2 {
text-align: center;
color: #2c3e50;
margin-bottom: 25px;
font-size: 1.8em;
}
.wirebarn-calculator-container h3 {
color: #34495e;
margin-top: 30px;
margin-bottom: 15px;
font-size: 1.4em;
border-bottom: 1px solid #eee;
padding-bottom: 5px;
}
.wirebarn-calculator-container h4 {
color: #34495e;
margin-top: 20px;
margin-bottom: 10px;
font-size: 1.2em;
}
.wirebarn-calculator-container p {
line-height: 1.6;
margin-bottom: 15px;
}
.wirebarn-calculator-container ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 15px;
}
.wirebarn-calculator-container ol {
list-style-type: decimal;
margin-left: 20px;
margin-bottom: 15px;
}
.wirebarn-calculator-container li {
margin-bottom: 8px;
}
.calculator-form .form-group {
margin-bottom: 18px;
}
.calculator-form label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
.calculator-form input[type="number"],
.calculator-form select {
width: calc(100% – 22px);
padding: 12px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1em;
box-sizing: border-box;
transition: border-color 0.3s ease;
}
.calculator-form input[type="number"]:focus,
.calculator-form select:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}
.calculator-form small {
display: block;
margin-top: 5px;
color: #777;
font-size: 0.85em;
}
.calculator-form button {
display: block;
width: 100%;
padding: 14px 20px;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
font-size: 1.1em;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
margin-top: 25px;
}
.calculator-form button:hover {
background-color: #218838;
transform: translateY(-2px);
}
.calculator-result {
background-color: #e9f7ef;
border: 1px solid #d4edda;
border-radius: 8px;
padding: 20px;
margin-top: 30px;
font-size: 1.1em;
color: #155724;
line-height: 1.8;
}
.calculator-result p {
margin: 0 0 10px 0;
}
.calculator-result strong {
color: #0a3622;
}
function calculateWirebarn() {
var loadWatts = parseFloat(document.getElementById("loadWatts").value);
var systemVoltage = parseFloat(document.getElementById("systemVoltage").value);
var wireDistance = parseFloat(document.getElementById("wireDistance").value);
var desiredVoltageDrop = parseFloat(document.getElementById("desiredVoltageDrop").value);
var wireMaterial = document.getElementById("wireMaterial").value;
var resultDiv = document.getElementById("wirebarnResult");
// Input validation
if (isNaN(loadWatts) || loadWatts <= 0) {
resultDiv.innerHTML = "Please enter a valid positive number for Total Load (Watts).";
return;
}
if (isNaN(systemVoltage) || systemVoltage <= 0) {
resultDiv.innerHTML = "Please enter a valid positive number for System Voltage (Volts).";
return;
}
if (isNaN(wireDistance) || wireDistance <= 0) {
resultDiv.innerHTML = "Please enter a valid positive number for One-Way Wire Distance (Feet).";
return;
}
if (isNaN(desiredVoltageDrop) || desiredVoltageDrop 100) {
resultDiv.innerHTML = "Please enter a valid positive number for Max Desired Voltage Drop (%).";
return;
}
var currentAmps = loadWatts / systemVoltage;
var maxVoltageDropVolts = (desiredVoltageDrop / 100) * systemVoltage;
// Resistivity (K) values at 75°C (common for voltage drop calculations)
var K_value;
if (wireMaterial === "copper") {
K_value = 12.9; // Copper resistivity
} else {
K_value = 21.2; // Aluminum resistivity
}
// AWG to Circular Mils Area (CMA) mapping, ordered from smallest gauge (highest number) to largest
var awgTable = [
{ gauge: "18 AWG", cma: 1624 },
{ gauge: "16 AWG", cma: 2582 },
{ gauge: "14 AWG", cma: 4107 },
{ gauge: "12 AWG", cma: 6530 },
{ gauge: "10 AWG", cma: 10380 },
{ gauge: "8 AWG", cma: 16510 },
{ gauge: "6 AWG", cma: 26240 },
{ gauge: "4 AWG", cma: 41740 },
{ gauge: "2 AWG", cma: 66360 },
{ gauge: "1 AWG", cma: 83690 },
{ gauge: "1/0 AWG", cma: 105600 },
{ gauge: "2/0 AWG", cma: 133100 },
{ gauge: "3/0 AWG", cma: 167800 },
{ gauge: "4/0 AWG", cma: 211600 }
];
var recommendedGauge = "N/A";
var actualVoltageDropVolts = 0;
var actualVoltageDropPercent = 0;
// Iterate through gauges to find the smallest one that meets the voltage drop requirement
for (var i = 0; i < awgTable.length; i++) {
var cma = awgTable[i].cma;
// Voltage Drop (Vd) = (2 * K * I * L) / CMA
var calculatedVd = (2 * K_value * currentAmps * wireDistance) / cma;
var calculatedVdPercent = (calculatedVd / systemVoltage) * 100;
if (calculatedVd <= maxVoltageDropVolts) {
recommendedGauge = awgTable[i].gauge;
actualVoltageDropVolts = calculatedVd;
actualVoltageDropPercent = calculatedVdPercent;
break; // Found the smallest suitable gauge
}
}
if (recommendedGauge === "N/A") {
// If even the largest gauge (4/0) doesn't meet the requirement
var largestGaugeCMA = awgTable[awgTable.length – 1].cma;
actualVoltageDropVolts = (2 * K_value * currentAmps * wireDistance) / largestGaugeCMA;
actualVoltageDropPercent = (actualVoltageDropVolts / systemVoltage) * 100;
resultDiv.innerHTML =
"Warning: Even with the largest available gauge (" + awgTable[awgTable.length – 1].gauge + "), the voltage drop (" + actualVoltageDropPercent.toFixed(2) + "%) exceeds your desired " + desiredVoltageDrop.toFixed(1) + "%." +
"Consider reducing the load, increasing the system voltage, or shortening the wire distance." +
"Calculated Current: " + currentAmps.toFixed(2) + " Amps" +
"Voltage Drop with " + awgTable[awgTable.length – 1].gauge + ": " + actualVoltageDropVolts.toFixed(2) + " Volts (" + actualVoltageDropPercent.toFixed(2) + "%)";
} else {
resultDiv.innerHTML =
"Calculated Current: " + currentAmps.toFixed(2) + " Amps" +
"Recommended Wire Gauge: " + recommendedGauge + " (" + wireMaterial.charAt(0).toUpperCase() + wireMaterial.slice(1) + ")" +
"Actual Voltage Drop: " + actualVoltageDropVolts.toFixed(2) + " Volts (" + actualVoltageDropPercent.toFixed(2) + "%)" +
"(This is within your desired " + desiredVoltageDrop.toFixed(1) + "% maximum voltage drop)";
}
}