Skip to content

Instantly share code, notes, and snippets.

@ril3y
Created September 15, 2014 22:53
Show Gist options
  • Save ril3y/37a49d6b1f67bfcab874 to your computer and use it in GitHub Desktop.
Save ril3y/37a49d6b1f67bfcab874 to your computer and use it in GitHub Desktop.
//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