CalcHowTo
Intro
As an electrial engineer I spent a lot of time using and creating excel based calculators. The problem I have is when I or other people make minor changes we rarely ever syncronize our updatse. Eventually we just redesign the calculators from scratch. To try and reduce time I wanted to create them in javascript on a webpage. That way I know I can access it anywhere and update it on any pc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Current Limiting Resistor Calculator</TITLE>
<SCRIPT language=JavaScript>
function Compute1(form) {
with(Math) { var Precision= 0; var Precision= 0;
var Vin= Number(form.Vin.value); var Vled= Number(form.Vled.value); var Iled= Number(form.Iled.value);
Rled= (Vin-Vled)/(Iled/1000);
Wresistor= (Vin-Vled)*(Iled/1000);
if(Rled<0) { alert("the numbers you entered don't make sense!!!"); }
form.Rled.value= Rled.toFixed(Precision); Precision= 3; form.Wresistor.value= Wresistor.toFixed(Precision); }
}
</SCRIPT>
<META name=GENERATOR content="MSHTML 8.00.6001.19154"></HEAD>
<FORM method=post name=ParamForm action="">
LED Current Limiting Resistor Calc | |
Voltage Input | <INPUT value=5 size=17 name=Vin> (V) |
LED Voltage | <INPUT value=2.1 size=17 name=Vled> (V) |
LED Current | <INPUT value=20 size=17 name=Iled> (mA) |
Results | |
Current Limiting Resistor <INPUT size=17 name=Rled>(Ohms) <INPUT onclick=Compute1(document.ParamForm) value="Submit" type=button> |
Resistor Power rating <INPUT size=17 name=Wresistor>(Watts) |