Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Everything about electronics
Everything about electronics
.calculator-container {
max-width: 650px;
margin: 40px auto;
padding: 20px;
border: 2px solid #ccc;
border-radius: 12px;
background-color: #f9f9f9;
font-family: Arial, sans-serif;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 5px;
}
.calculator-container p {
text-align: center;
font-size: 14px;
margin-bottom: 20px;
}
.calc-box {
padding: 15px;
border: 2px solid #aaa;
border-radius: 12px;
background-color: #fff;
}
.form-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.form-row label {
flex: 1.3;
}
.form-row input,
.form-row select {
flex: 2;
padding: 6px;
margin-left: 10px;
}
.form-buttons {
text-align: center;
margin-top: 15px;
}
.form-buttons button {
padding: 8px 18px;
margin: 5px;
font-size: 14px;
border-radius: 6px;
border: none;
background-color: #3498db;
color: white;
cursor: pointer;
}
.result-box {
margin-top: 20px;
text-align: center;
font-weight: bold;
font-size: 16px;
}
Enter any 2 fields below. Leave one blank to calculate it. Duty cycle is estimated assuming repetitive triggering.
Ω
kΩ
MΩ
µF
nF
pF
s
ms
µs
ns
function calculateMonostable() {
const rVal = document.getElementById(“r”).value;
const cVal = document.getElementById(“c”).value;
const tVal = document.getElementById(“t”).value;
const rUnit = parseFloat(document.getElementById(“r_unit”).value);
const cUnit = parseFloat(document.getElementById(“c_unit”).value);
const tUnit = parseFloat(document.getElementById(“t_unit”).value);
const inputs = [rVal, cVal, tVal].filter(v => v !== “”);
if (inputs.length !== 2) {
alert(“Please fill exactly 2 fields and leave one blank.”);
return;
}
let r = rVal ? parseFloat(rVal) * rUnit : null;
let c = cVal ? parseFloat(cVal) * cUnit : null;
let t = tVal ? parseFloat(tVal) * tUnit : null;
let result = “”;
if (!rVal) {
r = t / (1.1 * c);
result += `Calculated R: ${formatWithUnit(r, “Ω”)}
`;
} else if (!cVal) {
c = t / (1.1 * r);
result += `Calculated C: ${formatWithUnit(c, “F”)}
`;
} else if (!tVal) {
t = 1.1 * r * c;
result += `Calculated T: ${formatWithUnit(t, “s”)}
`;
}
if (t) {
const f = 1 / t;
const duty = (t * f) * 100;
result += `Duty Cycle: ${duty.toFixed(2)} %`;
}
document.getElementById(“monostable_result”).innerHTML = result;
}
function resetMonostable() {
[“r”, “c”, “t”].forEach(id => document.getElementById(id).value = “”);
document.getElementById(“monostable_result”).innerHTML = “”;
}
function formatWithUnit(value, unit) {
const abs = Math.abs(value);
if (unit === “Ω”) {
if (abs >= 1e6) return (value / 1e6).toFixed(2) + ” MΩ”;
if (abs >= 1e3) return (value / 1e3).toFixed(2) + ” kΩ”;
return value.toFixed(2) + ” Ω”;
}
if (unit === “F”) {
if (abs >= 1e-6) return (value * 1e6).toFixed(2) + ” µF”;
if (abs >= 1e-9) return (value * 1e9).toFixed(2) + ” nF”;
return (value * 1e12).toFixed(2) + ” pF”;
}
if (unit === “s”) {
if (abs >= 1) return value.toFixed(3) + ” s”;
if (abs >= 1e-3) return (value * 1e3).toFixed(2) + ” ms”;
if (abs >= 1e-6) return (value * 1e6).toFixed(2) + ” µs”;
return (value * 1e9).toFixed(2) + ” ns”;
}
return value.toFixed(2);
}
(adsbygoogle = window.adsbygoogle || []).push({});