Difference between revisions of "CalcHowTo"

From CunningWiki
Jump to: navigation, search
m
Line 3: Line 3:
 
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.
 
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.
  
  example
+
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  code
+
  <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="">
 +
      <TABLE border=1>
 +
        <TBODY>
 +
<TR>
 +
          <TD colSpan=2>
 +
          <P align=center><FONT face=Arial><B>LED Current Limiting Resistor Calc</B></FONT></P></TD></TR>
 +
        <TR>
 +
          <TD><FONT size=3 face=Arial>Voltage Input</FONT></TD>
 +
          <TD><FONT face=Arial><INPUT value=5 size=17 name=Vin> (V)</FONT></TD></TR>
 +
        <TR>
 +
          <TD><FONT face=Arial>LED Voltage</FONT></TD>
 +
          <TD><FONT face=Arial><INPUT value=2.1 size=17 name=Vled> (V)</FONT></TD></TR>
 +
        <TR>
 +
          <TD><FONT face=Arial>LED Current</FONT></TD>
 +
          <TD><FONT face=Arial><INPUT value=20 size=17 name=Iled> (mA)</FONT></TD></TR>
 +
        <TR>
 +
          <TD colSpan=2>
 +
          <P align=center><FONT face=Arial><B>Results</B></FONT></P></TD></TR>
 +
        <TR>
 +
          <TD><FONT face=Arial>Current Limiting Resistor<BR><INPUT size=17 name=Rled>(Ohms)<BR><INPUT onclick=Compute1(document.ParamForm) value="Submit" type=button></FONT></TD>
 +
          <TD><FONT face=Arial>Resistor Power rating<BR><INPUT size=17 name=Wresistor>(Watts)<BR></FONT></TD>
 +
 
 +
 
 +
</HTML>

Revision as of 15:43, 15 December 2011

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="">
<TBODY>


</HTML>

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)