No categories assigned

Common.js

Revision as of 20:07, 19 March 2021 by David (talk | contribs)

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */

$("input:enabled").change(function() 
{
    calcValues();
});

function calcValues () 
{
    var rpm = $("input[name='rpm']").val();
    var ratio = $("input[name='ratio']").val();
    var cir = $("input[name='diameter']").val() * Math.PI;

    var ipm = rpm * ratio * cir;
    var fpm = ipm / 12.0;
    var mph = fpm * 60 / 5280;
    var mpm = fpm * 0.3048;
    var kph = mpm * 60 / 1000;

    $("input[name='circ']").val(cir.toFixed(2));
    $("input[name='speedIPM']").val(ipm.toFixed(2));
    $("input[name='speedFPM']").val(fpm.toFixed(2));
    $("input[name='speedMPH']").val(mph.toFixed(2));
    $("input[name='speedMPM']").val(mpm.toFixed(2));
    $("input[name='speedKPH']").val(kph.toFixed(2));
}

$(function() 
{
	$('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator" class="table_small"><i class="fa fa-tachometer fa-2x" aria-hidden="true" style="color: #CC0000"></i> Robot Speed Calculator</h3><p><i>* If the red fields in the form below are not populated, please refresh your browser.</i></p>      <ul>        <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190"> <span>rpm</span></li>        <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1"> <span>ratio</span></li>        <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6"> <span>inches</span></li>        <li><label for="circ">Wheel Circumference</label> <input type="text" name="circ" disabled="disabled"> <span>inches</span></li>        <li><label for="speedIPM">Speed</label> <input type="text" name="speedIPM" disabled="disabled"> <span>inches per minute</span></li>        <li><label for="speedFPM">Speed</label> <input type="text" name="speedFPM" disabled="disabled"> <span>feet per minute</span></li>        <li><label for="speedMPH">Speed</label> <input type="text" name="speedMPH" disabled="disabled"> <span>miles per hour</span></li>        <li><label for="speedMPM">Speed</label> <input type="text" name="speedMPM" disabled="disabled"> <span>meters per minute</span></li>        <li><label for="speedKPH">Speed</label> <input type="text" name="speedKPH" disabled="disabled"> <span>km per hour</span></li>        <li>* This is the reduction from the output of the gear motor to the wheel. If direct drive, reduction = 1. If your reduction is 1:2 put in 0.5.</li>      </ul>    </div>	');
    calcValues();
});