Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 17th, 2013  |  syntax: HTML  |  size: 4.23 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     <table>
  2.         <tr>
  3.                 <th rowspan="3">Inputs:</th>
  4.                 <td>Hole dia</td>
  5.                 <td><input id="dia" onkeyup="calculate()" type="text" value="18" name="dia"></td>
  6.                 <td><select id="diaUnits" onchange="calculate()" name="diaUnits">
  7.                         <option value="1">mil</option>
  8.                         <option value="39.37" selected>mm</option>
  9.                         <option value="0.03937">um</option>
  10.                 </select></td>
  11.         </tr>
  12.         <tr>
  13.                 <td>Plating thickness</td>
  14.                 <td><input id="thickness" onkeyup="calculate()" type="text" value="1" name="thickness"></td>
  15.                 <td><select id="thicknessUnits" onchange="calculate()" name="thicknessUnits">
  16.                         <option value="1">mil</option>
  17.                         <option value="39.37" selected>mm</option>
  18.                         <option value="0.03937">um</option>
  19.                 </select></td>
  20.         </tr>
  21.         <tr>
  22.                 <td>Via length</td>
  23.                 <td><input id="length" onkeyup="calculate()" type="text" value="60" name="length"></td>
  24.                 <td><select id="lengthUnits" onchange="calculate()" name="lengthUnits">
  25.                         <option value="1">mil</option>
  26.                         <option value="39.37" selected>mm</option>
  27.                         <option value="0.03937">um</option>
  28.                 </select></td>
  29.         </tr>
  30.         <tr>
  31.                 <th rowspan="2">Additional Inputs:</th>
  32.                 <td>Applied current</td>
  33.                 <td><input id="current" onkeyup="calculate()" type="text" value="1" name="current"></td>
  34.                 <td>A</td>
  35.         </tr>
  36.         <tr>
  37.                 <td>Plating resistivity</td>
  38.                 <td><input id="resistivity" onkeyup="calculate()" type="text"  value="1.9e-6" name="resistivity"></td>
  39.                 <td>Ohm×cm</td>
  40.         </tr>
  41.         <tr>
  42.                 <th rowspan="5">Results:</th>
  43.                 <td>Resistance</td>
  44.                 <td><input id="resistance" onkeyup="calculate()" type="text" name="resistance"></td>
  45.                 <td>Ohm</td>
  46.         </tr>
  47.         <tr>
  48.                 <td>Voltage drop</td>
  49.                 <td><input id="voltage drop" onkeyup="calculate()" type="text" name="voltage drop"></td>
  50.                 <td>V</td>
  51.         </tr>
  52.         <tr>
  53.                 <td>Power loss</td>
  54.                 <td><input id="power loss" onkeyup="calculate()" type="text" name="power loss"></td>
  55.                 <td>W</td>
  56.         </tr>
  57.         <tr>
  58.                 <td>Estimated ampacity</td>
  59.                 <td><input id="ampacity" onkeyup="calculate()" type="text" name="ampacity"></td>
  60.                 <td>A</td>
  61.         </tr>
  62.         <tr>
  63.                 <td>Thermal resistance</td>
  64.                 <td><input id="thermal resistance" onkeyup="calculate()" type="text" name="thermal resistance"></td>
  65.                 <td>°C/W</td>
  66.         </tr>
  67.     </table>
  68.    
  69.     <script language="javascript">
  70.         function calculate() {
  71.                 // Getting input
  72.                 dia = document.getElementById("dia").value;
  73.                 thickness = document.getElementById("thickness").value;
  74.                 length = document.getElementById("length").value;
  75.                 current = document.getElementById("current").value;
  76.                 resistivity = document.getElementById("resistivity").value * 1000 / 2.54;
  77.    
  78.                 // Getting units of input
  79.                 dia_unit = document.getElementById("diaUnits").value;
  80.                 thickness_unit = document.getElementById("thicknessUnits").value;
  81.                 length_unit = document.getElementById("lengthUnits").value;
  82.    
  83.                 // Converting input to heterogeneous units, see http://www.wolframalpha.com/input/?i=um+to+mil;+mm+to+mil for details
  84.                 dia *= dia_unit;
  85.                 thickness *= thickness_unit;
  86.                 length *= length_unit;
  87.    
  88.                 // Calculating
  89.                 rhoth = 98;
  90.                 area = Math.PI * (dia + thickness) * thickness;
  91.                 resistance = resistivity *  length / area;
  92.                 thermal_resistance = rhoth * length / area;
  93.                 voltage_drop = current * resistance;
  94.                 power_loss = current * voltage_drop;
  95.    
  96.                 // IPC-2221 external layers constants
  97.                 k = 0.048;
  98.                 b = 0.44;
  99.                 c = 0.725;
  100.                 delta_t = 10;
  101.    
  102.                 ampacity = k * Math.pow(delta_t, b) * Math.pow(area, c);
  103.    
  104.                 // Output
  105.                 document.getElementById("resistance").value = resistance.toPrecision(3);
  106.                 document.getElementById("voltage drop").value = voltage_drop.toPrecision(3);
  107.                 document.getElementById("power loss").value = power_loss.toPrecision(3);
  108.                 document.getElementById("thermal resistance").value = thermal_resistance.toPrecision(3);
  109.                 document.getElementById("ampacity").value = ampacity.toPrecision(3);
  110.         }
  111.    
  112.         calculate();
  113.     </script>