Last active
December 29, 2020 08:21
-
-
Save mabdrabo/6757174 to your computer and use it in GitHub Desktop.
given a few basic info about the robot or vehicle, gives an approximate to what is really needed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DC motor calculator</title> | |
<script> | |
function calculate () { | |
mass = document.getElementById('mass').value; | |
acceleration = document.getElementById('acceleration').value; | |
speed = document.getElementById('speed').value; | |
radius = document.getElementById('radius').value; | |
circumference = eval(radius * 2 * 3.14); | |
force = eval(mass * acceleration); | |
torque = eval(force * radius); | |
rps = eval(speed / circumference); | |
rpm = eval(rps * 60); | |
power_wt = eval(torque * rpm * 0.1047); | |
power_hp = eval(torque * rpm * 0.1047); | |
document.getElementById('force').innerHTML = force; | |
document.getElementById('torque').innerHTML = torque; | |
document.getElementById('rps').innerHTML = rps; | |
document.getElementById('rpm').innerHTML = rpm; | |
document.getElementById('power_wt').innerHTML = power_wt; | |
document.getElementById('power_hp').innerHTML = power_hp; | |
alert(power_hp); | |
} | |
</script> | |
</head> | |
<body> | |
<label>Mass (Kg): </label> | |
<input type="text" id="mass" placeholder="Mass"> | |
<label>Acceleration (m/s^2): </label> | |
<input type="text" id="acceleration" placeholder="Acceleration"> | |
<br/> | |
<label>Speed (m/s): </label> | |
<input type="text" id="speed" placeholder="Speed"> | |
<label>Wheel Radius (m): </label> | |
<input type="text" id="radius" placeholder="Wheel Radius"> | |
<br/> | |
<input type="button" value="Calculate" onClick="calculate();"> | |
<hr/> | |
<hr/> | |
Force (N): <label id="force"></label> | |
<br/> | |
Torque (N.m): <label id="torque"></label> | |
<br/> | |
RPS: <label id="rps"></label> | |
<br/> | |
RPM: <label id="rpm"></label> | |
<br/> | |
Power (watt): <label id="power_wt"></label> | |
<br/> | |
Power (hp): <label id="power_hp"></label> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment