gcmc - G-Code Meta Compiler

Library functions


canned_drill.inc.gcmc

undef canned_drill ( vectorlist:holelist, scalar:retractz, scalar:dw, scalar:oldz )
holelist vectorlist [distance] Vectors pointing to the holes to drill
retractz scalar [distance] Z-axis retract level (R-plane)
dw scalar [none] Dwell time at bottom of hole if ≥0. No dwell is performed if <0
oldz scalar [none] Boolean to indicate if retract should return to original Z
Perform a canned drilling cycle with optional dwelling at the bottom of the hole. The position of the holes are set by the holelist argument where holelist[0] must include a Z-coordinate to set the drilling depth. Each vector in holelist may include X-, Y- or both XY-coordinates to set the position of each drill-hole. An optional Z-coordinate for each vector in holelist may set a new drilling depth for the following hole(s).

The retractz argument sets the R-plane. The R-plane defines the Z-level at which further down-movement is performed at the current feedrate. The actual retraction point depends on oldz, where true means full retraction to the Z-level before the canned_drill() function was called. Setting oldz to false retracts to the R-plane after each drilling sequence. The retractz level is used instead of the original Z-level if the original Z-level was below the R-plane.

The canned_drill() function calls pathmode(1) to set exact path mode before attempting any movement.

undef canned_drill_peck ( vectorlist:holelist, scalar:retractz, scalar:incr, scalar:oldz )
holelist vectorlist [distance] Vectors pointing to the holes to drill
retractz scalar [distance] Z-axis retract level (R-plane)
incr scalar [distance] Incremental drilling depth; must be >0
oldz scalar [none] Boolean to indicate if retract should return to original Z
Perform a canned peck-drilling cycle with incr denoting the incremental down-move distance before clearing the hole. The position of the holes are set by the holelist argument where holelist[0] must include a Z-coordinate to set the drilling depth. Each vector in holelist may include X-, Y- or both XY-coordinates to set the position of each drill-hole. An optional Z-coordinate for each vector in holelist may set a new drilling depth for the following hole(s).

The retractz argument sets the R-plane. The R-plane defines the Z-level to reach to clear the hole. The final retraction point depends on oldz, where true means full retraction to the Z-level before the canned_drill_peck() function was called. Setting oldz to false retracts to the R-plane after each drilling sequence. The retractz level is used instead of the original Z-level if the original Z-level was below the R-plane.

The canned_drill_peck() function calls pathmode(1) to set exact path mode before attempting any movement.

Canned drilling examples

See also the distribution's example file example/canned.gcmc.
include("canned_drill.inc.gcmc");

homepos = [0mm, 0mm, 0mm];
initpos = [-1mm, -1mm, 10mm];	/* Somewhere to start */

retract = 5.0mm;		/* R-plane level */
incr = 2.2mm;			/* Peck increment */

feedrate(100);

goto(homepos);
move(homepos);	/* Just to let LinuxCNC show a line in the preview */

/* A set of holes */
holes = {
	[10mm, 0mm, -5mm],	/* First hole at 10,0 depth -1 */
	[15mm],			/* Second hole at X=15 same Y and depth */
	[20mm],
	[25mm],
	[-, 5mm],		/* Move only in Y */
	[20mm],
	[15mm, -, -6mm],	/* Set new drilling depth */
	[10mm]
};

goto(initpos);
canned_drill(holes, retract, -1, 0);	/* Drill a set of holes */

/* Set a new set of holes with explicit coordinates */
holes = {
	[10mm, 20mm, -5mm],
	[15mm, 20mm],
	[20mm, 20mm],
	[25mm, 20mm],
	[25mm, 25mm],	
	[20mm, 25mm],
	[15mm, 25mm, -6mm],
	[10mm, 25mm]
};

goto(initpos + [-, 20]);
canned_drill_peck(holes, retract, incr, 1);	/* Peck-drilling */

goto(head(homepos, 2));
goto(homepos);

tracepath.inc.gcmc

undef tracepath ( vectorlist:path, scalar:z, scalar:dw )
path vectorlist [distance] Vectors pointing to the XY positions to visit
z scalar [distance] Cutting plane Z-level
dw scalar [none] Dwell time at bottom each point if ≥0. No dwell is performed if <0
Cut a path at depth z following all points as defined by path. The tracepath() function performs a preliminary movement to path[0] at the current Z-level, moves to cutting depth according to the z argument, visits each vector of path and finally retracts to original Z-level.

A dwell of length dw is performed at each point in the path if it is ≥0. Any negative value of dw will suppress dwelling.

Tracepath example

include("tracepath.inc.gcmc");

starpath = {
	[ 1,  1], [ 0,  3],
	[-1,  1], [-3,  0],
	[-1, -1], [ 0, -3],
	[ 1, -1], [ 3,  0]
};

SAFEZ = [0mm, 0mm, 1mm];

feedrate(100);
goto(SAFEZ);

starpath *= 10mm;	/* Scale the star */

tracepath(starpath, -1mm, -1);

goto(SAFEZ);