Created
February 6, 2014 02:25
-
-
Save ryanthejuggler/8837407 to your computer and use it in GitHub Desktop.
G-code test generator
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
// usage: node testgen.js > myFile.g | |
// alter the below variables to taste! | |
var ORIGIN = [0,0]; | |
var EXTENT = 90; | |
var NUM_LOOPS = 20; | |
var POINTS_PER_LOOP = 100; | |
var SPEED=20000; | |
var MAX_HEIGHT=250; | |
var i, theta, r, h; | |
console.log("G4 P5000"); | |
console.log("G28"); | |
console.log("G1 F"+SPEED); | |
for(i=0;i<NUM_LOOPS;i+=(1/POINTS_PER_LOOP)){ | |
theta = 2*i*Math.PI; | |
r = EXTENT*(1-i/NUM_LOOPS); | |
h = MAX_HEIGHT*i/NUM_LOOPS; | |
console.log("G1 X"+(ORIGIN[0]+Math.cos(theta)*r) | |
+" Y"+(ORIGIN[1]+Math.sin(theta)*r) | |
+" Z"+h); | |
} | |
console.log("G28"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment