Created
February 18, 2013 08:37
-
-
Save tmpvar/4975923 to your computer and use it in GitHub Desktop.
spindle mount for mini cnc r1
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
var gcode = []; | |
var feed = 2000; | |
var zfeed = 100; | |
var materialHeight = 1/4*25.4 + 1; | |
var depthPerPass = .1; | |
gcode = [ | |
'G90', | |
]; | |
var bitDiameter = 1/4*25.4; | |
var bitRadius = bitDiameter/2; | |
function move(coords) { | |
var parts = [ | |
'G1', | |
]; | |
for (var coord in coords) { | |
if (coords.hasOwnProperty(coord)) { | |
parts.push(coord.toUpperCase() + coords[coord]); | |
} | |
} | |
gcode.push(parts.join(' ')); | |
} | |
function generateCircle(diameter, startz, endz) { | |
var radius = diameter / 2; | |
gcode.push('G1 Z0 F1000'); | |
var lfeed = feed*4; | |
gcode.push('G1 X-' + radius + 'F' + lfeed); | |
for (var i=startz; i<=endz; i+=depthPerPass) { | |
gcode.push(['G1', 'Z' + i, 'F' + zfeed].join(' ')); | |
gcode.push('G02' + 'X0. Y' + radius + ' I' + radius + ' J0. F' + lfeed); | |
gcode.push('G02' + 'X' + radius + 'Y0. I0. J-' + radius); | |
gcode.push('G02' + 'X0. Y-' + radius + ' I-' + radius + ' J0'); | |
gcode.push('G02' + 'X-' + radius + ' Y0. I0. J' + radius); | |
} | |
gcode.push('G1 Z0 F1000'); | |
gcode.push('G1 Y0 X0 F' + feed); | |
} | |
var drill = function(depth, speed) { | |
move({ z: depth, f: speed }); | |
move({ z: 0, f: zfeed }); | |
}; | |
generateCircle(36-bitDiameter, 0, materialHeight); | |
// touch the holes | |
move({ x: -41 , y: -58.5, f: feed }); | |
drill(3, zfeed/6); | |
// acme hole | |
move({ x: -62 , y: 0, f: feed }); | |
drill(3, zfeed/6); | |
move({ x: -41 , y: 58.5, f: feed }); | |
drill(3, zfeed/6); | |
move({ x: 19 , y: 58.5, f: feed }); | |
drill(3, zfeed/6); | |
move({ x: 19 , y: -58.5, f: feed }); | |
drill(3, zfeed/6); | |
// cut the outline | |
move({ x : 30 + bitRadius, y: -69.5 - bitRadius, f: feed }); | |
for (var depth=0; depth<=materialHeight; depth+=depthPerPass) { | |
move({ z: depth, f : zfeed }); | |
move({ x : -52 - bitRadius, y: -69.5 - bitRadius, f: feed }); | |
move({ x : -75 - bitRadius, y: -11 - bitRadius, f: feed }); | |
move({ x : -75 - bitRadius, y: 11 + bitRadius, f: feed }); | |
move({ x : -52 - bitRadius, y: 69.5 + bitRadius, f: feed }); | |
move({ x : 30 + bitRadius, y: 69.5 + bitRadius, f: feed }); | |
// return to origin | |
move({ x : 30 + bitRadius, y: -69.5 - bitRadius, f: feed }); | |
} | |
gcode.push('G1 Z0 F' + zfeed); | |
gcode.push('G1 X0 Y0 F' + feed); | |
console.log(gcode.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment