You are viewing an old version of this page. Return to the latest version.
Difference between revisions of "MediaWiki:Common.js"
(5 intermediate revisions by 2 users not shown) | |||
Line 28: | Line 28: | ||
$(function() | $(function() | ||
{ | { | ||
− | $('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator" | + | $('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator">Robot Speed Calculator</h3><p><i>* If the fields in the form below are not populated, please refresh your browser.</i></p> <ul style="list-style-type:none;"> <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190" oninput="calcValues()"> <span>rpm</span></li> <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1" oninput="calcValues()"> <span>ratio</span></li> <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6" oninput="calcValues()"> <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></ul><p>*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.</p> </div> '); |
calcValues(); | calcValues(); | ||
}); | }); |
Latest revision as of 19:41, 23 March 2021
/* 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">Robot Speed Calculator</h3><p><i>* If the fields in the form below are not populated, please refresh your browser.</i></p> <ul style="list-style-type:none;"> <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190" oninput="calcValues()"> <span>rpm</span></li> <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1" oninput="calcValues()"> <span>ratio</span></li> <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6" oninput="calcValues()"> <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></ul><p>*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.</p> </div> ');
calcValues();
});