Created
September 15, 2014 22:53
-
-
Save ril3y/37a49d6b1f67bfcab874 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Wrecking Ball Demo | |
//var feed = 21538 | |
//var axis = "Y" | |
var calcPendulum = function(zLen){ | |
//Pendulum Movement Equation | |
//T = 2pi*SQRT(L/g) | |
var twoPi = 6.2831926 | |
var gravity = 9.8 | |
var result = twoPi * Math.sqrt(zLen / gravity); | |
return(result.toFixed(4)) | |
} | |
var calcVelocity = function(xyLen, jerk, pendulumPeriod){ | |
var fudge = 0.94456 | |
var idealVelocity = (xyLen / pendulumPeriod) * 60000 | |
alert(idealVelocity.toFixed(4)) | |
return(idealVelocity*fudge) | |
} | |
var pp = calcPendulum(.275) | |
var vel = calcVelocity(.45, 0, pp) | |
var sendLine = function(gcodeLine, ){ | |
var line = "{\n g1F" + feed + axis + "400\n g1F" + feed + "G4P5\n" + axis +"0\n" | |
console.log("Sent: " + line + "\n"); | |
chilipeppr.publish("/com-chilipeppr-widget-serialport/send", gcodeLine); | |
} | |
//sendLine(line); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment