Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1,301 @@
(info: arc1: inside/outside, cw/ccw, cutter radius compensation)
; Arc making subroutine formatted for ngcgui
; Specify:
; dir == 2 for cw, 3 for ccw
; inside == 1 for inside, 0 for outside
; xoff,yoff == arc center
; arc radius == distance to center of rotation
; angle == anglular spread of arc
; rotate == rotation of arc
; width == width of arc
; see also arc2.ngc to specify using center of rotation
;----------------------------------------------------------------------
; Copyright: 2012
; Author: Dewey Garrett <dgarrett@panix.com>
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;----------------------------------------------------------------------
o<arc1> sub
#<toolno> = #1 (=1)
#<dir> = #2 (=2 2:cw 3:ccw)
#<inside> = #3 (=1 1:inside 0:outside)
#<rpm> = #4 (=2000)
#<feedrate> = #5 (=100)
#<zincr> = #6
#<cutdepth> = #7
#<zsafe> = #8 (=0.25)
#<zstart> = #9 (=0)
#<width> = #10 (=.3)
#<angle> = #11 (=45 Angle)
#<arc_r> = #12 (=2 Arc Radius)
#<rotate> = #13 (=-90)
#<xoff> = #14 (=2)
#<yoff> = #15 (=0)
#<scale> = #16 (=1)
#<spin_notify> = #17 (=0)
#<use_g43> = #18 (=1)
#<h_for_g43> = #19 (=0)
#<verbose> = #20 (=0)
#<min_angle> = 1 ;minimum angle
g40; cutter comp off to begin
o<i0> if [#<scale> LE 0]
(print, arc1: bad scale: #<scale> - EXITING)
(debug, arc1: bad scale: #<scale> - EXITING)
(AXIS,notify, arc1: bad scale - EXITING)
m2
o<i0> endif
o<i1> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(print, arc1: bad dir=#<dir> - EXITING)
(debug, arc1: bad dir=#<dir> - EXITING)
(AXIS,notify, arc1: bad dir - EXITING)
m2
o<i1> endif
o<i2> if [[#<inside> NE 1] AND [#<inside> NE 0]]
(print, arc1: bad inside specifier: #<inside> - EXITING)
(debug, arc1: bad inside specifier: #<inside> - EXITING)
(AXIS,notify, arc1: bad inside specifier - EXITING)
m2
o<i2> endif
o<i3> if [#<angle> LT #<min_angle>]
(print, arc1: angle too small: #<angle> - EXITING)
(debug, arc1: angle too small: #<angle> - EXITING)
(AXIS,notify, arc1: angle too small - EXITING)
m2
o<i3> endif
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
o<iftool> if [[#<tooldiam> GT #<width>] AND [#<inside> EQ 1]]
(print, arc1: tooldiam too big: #<tooldiam> - EXITING)
(debug, arc1: tooldiam too big: #<tooldiam> - EXITING)
(AXIS,notify, arc1: tooldiam too big - EXITING)
m2
o<iftool> endif
; construct arc parallel to x axis (for transformation later)
#<slot_r> = [#<width>/2]
#<phi> = [90 - #<angle>/2]
#<distance> = [2 * #<arc_r> * COS[#<phi>]] ; between endpoints
; (xa,ya), (xb,yb), ... are points on arc
; (vxas,vyas), (vxbs,vybs), ... are vectors to subarc centers (short ones)
; (vxal,vyal), (vxbl,vybl), ... are vectors to subarc centers (long ones)
; start point is at center of outside arc:
#<x0> = 0
#<y0> = [#<slot_r> + #<arc_r> * [1 - sin[#<phi>]]]
#<vx0> = 0
#<vy0> = [0 - #<arc_r> - #<slot_r>]
#<xa> = [0 + #<distance>/2 + #<slot_r> * cos[#<phi>]]
#<ya> = [0 + #<slot_r> * sin[#<phi>]]
#<vxas> = [0 - #<slot_r> * cos[#<phi>]]
#<vyas> = [0 - #<slot_r> * sin[#<phi>]]
#<vxal> = [0 - [#<arc_r> + #<slot_r>] * cos[#<phi>]]
#<vyal> = [0 - [#<arc_r> + #<slot_r>] * sin[#<phi>]]
#<xb> = [0 + #<distance>/2 - #<slot_r> * cos[#<phi>]]
#<yb> = [0 - #<slot_r> * sin[#<phi>]]
#<vxbs> = [0 + #<slot_r> * cos[#<phi>]]
#<vybs> = [0 + #<slot_r> * sin[#<phi>]]
#<vxbl> = [0 - [#<arc_r> - #<slot_r>] * cos[#<phi>]]
#<vybl> = [0 - [#<arc_r> - #<slot_r>] * sin[#<phi>]]
#<xc> = [0 - #<distance>/2 + #<slot_r> * cos[#<phi>]]
#<yc> = [0 - #<slot_r> * sin[#<phi>]]
#<vxcs> = [0 - #<slot_r> * cos[#<phi>]]
#<vycs> = [0 + #<slot_r> * sin[#<phi>]]
#<vxcl> = [0 + [#<arc_r> - #<slot_r>] * cos[#<phi>]]
#<vycl> = [0 - [#<arc_r> - #<slot_r>] * sin[#<phi>]]
#<xd> = [0 - #<distance>/2 - #<slot_r> * cos[#<phi>]]
#<yd> = [0 + #<slot_r> * sin[#<phi>]]
#<vxds> = [0 + #<slot_r> * cos[#<phi>]]
#<vyds> = [0 - #<slot_r> * sin[#<phi>]]
#<vxdl> = [0 + [#<arc_r> + #<slot_r> ] * cos[#<phi>]]
#<vydl> = [0 - [#<arc_r> + #<slot_r> ] * sin[#<phi>]]
;# this offset makes center at x,y = 0,0 for convenience:
#<yf> = [0 - #<arc_r> * [1 - sin[#<phi>]]]
#<y0> = [#<yf> + #<y0>]
#<ya> = [#<yf> + #<ya>]
#<yb> = [#<yf> + #<yb>]
#<yc> = [#<yf> + #<yc>]
#<yd> = [#<yf> + #<yd>]
; choose points according to dir:
o<ifdir> if [#<dir> EQ 2] ; cw 0->a->b->c->d->0
#<dir0> = 2 ; pre entry
#<dir1> = 2 ; most
#<dir2> = 3 ; inside of arc
; 1/4 circle arc entry move
#<xp> = [#<x0> - #<tooldiam>/2]
#<yp> = [#<y0> - #<tooldiam>/2]
#<vxp> = [#<tooldiam>/2]
#<vyp> = 0
#<x1> = #<xa>
#<y1> = #<ya>
#<vx1> = #<vxas>
#<vy1> = #<vyas>
#<x2> = #<xb>
#<y2> = #<yb>
#<vx2> = #<vxbl>
#<vy2> = #<vybl>
#<x3> = #<xc>
#<y3> = #<yc>
#<vx3> = #<vxcs>
#<vy3> = #<vycs>
#<x4> = #<xd>
#<y4> = #<yd>
#<vx4> = #<vxdl>
#<vy4> = #<vydl>
o<ifdir> else ; ccw 0->d->c->b->a->0
#<dir0> = 3 ; pre entry
#<dir1> = 3 ; most
#<dir2> = 2 ; inside of arc
; 1/4 circle arc entry move
#<xp> = [#<x0> + #<tooldiam>/2]
#<yp> = [#<y0> - #<tooldiam>/2]
#<vxp> = [0 - #<tooldiam>/2]
#<vyp> = 0
#<x1> = #<xd>
#<y1> = #<yd>
#<vx1> = #<vxds>
#<vy1> = #<vyds>
#<x2> = #<xc>
#<y2> = #<yc>
#<vx2> = #<vxcl>
#<vy2> = #<vycl>
#<x3> = #<xb>
#<y3> = #<yb>
#<vx3> = #<vxbs>
#<vy3> = #<vybs>
#<x4> = #<xa>
#<y4> = #<ya>
#<vx4> = #<vxal>
#<vy4> = #<vyal>
o<ifdir> endif
; apply rotation, scaling, offsets
o<move> call [#<xp>][#<yp>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<xp> = #<_move:x>
#<yp> = #<_move:y>
o<move> call [#<x0>][#<y0>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x0> = #<_move:x>
#<y0> = #<_move:y>
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x3> = #<_move:x>
#<y3> = #<_move:y>
o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x4> = #<_move:x>
#<y4> = #<_move:y>
; vectors to arc centers: just rotate and scale, no offset
o<move> call [#<vxp>][#<vyp>][#<rotate>][#<scale>][0][0]
#<vxp> = #<_move:x>
#<vyp> = #<_move:y>
o<move> call [#<vx0>][#<vy0>][#<rotate>][#<scale>][0][0]
#<vx0> = #<_move:x>
#<vy0> = #<_move:y>
o<move> call [#<vx1>][#<vy1>][#<rotate>][#<scale>][0][0]
#<vx1> = #<_move:x>
#<vy1> = #<_move:y>
o<move> call [#<vx2>][#<vy2>][#<rotate>][#<scale>][0][0]
#<vx2> = #<_move:x>
#<vy2> = #<_move:y>
o<move> call [#<vx3>][#<vy3>][#<rotate>][#<scale>][0][0]
#<vx3> = #<_move:x>
#<vy3> = #<_move:y>
o<move> call [#<vx4>][#<vy4>][#<rotate>][#<scale>][0][0]
#<vx4> = #<_move:x>
#<vy4> = #<_move:y>
s #<rpm> m3
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
f#<feedrate>
g0 z#<zsafe>
g0 x#<xp> y#<yp> ; pre-entry point
o<ifi0> if [#<inside> EQ 1]
o<ifi1> if [#<dir> EQ 2]
/g42 ;# cutter compensation right of path
o<ifi1> else
/g41 ;# cutter compensation left of path
o<ifi1> endif
o<ifi0> else
o<ifi2> if [#<dir> EQ 2]
/g41 ;# cutter compensation left of path
o<ifi2> else
/g42 ;# cutter compensation right of path
o<ifi2> endif
o<ifi0> endif
; entry with cutter radius compensation
g#<dir0> x#<x0> y#<y0> i #<vxp> j #<vyp>
g1 z#<zstart>
#<zcurrent> = [#<zstart> - #<zincr>]
o<wh1> while [#<zcurrent> GT [0 - #<cutdepth>]]
g#<dir1> x#<x1> y#<y1> i#<vx0> j#<vy0> z #<zcurrent>
g#<dir1> x#<x2> y#<y2> i#<vx1> j#<vy1>
g#<dir2> x#<x3> y#<y3> i#<vx2> j#<vy2>
g#<dir1> x#<x4> y#<y4> i#<vx3> j#<vy3>
g#<dir1> x#<x0> y#<y0> i#<vx4> j#<vy4>
#<zcurrent>=[#<zcurrent>-#<zincr>]
o<wh1> endwhile
g#<dir1> x#<x1> y#<y1> i#<vx0> j#<vy0> z [0 - #<cutdepth>]
g#<dir1> x#<x2> y#<y2> i#<vx1> j#<vy1>
g#<dir2> x#<x3> y#<y3> i#<vx2> j#<vy2>
g#<dir1> x#<x4> y#<y4> i#<vx3> j#<vy3>
g#<dir1> x#<x0> y#<y0> i#<vx4> j#<vy4>
g#<dir1> x#<x1> y#<y1> i#<vx0> j#<vy0>
g0 z#<zsafe>
g40 ;# cancel cutter radius compensation
o<arc1> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@@ -0,0 +1,54 @@
(info: arc2: specify arc center, offset, angle)
; dir: 2 for cw, 3 for ccw
; inside: 1 for inside, else outside
; Specify:
; (xoff,yoff) == arc center
; (xctr,yctr) == center of rotation
; angle == anglular spread of arc
; width == width of arc
; calls arc1.ngc
o<arc2> sub
#<toolno> = #1 (=1)
#<dir> = #2 (=2 2:cw 3:ccw)
#<inside> = #3 (=1 1:inside 0:outside)
#<rpm> = #4 (=2000)
#<feedrate> = #5 (=100)
#<zincr> = #6
#<cutdepth> = #7
#<zsafe> = #8 (=0.25)
#<zstart> = #9 (=0)
#<width> = #10 (=.25)
#<angle> = #11 (=15)
#<xoff> = #12 (=2)
#<yoff> = #13 (=1)
#<xctr> = #14 (=0)
#<yctr> = #15 (=0)
#<scale> = #16 (=1)
#<spin_notify> = #17 (=0)
#<use_g43> = #18 (=1)
#<h_for_g43> = #19 (=0)
#<verbose> = #20 (=0)
#<min_separation> = .1
#<delx> = [#<xoff> - #<xctr>]
#<dely> = [#<yoff> - #<yctr>]
#<arc_r> = [SQRT[#<dely>*#<dely> + #<delx>*#<delx>]]
#<rotate> = [-90 + ATAN[#<dely>]/[#<delx>]]
o<if0> if [#<arc_r> LT #<min_separation>]
(print, arc2: separation too small: #<arc_r> - EXITING)
(debug, arc2: separation too small: #<arc_r> - EXITING)
(AXIS,notify, arc2: separation too small - EXITING)
m2
o<if0> endif
o<arc1>call[#<toolno>][#<dir>][#<inside>][#<rpm>][#<feedrate>][#<zincr>][#<cutdepth>][#<zsafe>][#<zstart>][#<width>][#<angle>][#<arc_r>][#<rotate>][#<xoff>][#<yoff>][#<scale>][#<spin_notify>][#<use_g43>][#<h_for_g43>][#<verbose>]
o<arc2> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -0,0 +1,89 @@
(info: backlash measurement utility, use with dial indicator)
o<backlash> sub
#<axis> = #1 (= 0 0=x 1=y 2=z)
#<p1> = #2 (= 1.1)
#<p2> = #3 (= 2)
#<fraction> = #4 (= 0.1)
#<feedrate> = #5 (= 10)
#<count> = #6 (= 10)
o<l10> if [#<p1> GT #<p2>]
#<vmin> = #<p2>
#<vmax> = #<p1>
o<l10> else
#<vmin> = #<p1>
#<vmax> = #<p2>
o<l10> endif
#<delv> = [#<vmax> - #<vmin>]
o<l20> if [ABS[#<delv>] GT 0.9] (protect indicator)
(debug, backlash: move too big for indicator #<delv> - EXITING)
(print, backlash: move too big for indicator #<delv> - EXITING)
(AXIS,notify, backlash: move too big for indicator - EXITING)
m2
o<l20> endif
o<l30> if [[#<fraction> GT .99] OR [#<fraction> LT .01]]
(debug, backlash: bad fraction: #<fraction> - EXITING)
(print, backlash: bad fraction: #<fraction> - EXITING)
(AXIS,notify, bad fraction - EXITING)
m2
o<l30> endif
#<vzero> = [#<vmin> + [#<vmax> - #<vmin>] * #<fraction>]
#<ok> = 0
f #<feedrate> g1
o<whl> while [#<count> GT 0]
o<xxx> if [#<axis> EQ 0]
#<ok> = 1
x #<vmin>
x #<vzero>
(debug, set indicator ZERO, S to continue)
m0 (mandatory stop)
M110
x #<vmax>
x #<vzero>
o<xxx> endif
o<yyy> if [#<axis> EQ 1]
#<ok> = 1
y #<vmin>
y #<vzero>
(debug, set indicator ZERO, S to continue)
m0 (mandatory stop)
M110
y #<vmax>
y #<vzero>
o<yyy> endif
o<zzz> if [#<axis> EQ 2]
#<ok> = 1
z #<vmin>
z #<vzero>
(debug, set indicator ZERO, S to continue)
m0 (mandatory stop)
M110
z #<vmax>
z #<vzero>
o<zzz> endif
o<ccc> if [#<axis> EQ 5]
#<ok> = 1
c #<vmin>
c #<vzero>
(debug, set indicator ZERO, S to continue)
m0 (mandatory stop)
M110
c #<vmax>
c #<vzero>
o<ccc> endif
#<count> = [#<count> - 1]
(debug, READ indicator, S to continue)
m0 (mandatory stop)
M110
o<whl> endwhile
o<l60> if [#<ok> EQ 0]
(debug, bad axis specifier: #<axis>)
(print, bad axis specifier: #<axis>)
o<l60> endif
o<backlash> endsub

View File

@@ -0,0 +1,54 @@
(info: db25 connector -- uses iquad.ngc)
; centered at origin, use offsets to relocate
o<db25> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<dir> = #3 (=2 2conv|3climb)
#<feedrate> = #4 (=10)
#<cutdepth> = #5 (=.1)
#<zincr> = #6 (=.02)
#<zsafe> = #7 (=0.2)
#<zstart> = #8 (=0)
#<xoff> = #9 (=0)
#<yoff> = #10 (=0)
#<rotate> = #11 (=0)
#<use_g43> = #12 (=1)
#<h_for_g43>= #13 (=0)
#<verbose> = #14 (=0)
; reject tools that are too big
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = #5410
o<if0> if [#<tooldiam> Gt 0.12501]
(debug, db25: tooldiam too big: #<tooldiam> - EXITING)
(print, db25: tooldiam too big: #<tooldiam> - EXITING)
(AXIS,notify, db25: tooldiam too big - EXITING)
m2
o<if0> endif
; http://www.interfacebus.com/Connector_D-Sub_Mechanical_Dimensions.html
; mounting hole spacing is 1.857
#<xlong> = 1.635
#<xlong> = 1.675 ; adjust to allow use of 0.125 cutter diameter
#<y> = 0.432
#<xshort> = [#<xlong> - 2 * #<y> * tan[10]]
; center at origin
#<x1> = [0.5 * #<xlong>]
#<y1> = [0.5 * #<y>]
#<x2> = [ 0.5 * #<xshort>]
#<y2> = [-0.5 * #<y>]
#<x3> = [-0.5 * #<xshort>]
#<y3> = [-0.5 * #<y>]
#<x4> = [-0.5 * #<xlong>]
#<y4> = [ 0.5 * #<y>]
#<scale> = 1.0
o<iquad>call[#<toolno>][#<rpm>][#<dir>][#<feedrate>][#<cutdepth>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>]
o<db25> endsub

View File

@@ -0,0 +1,67 @@
(Adapted from Program to mill a flowsnake.ngc by K. Lerman)
(info: gosper -- recursion demo -- line is x1,y1 to x2,y2)
o<gosper> sub
#<rpm> = #1 (=2000)
#<zcut> = #2 (=.010 depth of cut)
#<feedrate> = #3 (=10)
#<zsafe> = #4 (=0.5 safety height)
#<x1> = #5 (=-0.866 line x1)
#<y1> = #6 (=-0.5 line y1)
#<x2> = #7 (= 0.866 line x2)
#<y2> = #8 (=-0.5 line y2)
#<level> = #9 (=3 recursion lvl)
#<scale> = #10 (=1)
#<rotate> = #11 (=0)
#<xoff> = #12 (=-3)
#<yoff> = #13 (=-3)
(debug, feature: #<_feature:>)
(debug, remaining: #<_remaining_features:>)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
o<t1> if [#<level> LT 0]
#<level> = 0
(debug, level set to #<level>)
o<t1> endif
o<t2> if [#<level> GT 4]
#<level> = 4
(debug, level reduced to #<level>)
o<t2> endif
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
#<len1> = #<_move:len>
#<phi1> = #<_move:phi>
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
#<len2> = #<_move:len>
#<phi2> = #<_move:phi>
#<fr> = #<feedrate>
s#<rpm> M3 (spindle on)
o<spin> call [#<rpm>]
g0 z #<zsafe>
g0 x #<x1> y #<y1>
f #<feedrate>
g1 z [0 - #<zcut>]
#<dely> = [#<y2> - #<y1>]
#<delx> = [#<x2> - #<x1>]
#<len> = [SQRT[#<delx>*#<delx> + #<dely>*#<dely>]]
#<theta> = ATAN [#<dely>]/[#<delx>] (degrees)
(compute p3 for equilateral triangle)
#<p3x> = [#<x1> + #<len> * COS[#<theta> + 60]]
#<p3y> = [#<y1> + #<len> * SIN[#<theta> + 60]]
(three sides of equilateral triangle)
o<gosper_sub> call [#<level>][#<x1>] [#<y1>] [#<x2>] [#<y2>] [#<fr>]
o<gosper_sub> call [#<level>][#<x2>] [#<y2>] [#<p3x>][#<p3y>][#<fr>]
o<gosper_sub> call [#<level>][#<p3x>][#<p3y>][#<x1>] [#<y1>] [#<fr>]
g0 z #<zsafe>
o<gosper> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -0,0 +1,154 @@
(info: helix: in/out cutting, cw/ccw dir with radius comp, D-holes)
o<helix> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<dir> = #4 (=3 2:cw, 3:ccw)
#<inside> = #5 (=1 1:in, 0:out)
#<cutdepth> = #6 (z cutdepth)
#<zincr> = #7 (z increment)
#<zsafe> = #8 (=0.5)
#<x> = #9 (x center)
#<y> = #10 (y center)
#<hdiam> = #11 (diameter)
#<faceangle> = #12 (=0 face angle)
#<d_angle> = #13 (=0 d angle)
#<zstart> = #14 (=0)
#<spin_notify>= #15 (=0)
#<use_g43> = #16 (=1)
#<h_for_g43> = #17 (=0)
#<verbose> = #18 (=0)
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
#<hr> = [#<hdiam>/2]
#<cutdepth> = [-1 * #<cutdepth>]
o<l00> if [#<cutdepth> GT 0.0]
(debug, helix: bad cutdepth #<cutdepth> - EXITING)
(print, helix: bad cutdepth #<cutdepth> - EXITING)
(AXIS,notify, helix: bad cutdepth - EXITING)
m2
o<l00> endif
#<zincr> = [-1 * #<zincr>]
o<l01> if [#<zincr> GT 0.0]
(debug, helix: bad zincr #<zincr> - EXITING)
(print, helix: bad zincr #<zincr> - EXITING)
(AXIS,notify, helix: bad zincr - EXITING)
m2
o<l01> endif
o<l02> if [[#<inside> NE 0] AND [#<inside> NE 1]]
(debug, helix: bad inside specifier #<inside> - EXITING)
(print, helix: bad inside specifier #<inside> - EXITING)
(AXIS,notify, helix: bad inside specifier - EXITING)
m2
o<l02> endif
o<l03> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, helix: bad dir specifier #<dir> - EXITING)
(print, helix: bad dir specifier #<dir> - EXITING)
(AXIS,notify, helix: bad dir specifier - EXITING)
m2
o<l03> endif
#<rtool> = [#<tooldiam> / 2.0]
G40 (cutter radius compensation off)
s#<rpm> m3 (spindle cw)
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
f #<feedrate>
#<delta> = #<d_angle>
#<d2> = [#<d_angle>/2]
(to avoid gouging, start point is arc opposite flat)
(start point x0,y0 and vector to center vx0,vy0)
#<x0> = [#<x> + #<hr> * cos[#<faceangle> + 180]]
#<y0> = [#<y> + #<hr> * sin[#<faceangle> + 180]]
#<vx0> = [#<hr> * cos[#<faceangle>]]
#<vy0> = [#<hr> * sin[#<faceangle>]]
o<entry> call [#<inside>][#<dir>][#<tooldiam>][#<x0>][#<y0>][#<x>][#<y>]
#<prex> = #<_entry:prex> (pre entry point)
#<prey> = #<_entry:prey>
#<vxe> = #<_entry:vx> (vector to arc center)
#<vye> = #<_entry:vy>
(points at the ends of the arc)
(x1,y1 start point of flat, vx1,vy1 vector to center)
(x2,y2 start point of flat, vx2,vy2 vector to center)
o<l08> if [#<dir> eq 2] (cw)
#<x1> = [#<x> + #<hr> * cos[#<faceangle> + #<d2>]]
#<y1> = [#<y> + #<hr> * sin[#<faceangle> + #<d2>]]
#<vx1> = [#<hr> * cos[#<faceangle> + #<d2> + 180]]
#<vy1> = [#<hr> * sin[#<faceangle> + #<d2> + 180]]
#<x2> = [#<x> + #<hr> * cos[#<faceangle> - #<d2>]]
#<y2> = [#<y> + #<hr> * sin[#<faceangle> - #<d2>]]
#<vx2> = [#<hr> * cos[#<faceangle> - #<d2> + 180]]
#<vy2> = [#<hr> * sin[#<faceangle> - #<d2> + 180]]
o<l08> else
#<x2> = [#<x> + #<hr> * cos[#<faceangle> + #<d2>]]
#<y2> = [#<y> + #<hr> * sin[#<faceangle> + #<d2>]]
#<vx2> = [#<hr> * cos[#<faceangle> + #<d2> + 180]]
#<vy2> = [#<hr> * sin[#<faceangle> + #<d2> + 180]]
#<x1> = [#<x> + #<hr> * cos[#<faceangle> - #<d2>]]
#<y1> = [#<y> + #<hr> * sin[#<faceangle> - #<d2>]]
#<vx1> = [#<hr> * cos[#<faceangle> - #<d2> + 180]]
#<vy1> = [#<hr> * sin[#<faceangle> - #<d2> + 180]]
o<l08> endif
g0 z #<zsafe>
o<l10> if [#<inside> NE 0] (inside)
o<l20> if [#<dir> eq 2] (cw)
(debug conventional CW,INSIDE)
g0 x#<prex> y#<prey> z #<zsafe>
/ g42 (cutter radius comp right of path)
g2 x#<x0> y#<y0> i#<vxe> j#<vye>
o<l20> else (ccw)
(debug climb CCW,INSIDE)
g0 x#<prex> y#<prey> z #<zsafe>
/ g41 (cutter radius comp left of path)
g3 x#<x0> y#<y0> i#<vxe> j#<vye>
o<l20> endif
o<l10> else (outside)
o<l30> if [#<dir> eq 2] (2 ==> cw)
(debug,climb CW,OUTSIDE)
g0 x#<prex> y#<prey> z #<zsafe>
/ g41 (cutter radius comp left of path)
g3 x#<x0> y#<y0> i#<vxe> j#<vye>
o<l30> else (3 ==> ccw)
(debug conventional CCW,OUTSIDE)
g0 x#<prex> y#<prey> z #<zsafe>
/ g42 (cutter radius comp right of path)
g2 x#<x0> y#<y0> i#<vxe> j#<vye>
o<l30> endif
o<l10> endif
(entry complete: #<x0>,#<y0>,#<zsafe>)
g0 z [#<zstart> + 0.05] (hardcoded delta)
g1 z #<zstart> (plunge)
#<zcurrent> = #<zstart>
#<_:pass> = 1 (colon makes hidden global var)
o<l30> while [#<zcurrent> GT #<cutdepth>]
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<l32> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<l32> endif
g#<dir> x#<x1> y#<y1> i#<vx0> j#<vy0> z#<zcurrent>
g1 x#<x2> y#<y2>
g#<dir> x#<x0> y#<y0> i#<vx2> j#<vy2> z#<zcurrent>
#<_:pass> = [#<_:pass> + 1]
o<l30> endwhile
(final traverse at full depth)
g#<dir> x#<x1> y#<y1> i#<vx0> j#<vy0> z#<zcurrent>
g1 x#<x2> y#<y2>
g#<dir> x#<x0> y#<y0> i#<vx2> j#<vy2> z#<zcurrent>
g0 z#<zsafe>
g40
o<helix> endsub

View File

@@ -0,0 +1,29 @@
(info: helix_rtheta: specify center with r,theta, uses helix.ngc)
o<helix_rtheta> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<dir> = #4 (=3 2:cw, 3:ccw)
#<inside> = #5 (=1 1:in, 0:out)
#<cutdepth> = #6 (z cutdepth)
#<zincr> = #7 (z increment)
#<zsafe> = #8 (=0.5)
#<hdiam> = #9 (hole diameter)
#<faceangle> = #10 (=0 face angle)
#<d_angle> = #11 (=0 d angle)
#<r> = #12 (r center)
#<theta> = #13 (theta center)
#<zstart> = #14 (=0)
#<spin_notify>= #15 (=0)
#<use_g43> = #16 (=1)
#<h_for_g43> = #17 (=0)
#<verbose> = #18 (=0)
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + 0.001]
#<x> = [#<r> * COS[#<theta>]]
#<y> = [#<r> * SIN[#<theta>]]
o<helix>call [#<toolno>][#<rpm>][#<feedrate>][#<dir>][#<inside>][#<cutdepth>][#<zincr>][#<zsafe>][#<x>][#<y>][#<hdiam>][#<faceangle>][#<d_angle>][#<zstart>][#<spin_notify>][#<use_g43>][#<h_for_g43>][#<verbose>]
o<helix_rtheta> endsub

View File

@@ -0,0 +1,45 @@
(info: hole_circle: equally spaced, uses helix.ngc)
o<hole_circle> sub
#<toolno> = #1
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<dir> = #4 (=3 2:cw, 3:ccw)
#<inside> = #5 (=1 1:in, 0:out)
#<cutdepth> = #6
#<zincr> = #7
#<zsafe> = #8 (=0.5)
#<diam> = #9 (Circle diameter)
#<theta> = #10 (=0 start theta)
#<hdiam> = #11 (hole diameter)
#<n> = #12 (=4 N holes)
#<zstart> = #13 (=0)
#<xctr> = #14 (= 0)
#<yctr> = #15 (= 0)
#<spin_notify>= #16 (= 0)
#<use_g43> = #17 (=1)
#<h_for_g43> = #18 (=0)
#<verbose> = #19 (=0)
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
#<i> = 0
#<deltheta> = [360/#<n>]
#<faceangle> = 0 (notused helix item)
#<d_angle> = 0 (notused helix item)
#<r> = [#<diam> / 2]
o<l20> while [#<i> LT #<n>]
#<x> = [#<xctr> + #<r> * COS[#<theta>]]
#<y> = [#<yctr> + #<r> * SIN[#<theta>]]
o<helix>call [#<toolno>][#<rpm>][#<feedrate>][#<dir>][#<inside>][#<cutdepth>][#<zincr>][#<zsafe>][#<x>][#<y>][#<hdiam>][#<faceangle>][#<d_angle>][#<zstart>][#<spin_notify>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<i> = [#<i> + 1]
#<theta> = [#<theta> + #<deltheta>]
#<_feature:> = #<i> (using _feature: here disables stop)
(that would occur in helix at spin sub call)
o<l20> endwhile
o<hole_circle> endsub

View File

@@ -0,0 +1,218 @@
(require: angle at intersection of p1-2 and p1-4 must be obtuse)
(cw traverse: p1,p2,p3,p4)
(ccw traverse: p1,p4,p3,p2)
(info: ihex: internal hexagon, cw/ccw dir, radius compensation)
o<ihex> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<dir> = #4 (=2 2conv | 3climb)
#<flatd> = #5 (distance across flats)
#<cutdepth> = #6
#<zincr> = #7
#<zsafe> = #8 (=0.2)
#<zstart> = #9 (=0)
#<scale> = #10 (=1)
#<rotate> = #11 (=0)
#<xoff> = #12 (=0)
#<yoff> = #13 (=0)
#<spin_notify> = #14 (=0)
#<use_g43> = #15 (=1)
#<h_for_g43> = #16 (=0)
#<verbose> = #17 (=0)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
o<dir> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, ihex: direction must be 2 or 3 - EXITING)
(print, ihex: direction must be 2 or 3 - EXITING)
(AXIS,notify, ihex: direction must be 2 or 3 - EXITING)
m2
o<dir> endif
#<f> = [#<flatd>/2]
#<p> = [#<f>/cos[30]]
#<pcos60> = [#<p> * cos[60]]
#<psin60> = [#<p> * sin[60]]
(p1 -> p2 -> is cw)
(apply scale,rotate, then offset to all input points)
#<x1> = #<p>
#<y1> = 0
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
#<x2> = #<pcos60>
#<y2> = [0 - #<psin60>]
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
#<x3> = [0 - #<pcos60>]
#<y3> = [0 - #<psin60>]
o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x3> = #<_move:x>
#<y3> = #<_move:y>
#<x4> = [0 - #<p>]
#<y4> = 0
o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x4> = #<_move:x>
#<y4> = #<_move:y>
#<x5> = [0 -# <pcos60>]
#<y5> = #<psin60>
o<move> call [#<x5>][#<y5>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x5> = #<_move:x>
#<y5> = #<_move:y>
#<x6> = #<pcos60>
#<y6> = #<psin60>
o<move> call [#<x6>][#<y6>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x6> = #<_move:x>
#<y6> = #<_move:y>
#<r> = [#<tooldiam>/2]
#<cutdepth> = [0 - #<cutdepth>]
#<zincr> = [0 - #<zincr>]
(get lengths and angles for connecting lines)
o<line> call [#<x1>][#<y1>][#<x2>][#<y2>]
#<phi12> = #<_line:phi>
o<line> call [#<x2>][#<y2>][#<x3>][#<y3>]
#<len23> = #<_line:len>
#<phi23> = #<_line:phi>
#<cos23> = #<_line:cos>
#<sin23> = #<_line:sin>
o<line> call [#<x1>][#<y1>][#<x6>][#<y6>]
#<phi16> = #<_line:phi>
o<line> call [#<x6>][#<y6>][#<x5>][#<y5>]
#<len65> = #<_line:len>
#<phi65> = #<_line:phi>
#<cos65> = #<_line:cos>
#<sin65> = #<_line:sin>
g40 (cutter radius compensation off)
f #<feedrate>
s #<rpm> m3 (spindle cw)
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
g0 z#<zsafe>
#<zcurrent> = #<zstart>
#<pass> = 1
o<wh010> while [#<zcurrent> GT #<cutdepth>]
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<wh020> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<wh020> endif
o<wh030> if [#<pass> GT 100]
(debug, ihex: too many passes - EXITING)
(print, ihex: too many passes - EXITING)
(AXIS,notify, ihex: too many passes - EXITING)
m2
o<wh030> endif
o<dir00> if [#<dir> EQ 2]
o<aaa10> if [#<pass> EQ 1]
(arc entry along line1-2 where corner 1 is obtuse)
#<ax> = [#<x1> + 1 * #<r> * cos[#<phi12>]] (entry)
#<ay> = [#<y1> + 1 * #<r> * sin[#<phi12>]]
#<bx> = [#<ax> + 2 * #<r> * sin[#<phi12>]] (preentry 1)
#<by> = [#<ay> - 2 * #<r> * cos[#<phi12>]]
#<cx> = [#<bx> + #<r> * cos[#<phi12>]] (preentry 2)
#<cy> = [#<by> + #<r> * sin[#<phi12>]]
#<vx> = [0 - #<r> * sin[#<phi12>]] (r vector)
#<vy> = [0 + #<r> * cos[#<phi12>]]
g0 x #<cx> y #<cy> (preentry 1)
g0 x #<bx> y #<by> (preentry 2)
/ g42 (cutter radius comp right of path)
g2 x #<ax> y #<ay> i #<vx> j #<vy> (arc entry)
#<xfinal_a> = [#<x2>]
#<yfinal_a> = [#<y2>]
(go along the 2-->3 line to exit)
(angle between 1-->2 and 2-->3)
(only necessary for acute angles)
#<angle> = [180 + #<phi23> - #<phi12>]
#<elen> = [#<r> / ABS[TAN[#<angle>/2]]]
#<k> = [#<elen>/#<len23>]
(print angle=#<angle> elen=#<elen> k=#<k>)
o<aaa20> if [#<k> GE 1]
(debug, ihex: can't get in final corner k=#<k> - EXITING)
(print, ihex: can't get in final corner k=#<k> - EXITING)
(AXIS,notify, ihex: can't get in final corner - EXITING)
m2
o<aaa20> endif
#<xfinal_b> = [#<x2> + #<k> * #<len23> * #<cos23>]
#<yfinal_b> = [#<y2> + #<k> * #<len23> * #<sin23>]
g1 z #<zstart> (plunge)
o<aaa10> endif
x #<x2> y #<y2> z#<zcurrent>
x #<x3> y #<y3>
x #<x4> y #<y4>
x #<x5> y #<y5>
x #<x6> y #<y6>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<dir00> else (dir EQ 3 CCW)
o<bbb10> if [#<pass> EQ 1]
(arc entry along line4-1 where corner 1 is obtuse)
#<ax> = [#<x1> + 1 * #<r> * cos[#<phi16>]] (entry)
#<ay> = [#<y1> + 1 * #<r> * sin[#<phi16>]]
#<bx> = [#<ax> - 2 * #<r> * sin[#<phi16>]] (preentry 1)
#<by> = [#<ay> + 2 * #<r> * cos[#<phi16>]]
#<cx> = [#<bx> + #<r> * cos[#<phi16>]] (preentry 2)
#<cy> = [#<by> + #<r> * sin[#<phi16>]]
#<vx> = [0 + #<r> * sin[#<phi16>]] (r vector)
#<vy> = [0 - #<r> * cos[#<phi16>]]
g0 x #<cx> y #<cy> (preentry 1)
g0 x #<bx> y #<by> (preentry 2)
/ g41 (cutter radius comp left of path)
g3 x #<ax> y #<ay> i #<vx> j #<vy> (arc entry)
#<xfinal_a> = [#<x6>]
#<yfinal_a> = [#<y6>]
(go along the 4-->3 line to exit)
(angle between 4-->3 and 1-->4)
(only necessary for acute angles)
#<angle> = [180 - #<phi16> + #<phi65>]
#<elen> = [#<r> / ABS[TAN[#<angle>/2]]]
#<k> = [#<elen>/#<len65>]
o<bbb20> if [#<k> GE 1]
(debug, ihex: can't get in corner k=#<k> - EXITING)
(print, ihex: can't get in corner k=#<k> - EXITING)
(AXIS,notify, ihex: can't get in corner - EXITING)
m2
o<bbb20> endif
#<xfinal_b> = [#<x6> + 1.01* #<k> * #<len65> * #<cos65>]
#<yfinal_b> = [#<y6> + 1.01* #<k> * #<len65> * #<sin65>]
g1 z #<zstart> (plunge)
o<bbb10> endif
x #<x6> y #<y6> z#<zcurrent>
x #<x5> y #<y5>
x #<x4> y #<y4>
x #<x3> y #<y3>
x #<x2> y #<y2>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<dir00> endif
o<wh010> endwhile
g1 x #<xfinal_a> y #<yfinal_a>
g1 x #<xfinal_b> y #<yfinal_b>
g0 z #<zsafe>
g40
o<ihex> endsub

View File

@@ -0,0 +1,179 @@
(inside quadrangle, vertex 1 should be largest)
(computes direction for polygon cw or ccw and swaps indices if required)
(ok for non-pathological 4 sided polygons including convex)
(info: iquad: internal quadrilateral, four x,y points, cw/ccw dir, radius comp)
o<iquad> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=1)
#<dir> = #3 (=2 2conv|3climb)
#<feedrate> = #4 (=10)
#<cutdepth> = #5 (=.1)
#<zincr> = #6 (=.02)
#<zsafe> = #7 (=0.2)
#<zstart> = #8 (=0)
#<x1> = #9
#<y1> = #10
#<x2> = #11
#<y2> = #12
#<x3> = #13
#<y3> = #14
#<x4> = #15
#<y4> = #16
#<scale> = #17 (=1)
#<rotate> = #18 (=0)
#<xoff> = #19 (=0)
#<yoff> = #20 (=0)
#<spin_notify> = #21 (=0)
#<use_g43> = #22 (=1)
#<h_for_g43> = #23 (=0)
#<verbose> = #24 (=0)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
o<l00> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, iquad: bad direction #<dir> - EXITING)
(print, iquad: bad direction #<dir> - EXITING)
(AXIS,notify, iquad: bad direction - EXITING)
m2
o<l00> endif
(compute direction eg cw,ccw for points as specified:)
o<dir> call [4][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>]
#<pointsdir> = #<_dir:>
o<l20> if [#<pointsdir> NE #<dir>]
(print swap for pointsdir=#<pointsdir> user:#<dir>)
(swap 1234 --> 1432)
#<xt> = #<x2>
#<yt> = #<y2>
#<x2> = #<x4>
#<y2> = #<y4>
#<x4> = #<xt>
#<y4> = #<yt>
o<l20> endif
(apply scale, rotate, then offset to all input points)
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x3> = #<_move:x>
#<y3> = #<_move:y>
o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x4> = #<_move:x>
#<y4> = #<_move:y>
#<r> = [#<tooldiam>/2]
#<cutdepth> = [0 - #<cutdepth>]
#<zincr> = [0 - #<zincr>]
(get lengths and angles for connecting lines)
o<line> call [#<x1>][#<y1>][#<x2>][#<y2>]
#<cos12> = #<_line:cos>
#<sin12> = #<_line:sin>
o<line> call [#<x2>][#<y2>][#<x3>][#<y3>]
#<cos23> = #<_line:cos>
#<sin23> = #<_line:sin>
(compute angles at line intersections:)
o<dot> call [#<x4>][#<y4>][#<x1>][#<y1>][#<x2>][#<y2>]
#<ang412> = #<_dot:ang>
o<dot> call [#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>]
#<ang123> = #<_dot:ang>
g40 (cutter radius compensation off)
f #<feedrate>
s #<rpm> m3 (spindle cw)
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
g0 z#<zsafe>
#<zcurrent> = #<zstart>
#<pass> = 1
o<wh010> while [#<zcurrent> GT #<cutdepth>]
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<wh020> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<wh020> endif
o<wh030> if [#<pass> GT 100]
(debug, iquad: too many passes - EXITING)
(print, iquad: too many passes - EXITING)
(AXIS,notify, iquad: too many passes - EXITING)
m2
o<wh030> endif
o<pas00> if [#<pass> EQ 1]
(entry point:)
(for acute angle: go along the 1-->2 line to enter)
(at a point where tool will fit)
#<elen12> = [ #<r> / [TAN[#<ang412>/2]]]
#<k12> = [#<elen12> / #<r>]
(print entry 12 k=#<k12> elen12=#<elen12> angle=#<angle>)
#<ax> = [#<x1> + #<elen12> * #<cos12>]
#<ay> = [#<y1> + #<elen12> * #<sin12>]
(compute pre-entry points:)
o<dir00> if [#<dir> EQ 2]
#<bx> = [#<ax> + #<r> * #<sin12> - #<r> * #<cos12>]
#<by> = [#<ay> - #<r> * #<cos12> - #<r> * #<sin12>]
#<cx> = [#<bx> + #<r> * #<cos12>]
#<cy> = [#<by> + #<r> * #<sin12>]
#<vx> = [ #<r> * #<cos12>]
#<vy> = [ #<r> * #<sin12>]
o<dir00> else (dir EQ 3 CCW)
#<bx> = [#<ax> - #<r> * #<sin12> - #<r> * #<cos12>]
#<by> = [#<ay> + #<r> * #<cos12> - #<r> * #<sin12>]
#<cx> = [#<bx> + #<r> * #<cos12>]
#<cy> = [#<by> + #<r> * #<sin12>]
#<vx> = [ #<r> * #<cos12>]
#<vy> = [ #<r> * #<sin12>]
o<dir00> endif
g0 x #<cx> y #<cy> (preentry 1)
g0 x #<bx> y #<by> (preentry 2)
o<dir10> if [#<dir> EQ 2]
/ g42 (cutter radius comp right of path)
g2 x #<ax> y #<ay> i #<vx> j #<vy> (arc entry)
o<dir10> else (dir EQ 3 CCW)
/ g41 (cutter radius comp left of path)
g3 x #<ax> y #<ay> i #<vx> j #<vy> (arc entry)
o<dir10> endif
#<xfinal_a> = #<x2>
#<yfinal_a> = #<y2>
(rampdown finishes at point 2, to exit: need to turn corner at 2)
(and go along the 2-->3 line enough to exit)
#<elen23> = [ #<r> / [TAN[#<ang123>/2]]]
#<k23> = [#<elen23> / #<r>]
(print exit 23 k=#<k23> elen23=#<elen23> angle=#<ang123>)
(need a test here: if you go along 23 too far you gouge vertex 3)
#<xfinal_b> = [#<x2> + #<elen23> * #<cos23>]
#<yfinal_b> = [#<y2> + #<elen23> * #<sin23>]
g1 z #<zstart> (plunge to start height todo:g0)
o<pas00> endif
x #<x2> y #<y2> z#<zcurrent> (ramp down to zcurrent)
x #<x3> y #<y3>
x #<x4> y #<y4>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<wh010> endwhile
(print a= #<xfinal_a> #<yfinal_a> k=#<k23>)
(print b= #<xfinal_b> #<yfinal_b>)
g1 x #<xfinal_a> y #<yfinal_a>
g1 x #<xfinal_b> y #<yfinal_b>
g0 z #<zsafe>
g40
o<iquad> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -0,0 +1,119 @@
(info: G76 Threading, Specify driveline and offset, use NEGATIVE offset I for External Thread)
; default values:
; external thread example: xi=0.5,k=0.05,i=-0.03
; for majordiam=0.94,minordiam=0.84,i=-0.03
; internal thread example: xi=0.39,k=0.05,i=+0.03
; for majordiam=0.94,minordiam=0.84,i=+0.03
o<g76base> sub
#<toolno> = #1 (= 10)
#<rpm> = #2 (= 200 Spindle RPM)
#<xi> = #3 (= 0.5 X: Xi driveline)
#<zi> = #4 (= -0.5 Z: Zi driveline)
; G76 required items:
#<p> = #5 (= 0.125 P: Pitch, NEG for tpi)
#<z> = #6 (= -1.0 Z: Zf final)
#<i> = #7 (= -0.03 I: Thread peak offset)
#<k> = #8 (= 0.05 K: Full thread depth)
#<j> = #9 (= 0.015 J: Initial cut depth)
; G76 optional items:
#<r> = #10 (= 1.0 R: Depth degression)
#<q> = #11 (= 29.5 Q: Compound slide angle)
#<h> = #12 (= 0 H: No. of spring passes)
#<e> = #13 (= 0.050 E: Taper dist =K typ)
#<l> = #14 (= 2 L: End Taper 0,1,2,3)
; other:
#<spindir> = #15 (=3 Dir: Right=3 Left=4)
#<mode> = #16 (=8 G7/G8 Radius=8 Diam=7)
#<verbose> = #17 (=0 0:silent, 1:verbose)
o<if00> if [#<p> LT 0]
#<p> = ABS[1 / #<p>]
(debug, g76base: Computed pitch = #<p> from tpi)
o<if00> endif
o<if10> if [ [#<l> NE 0] AND [#<l> NE 1] AND [#<l> NE 2] AND [#<l> NE 3] ]
(print, q76base: Require: L = 0 or 1 or 2 or 3 - EXITING)
(debug, q76base: Require: L = 0 or 1 or 2 or 3 - EXITING)
(AXIS,notify, q76base: Require: L = 0 or 1 or 2 or 3 - EXITING)
m2
o<if10> endif
o<if11> if [ [#<spindir> NE 3] AND [#<spindir> NE 4]]
(print, q76base: Dir: 3 for RH 4 for LH - EXITING)
(debug, q76base: Dir: 3 for RH 4 for LH - EXITING)
(AXIS,notify, q76base: Dir: 3 for RH 4 for LH - EXITING)
m2
o<if11> endif
o<if12> if [ [#<mode> NE 7] AND [#<mode> NE 8] ]
(print, q76base: Mode: 7 for D 8 for R - EXITING)
(debug, q76base: Mode: 7 for D 8 for R - EXITING)
(AXIS,notify, q76base: Mode: 7 for D 8 for R - EXITING)
m2
o<if12> endif
o<if20> if [#<_vmajor> lT 2.6]
; no introspection on lathe radius/diameter mode
; so allow only G8 (radius mode)
o<if21> if [#<mode> NE 8]
(print, g76base: v2.5 requires G8 - EXITING)
(debug, g76base: v2.5 requires G8 - EXITING)
(AXIS,notify, g76base: v2.5 requires G8 - EXITING)
m2
o<if21> endif
o<if20> else
; >= 2.6
; use introspection on lathe radius/diameter mode
; to restore mode
o<if22> if [#<_lathe_diameter_mode> EQ 1]
#<restore_mode> = 7 ; diam
o<if22> endif
o<if23> if [#<_lathe_radius_mode> EQ 1]
#<restore_mode> = 8 ; radius
o<if23> endif
o<if24> if [ [#<_lathe_diameter_mode> EQ 0] AND [ #<_lathe_radius_mode> EQ 0] ]
; not supposed to happen:
(print, g76base: unexpected lathe mode - EXITING)
(debug, g76base: unexpected lathe mode - EXITING)
(AXIS,notify, g76base: unexpected lathe mode - EXITING)
m2
o<if24> endif
o<if25> if [ [#<_lathe_diameter_mode> EQ 1] AND [ #<_lathe_radius_mode> EQ 1] ]
; not supposed to happen:
(print, g76base: unexpected lathe mode - EXITING)
(debug, g76base: unexpected lathe mode - EXITING)
(AXIS,notify, g76base: unexpected lathe mode - EXITING)
m2
o<if25> endif
o<if20> endif
G#<mode>
o<if60> if [#<verbose> GT 0]
o<if70> if [#<mode> EQ 7]
(debug, g76base: set G7 DIAMETER mode)
o<if70> else
(debug, g76base: set G8 RADIUS mode)
o<if70> endif
o<if60> endif
o<loadtool> call [#<toolno>]
M#<spindir> S#<rpm>
G0 X#<xi> Z#<zi>
G76 P#<p> Z#<z> I#<i> J#<j> R#<r> K#<k> Q#<q> H#<h> E#<e> L#<l>
o<if80> if [[#<_vmajor> GE 2.6] AND [#<verbose> GT 0]]
(debug, g76base restoring mode to G #<restore_mode>)
o<if80> endif
o<g76base> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -0,0 +1,69 @@
(info: G76 Threading, Specify Major, Minor diameters, use NEGATIVE offset I for External Thread)
; convenience routine that allows specifying major and
; minor diameters for using G76
; Note: To make the number of passes equal for G7 (diam) and G8 (radius) modes,
; jeq = j_for_G7 = 2 * j_for_G8
o<g76diam> sub
#<toolno> = #1 (= 10)
#<rpm> = #2 (= 200 Spindle RPM)
#<i> = #3 (= -0.03 I: offset NEG:external)
#<zi> = #4 (= -0.5 Z: Zi driveline)
; required items:
#<p> = #5 (= -8 P: Pitch, NEG for tpi)
#<z> = #6 (= -1.0 Z: Zf final)
#<majordiameter> = #7 (= 0.94)
#<minordiameter> = #8 (= 0.84)
#<j> = #9 (= 0.015 Initial RADIAL cut depth)
; G76 optional items:
#<r> = #10 (= 1.0 R: Depth degression)
#<q> = #11 (= 29.5 Q: Compound slide angle)
#<h> = #12 (= 0 H: No. of spring passes)
#<e> = #13 (= 0.05 E: Taper dist =K typ)
#<l> = #14 (= 2 L: End Taper 0,1,2,3)
; other:
#<spindir> = #15 (=3 Dir: Right=3 Left=4)
#<mode> = #16 (=8 G7/G8 Radius=8 Diam=7)
#<verbose> = #17 (=0 0:quiet,1:verbose)
o<if1> if [#<majordiameter> LE #<minordiameter>]
(print, g76diam: major <= minor ? - EXITING)
(debug, g76diam: major <= minor ? - EXITING)
(AXIS,notify, g76diam: major <= minor ? - EXITING)
m2
o<if1> endif
#<jeq> = #<j> ; as-is for radius mode
o<if7> if [#<mode> EQ 8] ; RADIUS
#<k> = [ABS[#<majordiameter> - #<minordiameter>]/2]
o<if8> if [#<i> LE 0] ; EXTERNAL
#<xi> = [#<majordiameter>/2 - #<i>]
o<if8> else ; INTERNAL
#<xi> = [#<minordiameter>/2 - #<i>]
o<if8> endif
o<if7> else ; DIAMETER
#<k> = [ABS[#<majordiameter> - #<minordiameter>]]
#<jeq> = [2 * #<j>] ;workaround g76 behavior in diam mode
o<if9> if [#<i> LE 0] ; EXTERNAL
#<xi> = [#<majordiameter> - #<i>]
o<if9> else ; INTERNAL
#<xi> = [#<minordiameter> - #<i>]
o<if9> endif
o<if7> endif
o<i10> if [#<verbose> GT 0]
(debug, g76diam: driveline xi=#<xi> i=#<i>)
(debug, g76diam: k=#<k> j=#<j>)
o<i10> endif
o<g76base> call [#<toolno>][#<rpm>][#<xi>][#<zi>][#<p>][#<z>][#<i>][#<k>][#<jeq>][#<r>][#<q>][#<h>][#<e>][#<l>][#<spindir>][#<mode>][#<verbose>]
o<g76diam> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -0,0 +1,56 @@
; Author: jthornton
(info: inside diameter -- lathe boring)
o<id>sub
#<Hole_Dia> = #1 (=0.500 Starting Hole Diameter)
#<Final_Dia> = #2 (=0.625 Final Hole Diameter)
#<Depth_Cut> = #3 (=0.010 Depth of Cut)
#<Spring_Cuts> = #4 (=0 Spring Cuts)
#<Z_StartOfCut> = #5 (=0.100 Z Start of Cut)
#<Z_EndOfCut> = #6 (=-0.600 Z End of Cut)
#<SurfaceSpeed> = #7 (=80 Surface Speed)
#<FeedRate> = #8 (=2 Feed IPM)
#<MaxSpindle_RPM> = #9 (=1500 MAX RPM)
#<ToolNumber> = #10 (=8 Tool Number)
#<Coolant> = #11 (=8 Coolant 8=On 9=Off)
T#<ToolNumber> M6
; G43: toollength offset
; G7: diameter mode
; G96: constant surface speed
G43 G7 G96 D#<MaxSpindle_RPM> S#<SurfaceSpeed>
; Turn the OD
M3 M#<Coolant> ; spindle cw, coolant on/off:w
G0 X#<Hole_Dia> Z#<Z_StartOfCut>
#<Current-Diameter> = #<Hole_Dia>
o100 while [#<Current-Diameter> lt #<Final_Dia>]
O101 if [#<Current-Diameter> + #<Depth_Cut> lt #<Final_Dia>]
#<Current-Diameter> = [#<Current-Diameter> + #<Depth_Cut>]
O101 else
#<Current-Diameter> = #<Final_Dia>
O101 endif
X#<Current-Diameter>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current-Diameter>-0.010]
Z#<Z_StartOfCut>
o100 endwhile
o102 while [#<Spring_Cuts> gt 0]
G1 X#<Final_Dia>
Z#<Z_EndOfCut>
X[#<Final_Dia>-0.010]
G0 Z#<Z_StartOfCut>
#<Spring_Cuts> = [#<Spring_Cuts> -1]
o102 endwhile
G0 X[#<Current-Diameter>-0.010]
M5 M9 ; stop spindle, all coolant off
Z#<Z_StartOfCut>
G49 ; cancel tool length offset
G53 G0 X0 Z0 ; move in machine coordinates
o<id>endsub

View File

@@ -0,0 +1,12 @@
(not_a_subfile)
g18 (xz plane)
g20 (inches)
g40 (cancel cutter radius compensation)
g49 (cancel tool lengthoffset)
g90 (absolute distance mode)
g94 (units/min feedrate)
g54 (Coordinate system 1 default)
#<tol> = 0.001
g64 p#<tol> (path control stop)

View File

@@ -0,0 +1,48 @@
; Author: jthornton
(info: outside diameter - lathe turning)
o<od> sub
#<Material_Dia> = #1 (=0.260 Material Diameter)
#<Final_Dia> = #2 (=0.180 Final Diameter)
#<Depth_Cut> = #3 (=0.010 Depth of Cut)
#<Final_Cut> = #4 (=0.000 Final Cut)
#<SurfaceSpeed> = #5 (=100 Surface Speed)
#<FeedRate> = #6 (=2 Feed Rate)
#<Max_RPM> = #7 (=1500 Max Spindle RPM)
#<Z_EndOfCut> = #8 (=-0.5 End of Cut)
#<Z_StartOfCut> = #9 (=0.100 Start of Cut)
#<RToolNumber> = #10 (=6 Roughing Tool)
#<FToolNumber> = #11 (=6 Finishing Tool)
#<Coolant> = #12 (=8 Flood=8, Off=9)
T#<RToolNumber> M6
; G43: toolength offset
; G7: diameter mode
; G96: constant surface speed
G43 G7 G96 D#<Max_RPM> S#<SurfaceSpeed>
; Turn the OD
M3 M#<Coolant> ; spindle cw, coolant on/off
G0 X#<Material_Dia> Z#<Z_StartOfCut>
#<Current_Dia>=#<Material_Dia>
o100 while [#<Current_Dia> gt #<Final_Dia>]
O101 if [#<Current_Dia>-#<Depth_Cut> gt #<Final_Dia>]
#<Current_Dia>=[#<Current_Dia>-#<Depth_Cut>]
O101 else
#<Current_Dia>=#<Final_Dia>
O101 endif
X#<Current_Dia>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current_Dia>+0.025]
Z#<Z_StartOfCut>
o100 endwhile
G0 X[#<Current_Dia>+0.025]
M5 M9 ; stop spindle, all coolant off
Z#<Z_StartOfCut>
G49 ; cancel tool length offset compensation
G53 G0 X0 Z0 ; move in machine coordinates
o<od> endsub

View File

@@ -0,0 +1,32 @@
; Author: jthornton
(info: outside taper)
o<taper-od> sub
#<MaxRPM> = #1 (= 3000 Max RPM)
#<SurfaceUnitsMin> = #2 (= 100 Surface Units/Min)
#<FeedRate> = #3 (= 2 Feed Rate)
#<Z-Start> = #4 (= 0.000 Z Start)
#<Z-End> = #5 (= -2 Z End)
#<StartDiameter> = #6 (= 1 Start Diameter)
#<Angle> = #7 (= 10 Angle)
#<Tool> = #8 (= 6 Tool Number)
#<Coolant> = #9 (= 8 Flood=8, Off=9)
#<X-End> = [#<StartDiameter> + [[#<Z-Start> - #<Z-End>] * TAN[#<Angle>]]]
G7 G18 G40 G54
G96 D#<MaxRPM> S#<SurfaceUnitsMin> (Constance Surface Speed)
T#<Tool> M6
#<tooldiam>=#5410
G43 (load tool offset)
G42 (start cutter comp)
M3 M#<Coolant>
G0 X#<StartDiameter> Z[#<Z-Start> + .1000]
G1 X#<StartDiameter> Z#<Z-Start> F#<FeedRate>
X#<X-End> Z#<Z-End>
X[#<X-End> + [#<tooldiam> * 2] + 0.005]
M5 M9
G0 Z#<Z-Start>
G40
G53 G0 X0.000 Z0.000
o<taper-od> endsub

19
nc_files/ngcgui_lib/mfiles/M110 Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
# Clear axis info notifications
# use in gcode subroutines and/or connect to pushbutton
# M1nn files must exist _before_ starting emc
# in the [DISPLAY]PROGRAM_PREFIX
# or in a dir specified by [RS274NGC]USER_M_PATH
# the pin for axisui.notifications-clear-info is in emc-2.4pre
# using an earlier version will print error to stdout
halcmd setp axisui.notifications-clear-info 1
sleep .100 ;# requires a sleep that does <1
halcmd setp axisui.notifications-clear-info 0
# if a M1nn command fails and its script exits with nonzero status,
# the gcode program exits. So always exit 0, and make sure
# the M1nn command prints a message in order to keep on going.
exit 0

View File

@@ -0,0 +1,175 @@
(cw traverse: p1,p2,p3,p4)
(ccw traverse: p1,p4,p3,p2)
(info: ohex: outside hexagon, cw/ccw dir, radius compensation)
o<ohex> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<dir> = #4 (=2 2conv | 3climb)
#<flatd> = #5 (distance across flats)
#<cutdepth> = #6
#<zincr> = #7
#<zsafe> = #8 (=0.2)
#<zstart> = #9 (=0)
#<scale> = #10 (=1)
#<rotate> = #11 (=0)
#<xoff> = #12 (=0)
#<yoff> = #13 (=0)
#<spin_notify> = #14 (=0)
#<use_g43> = #15 (=1)
#<h_for_g43> = #16 (=0)
#<verbose> = #17 (=0)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 +.001]
o<dir> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, ohex: direction must be 2 or 3 - EXITING)
(print, ohex: direction must be 2 or 3 - EXITING)
(AXIS,notify, ohex: direction must be 2 or 3 - EXITING)
m2
o<dir> endif
#<f> = [#<flatd>/2]
#<p> = [#<f>/cos[30]]
#<pcos60> = [#<p> * cos[60]]
#<psin60> = [#<p> * sin[60]]
(p1 -> p2 -> is cw)
(apply scale,rotate, then offset to all input points)
#<x1> = #<p>
#<y1> = 0
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
#<x2> = #<pcos60>
#<y2> = [0 - #<psin60>]
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
#<x3> = [0 - #<pcos60>]
#<y3> = [0 - #<psin60>]
o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x3> = #<_move:x>
#<y3> = #<_move:y>
#<x4> = [0 - #<p>]
#<y4> = 0
o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x4> = #<_move:x>
#<y4> = #<_move:y>
#<x5> = [0 -# <pcos60>]
#<y5> = #<psin60>
o<move> call [#<x5>][#<y5>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x5> = #<_move:x>
#<y5> = #<_move:y>
#<x6> = #<pcos60>
#<y6> = #<psin60>
o<move> call [#<x6>][#<y6>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x6> = #<_move:x>
#<y6> = #<_move:y>
#<r> = [#<tooldiam>/2]
#<cutdepth> = [0 - #<cutdepth>]
#<zincr> = [0 - #<zincr>]
(get lengths and angles for connecting lines)
o<line> call [#<x1>][#<y1>][#<x2>][#<y2>]
#<phi12> = #<_line:phi>
o<line> call [#<x2>][#<y2>][#<x3>][#<y3>]
#<len23> = #<_line:len>
#<phi23> = #<_line:phi>
#<cos23> = #<_line:cos>
#<sin23> = #<_line:sin>
o<line> call [#<x1>][#<y1>][#<x6>][#<y6>]
#<phi16> = #<_line:phi>
o<line> call [#<x6>][#<y6>][#<x5>][#<y5>]
#<len65> = #<_line:len>
#<phi65> = #<_line:phi>
#<cos65> = #<_line:cos>
#<sin65> = #<_line:sin>
#<phi_cw> = #<phi12> (starting line for cw)
#<phi_ccw> = #<phi16> (starting line for ccw)
g40 (cutter radius compensation off)
f #<feedrate>
s #<rpm> m3 (spindle cw)
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
g0 z#<zsafe>
#<zcurrent> = #<zstart>
#<pass> = 1
o<wh010> while [#<zcurrent> GT #<cutdepth>]
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<wh020> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<wh020> endif
o<wh030> if [#<pass> GT 100]
(debug, ohex: too many passes - EXITING)
(print, ohex: too many passes - EXITING)
(AXIS,notify, ohex: too many passes - EXITING)
m2
o<wh030> endif
o<aaa00> if [#<dir> EQ 3]
o<aaa10> if [#<pass> EQ 1]
#<bx> = [#<x1> + #<r> * sin[#<phi_ccw>] - #<r> * cos[#<phi_ccw>]]
#<by> = [#<y1> - #<r> * cos[#<phi_ccw>] - #<r> * sin[#<phi_ccw>]]
#<vx> = [0 + #<r> * cos[#<phi_ccw>]] (r vector)
#<vy> = [0 + #<r> * sin[#<phi_ccw>]]
g0 x #<bx> y #<by> (preentry 1)
/ g42 (cutter radius comp right of path)
g2 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry)
#<xfinal_b> = #<x6>
#<yfinal_b> = #<y6>
g1 z #<zstart> (plunge)
o<aaa10> endif
x #<x6> y #<y6> z#<zcurrent>
x #<x5> y #<y5>
x #<x4> y #<y4>
x #<x3> y #<y3>
x #<x2> y #<y2>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<aaa00> else (dir EQ 2 CW)
o<aaa40> if [#<pass> EQ 1]
#<bx> = [#<x1> - #<r> * sin[#<phi_cw>] - #<r> * cos[#<phi_cw>]]
#<by> = [#<y1> + #<r> * cos[#<phi_cw>] - #<r> * sin[#<phi_cw>]]
#<vx> = [0 + #<r> * cos[#<phi_cw>]] (r vector)
#<vy> = [0 + #<r> * sin[#<phi_cw>]]
g0 x #<bx> y #<by>
/ g41 (cutter radius comp left of path)
g3 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry)
#<xfinal_b> = #<x2>
#<yfinal_b> = #<y2>
g1 z #<zstart> (plunge)
o<aaa40> endif
x #<x2> y #<y2> z#<zcurrent>
x #<x3> y #<y3>
x #<x4> y #<y4>
x #<x5> y #<y5>
x #<x6> y #<y6>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<aaa00> endif
o<wh010> endwhile
g1 x #<xfinal_b> y #<yfinal_b>
g0 z #<zsafe>
g40
o<ohex> endsub

View File

@@ -0,0 +1,136 @@
(outside traverse arbitrary quadrangle)
(computes direction for polygon cw or ccw and swaps if required)
(info: oquad: outside quadrilateral, specify four x,y points)
o<oquad> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=1)
#<dir> = #3 (=2 2conv|3climb)
#<feedrate> = #4 (=10)
#<cutdepth> = #5
#<zincr> = #6
#<zsafe> = #7 (=0.2)
#<zstart> = #8 (=0)
#<x1> = #9
#<y1> = #10
#<x2> = #11
#<y2> = #12
#<x3> = #13
#<y3> = #14
#<x4> = #15
#<y4> = #16
#<scale> = #17 (=1)
#<rotate> = #18 (=0)
#<xoff> = #19 (=0)
#<yoff> = #20 (=0)
#<spin_notify> = #21 (=0)
#<use_g43> = #22 (=1)
#<h_for_g43> = #23 (=0)
#<verbose> = #24 (=0)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
o<l00> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, oquad: bogus direction #<dir> - EXITING)
(print, oquad: bogus direction #<dir> - EXITING)
(AXIS,notify, oquad: bogus direction - EXITING)
m2
o<l00> endif
(determine direction eg cw or ccw of points)
o<dir> call [4][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>]
#<pointsdir> = #<_dir:>
o<l20> if [#<pointsdir> NE #<dir>]
(swap 1234 --> 1432)
#<xt> = #<x2>
#<yt> = #<y2>
#<x2> = #<x4>
#<y2> = #<y4>
#<x4> = #<xt>
#<y4> = #<yt>
o<l20> endif
(apply scale, rotate, then offset to all input points)
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
o<move> call [#<x3>][#<y3>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x3> = #<_move:x>
#<y3> = #<_move:y>
o<move> call [#<x4>][#<y4>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x4> = #<_move:x>
#<y4> = #<_move:y>
#<r> = [#<tooldiam>/2]
#<cutdepth> = [0 - #<cutdepth>]
#<zincr> = [0 - #<zincr>]
(get lengths and angles for connecting lines)
o<line> call [#<x1>][#<y1>][#<x2>][#<y2>]
#<phi12> = #<_line:phi>
g40 (cutter radius compensation off)
f #<feedrate>
s #<rpm> m3 (spindle cw)
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
g0 z#<zsafe>
#<zcurrent> = #<zstart>
#<pass> = 1
o<wh010> while [#<zcurrent> GT #<cutdepth>]
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<wh020> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<wh020> endif
o<wh030> if [#<pass> GT 100]
(debug, oquad: too many passes - EXITING)
(print, oquad: too many passes - EXITING)
(AXIS,notify, oquad: too many passes - EXITING)
m2
o<wh030> endif
o<pas00> if [#<pass> EQ 1]
o<dir00> if [#<dir> EQ 2]
#<bx> = [#<x1> - #<r> * sin[#<phi12>] - #<r> * cos[#<phi12>]]
#<by> = [#<y1> + #<r> * cos[#<phi12>] - #<r> * sin[#<phi12>]]
#<vx> = [ #<r> * cos[#<phi12>]] (b to arc center)
#<vy> = [ #<r> * sin[#<phi12>]]
g0 x #<bx> y #<by>
/ g41 (cutter radius comp left of path)
g3 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry)
o<dir00> else (dir EQ 3 CCW)
#<bx> = [#<x1> + #<r> * sin[#<phi12>] - #<r> * cos[#<phi12>]]
#<by> = [#<y1> - #<r> * cos[#<phi12>] - #<r> * sin[#<phi12>]]
#<vx> = [ #<r> * cos[#<phi12>]] (b to arc center)
#<vy> = [ #<r> * sin[#<phi12>]]
g0 x #<bx> y #<by>
/ g42 (cutter radius comp right of path)
g2 x #<x1> y #<y1> i #<vx> j #<vy> (arc entry)
o<dir00> endif
#<xfinal> = #<x2>
#<yfinal> = #<y2>
g1 z #<zstart> (plunge to start height todo:g0)
o<pas00> endif
x #<x2> y #<y2> z#<zcurrent> (ramp down to zcurrent)
x #<x3> y #<y3>
x #<x4> y #<y4>
x #<x1> y #<y1>
#<pass> = [#<pass> + 1]
o<wh010> endwhile
g1 x #<xfinal> y #<yfinal>
g0 z #<zsafe>
g40
o<oquad> endsub

View File

@@ -0,0 +1,139 @@
(info: qpex: qpocket examples)
o<qpex> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=1000)
#<dir> = #3 (=2 2conv|3climb) ; conventional=cw, climb=ccw
#<feedrate> = #4 (=10)
#<cutdepth> = #5 (=1)
#<zincr> = #6 (=.4)
#<zsafe> = #7 (=0.2)
#<zstart> = #8 (=0)
#<stepover> = #9 (=0.9)
#<g64tol> = #10 (=0.002)
#<spin_notify> = #11 (=0)
#<use_g43> = #12 (=1)
#<h_for_g43> = #13 (=0)
#<verbose> = #14 (=0)
;shorthand required for call linelength:
#<fr> = #<feedrate>
#<cut>= #<cutdepth>
#<so> = #<stepover>
#<vb> = #<verbose>
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<vb>]
#<x1> = -0.5
#<y1> = -0.5
#<x2> = +0.5
#<y2> = -0.5
#<x3> = +0.5
#<y3> = +0.5
#<x4> = -0.5
#<y4> = +0.5
#<xoff> = 2
#<yoff> = 0
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, square at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<use_g43>][#<h_for_g43>][#<vb>]
#<x1> = -0.5
#<y1> = -1.0
#<x2> = +0.5
#<y2> = -1.0
#<x3> = +0.5
#<y3> = +1.0
#<x4> = -0.5
#<y4> = +1.0
#<xoff> = 2
#<yoff> = 2
#<rotate> = 30
#<scale> = 1
M110 ; clear axis notifications
(debug, rectangle at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
#<x1> = -1.0
#<y1> = -0.5
#<x2> = +0.5
#<y2> = -0.5
#<x3> = +1.0
#<y3> = +0.5
#<x4> = -0.5
#<y4> = +0.5
#<xoff> = 0
#<yoff> = 2
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, parallelogram at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
#<x3> = -1
#<y3> = -1
#<x4> = 0
#<y4> = -.75
#<x1> = 1
#<y1> = -1
#<x2> = 0
#<y2> = 0
#<xoff> = -2
#<yoff> = 2
#<rotate> = 0
#<scale> = 1
(debug, kite at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
#<x1> = 1
#<y1> = -1
#<x2> = 0
#<y2> = 1
#<x3> = -1
#<y3> = -1
#<x4> = 0
#<y4> = -0.999 ;disallow colinear pts in 3-sided figure
#<xoff> = -2
#<yoff> = 0
#<rotate> = 45
#<scale> = 1
M110 ; clear axis notifications
(debug, triangle at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>]
#<x3> = -1
#<y3> = -1
#<x4> = 0
#<y4> = -1.5
#<x1> = 1
#<y1> = -1
#<x2> = 0
#<y2> = 0
#<xoff> = -2
#<yoff> = 2
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, kite at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>]
#<x3> = -1
#<y3> = -1
#<x4> = 0
#<y4> = -.75
#<x1> = 1
#<y1> = -1
#<x2> = 0
#<y2> = 0
#<xoff> = 0
#<yoff> = -1
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, dart at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
o<qpex> endsub

View File

@@ -0,0 +1,136 @@
(info: qpex_mm: qpocket mm examples, use a 5mm tool)
; for testing qpocket with mm system
; adapted from qpex.ngc and scaled for mm
; too small tools and/or small sos may exceed outlinepasslimit
o<qpex_mm> sub
#<toolno> = #1 (use a 5mm diam)
#<rpm> = #2 (=1000)
#<dir> = #3 (=2 2conv|3climb) ; conventional=cw, climb=ccw
#<feedrate> = #4 (=250)
#<cutdepth> = #5 (=10)
#<zincr> = #6 (=5)
#<zsafe> = #7 (=1)
#<zstart> = #8 (=0)
#<stepover> = #9 (=0.9)
#<g64tol> = #10 (=0.002)
#<spin_notify> = #11 (=0)
#<use_g43> = #12 (=1)
#<h_for_g43>= #13 (=0)
#<verbose> = #14 (=0)
;shorthand required for call linelength:
#<fr> = #<feedrate>
#<cut>= #<cutdepth>
#<so> = #<stepover>
#<vb> = #<verbose>
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<vb>]
#<tooldiam> = #5410
(debug, duh #<tooldiam>)
o<chk1> if [#<tooldiam> GT 10]
(print, qpex_mm: tooldiam is too big #<tooldiam> - EXITING)
(debug, qpex_mm: tooldiam is too big #<tooldiam> - EXITING)
(AXIS,notify, qpex:_mm tooldiam is too big - EXITING)
m2
o<chk1> endif
o<chk2> if [#<tooldiam> LT .5]
(print, qpex_mm: tooldiam is too small #<tooldiam> - EXITING)
(debug, qpex_mm: tooldiam is too small #<tooldiam> - EXITING)
(AXIS,notify, qpex_mm: tooldiam is too small - EXITING)
m2
o<chk2> endif
#<x1> = [-0.5 * 25.4]
#<y1> = [-0.5 * 25.4]
#<x2> = [+0.5 * 25.4]
#<y2> = [-0.5 * 25.4]
#<x3> = [+0.5 * 25.4]
#<y3> = [+0.5 * 25.4]
#<x4> = [-0.5 * 25.4]
#<y4> = [+0.5 * 25.4]
#<xoff> = [2 * 25.4]
#<yoff> = 0
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, square at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<use_g43>][#<h_for_g43>][#<vb>]
#<x1> = [-0.5 * 25.4]
#<y1> = [-1.0 * 25.4]
#<x2> = [+0.5 * 25.4]
#<y2> = [-1.0 * 25.4]
#<x3> = [+0.5 * 25.4]
#<y3> = [+1.0 * 25.4]
#<x4> = [-0.5 * 25.4]
#<y4> = [+1.0 * 25.4]
#<xoff> = [2 * 25.4]
#<yoff> = [2 * 25.4]
#<rotate> = 30
#<scale> = 1
M110 ; clear axis notifications
(debug, rectangle at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
#<x1> = [-1.0 * 25.4]
#<y1> = [-0.5 * 25.4]
#<x2> = [+0.5 * 25.4]
#<y2> = [-0.5 * 25.4]
#<x3> = [+1.0 * 25.4]
#<y3> = [+0.5 * 25.4]
#<x4> = [-0.5 * 25.4]
#<y4> = [+0.5 * 25.4]
#<xoff> = [0 * 25.4]
#<yoff> = [2 * 25.4]
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, parallelogram at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
#<x1> = [1 * 25.4]
#<y1> = [-1 * 25.4]
#<x2> = [0 * 25.4]
#<y2> = [1 * 25.4]
#<x3> = [-1 * 25.4]
#<y3> = [-1 * 25.4]
#<x4> = [0 * 25.4]
#<y4> = [-0.999 * 25.4] ;disallow colinear pts in 3-sided figure
#<xoff> = [-2 * 25.4]
#<yoff> = 0
#<rotate> = 45
#<scale> = 1
M110 ; clear axis notifications
(debug, triangle at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>]
#<x1> = [1 * 25.4]
#<y1> = [-1 * 25.4]
#<x2> = [0 * 25.4]
#<y2> = [0 * 25.4]
#<x3> = [-1 * 25.4]
#<y3> = [-1 * 25.4]
#<x4> = [0 * 25.4]
#<y4> = [-1.5 * 25.4]
#<xoff> = [-2 * 25.4]
#<yoff> = [2 * 25.4]
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, kite at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>]
#<x1> = [1 * 25.4]
#<y1> = [-1 * 25.4]
#<x2> = [0 * 25.4]
#<y2> = [0 * 25.4]
#<x3> = [-1 * 25.4]
#<y3> = [-1 * 25.4]
#<x4> = [0 * 25.4]
#<y4> = [-.75 * 25.4]
#<xoff> = [0 * 25.4]
#<yoff> = [-1 * 25.4]
#<rotate> = 0
#<scale> = 1
M110 ; clear axis notifications
(debug, dart at #<xoff>,#<yoff> rotate=#<rotate> scale=#<scale>)
o<qpocket>call[#<toolno>][#<rpm>][#<dir>][#<fr>][#<cut>][#<zincr>][#<zsafe>][#<zstart>][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>][#<scale>][#<rotate>][#<xoff>][#<yoff>][#<so>][#<g64tol>][#<spin_notify>][#<vb>]
o<qpex_mm> endsub

View File

@@ -0,0 +1,485 @@
(info: Quadrilateral pocketing using cutter radius compensation)
; Use with care, test in simulator first.
; Notes:
; Defaults herein are inch based
; Uses tool diameter from tool table for cutter radius compensation
; Supports conventional or climb milling
; Ramps to depth for each z increment
; Mirror about x axis for negative scale
; too small diameter tools and/or small stepovers may exceed outlinepasslimit
; too large diameter tools may case gouging errors
; Works for most rectangles and parallelograms but may require some care
; for specifying:
; point ordering (see entry move notes below)
; tool diameter (in tool table)
; stepover
; Entry moves:
; Input point ordering Requested Direction Entry line
; -------------------- ------------------------ ------------------
; 1234 == CW 2 == CW == Conventional point1 --> point2
; 1234 == CW 3 == CCW == Climb point1 --> point4
; 1234 == CCW 2 == CW == Conventional point1 --> point4
; 1234 == CCW 3 == CCW == Climb point1 --> point2
; To accommodate the widest range of tool diameters, order the point sequence
; (1234) so that the entry move is not directed towards an acute angle.
; Scaling, rotations, and offsets are supported.
; Scaling is applied first.
; Rotation is then applied (with respect to origin). It is often simplest
; to specify the feature so that it is centered at the origin.
; Offsets are applied last.
;----------------------------------------------------------------------
; Copyright: 2012,2014
; Author: Dewey Garrett <dgarrett@panix.com>
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;----------------------------------------------------------------------
o<qpocket> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=1000)
#<dir> = #3 (=2 2conv|3climb) ; conventional=cw, climb=ccw
#<feedrate> = #4 (=10)
#<cutdepth> = #5 (=0.1)
#<zincr> = #6 (=0.02)
#<zsafe> = #7 (=0.2)
#<zstart> = #8 (=0)
#<x1> = #9
#<y1> = #10
#<x2> = #11
#<y2> = #12
#<x3> = #13
#<y3> = #14
#<x4> = #15
#<y4> = #16
#<scale> = #17 (=1) ; use neg value for mirroring
#<rotate> = #18 (=0) ; angle in degrees
#<xoff> = #19 (=0)
#<yoff> = #20 (=0)
#<stepover> = #21 (=0.5) ; tooldiameter fraction
#<g64tol> = #22 (=0.002)
#<spin_notify> = #23 (=1) ; 1 == prompt user
#<use_g43> = #24 (=1)
#<h_for_g43> = #25 (=0)
#<verbose> = #26 (=0)
#<depthpasslimit> = 100 ; outer loop
#<outlinepasslimit> = 100 ; inner loop
#<tdelta> = 0.01 ; small increment to tool diameter
#<cutdepth> = [0 - #<cutdepth>]
#<zincr> = [0 - #<zincr>]
g40 ; make sure cutter radius compensation off at start
g64 p #<g64tol> ; path tolerance
o<if10> if [#<scale> EQ 0]
(print, qpocket: zero scale #<scale> - EXITING)
(debug, qpocket: zero scale #<scale> - EXITING)
(AXIS,notify, qpocket: zero scale - EXITING)
m2
o<if10> endif
o<if11> if [#<scale> LT 0]
(print, qpocket: MIRROR about x axis for negative scale #<scale>)
(debug, qpocket: MIRROR about x axis for negative scale #<scale>)
(AXIS,notify, qpocket: MIRROR about x axis for negative scale)
o<if11> endif
#<x1> = [#<scale> * #<x1>]
#<x2> = [#<scale> * #<x2>]
#<x3> = [#<scale> * #<x3>]
#<x4> = [#<scale> * #<x4>]
#<scale> = [ABS[#<scale>]]
#<y1> = [#<scale> * #<y1>]
#<y2> = [#<scale> * #<y2>]
#<y3> = [#<scale> * #<y3>]
#<y4> = [#<scale> * #<y4>]
#<scale> = 1
o<if20> if [[#<stepover> GT 1] OR [#<stepover> LE 0]]
(print, qpocket: invalid stepover=#<stepover> - EXITING)
(debug, qpocket: invalid stepover=#<stepover> - EXITING)
(AXIS,notify, qpocket: invalid stepover - EXITING)
m2
o<if20> endif
o<if30> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(print, qpocket:bad dir=#<dir> - EXITING)
(debug, qpocket:bad dir=#<dir> - EXITING)
(AXIS,notify, qpocket:bad dir - EXITING)
m2
o<if30> endif
;compute direction eg 2==cw,3==ccw for points as ordered:
o<dir> call [4][#<x1>][#<y1>][#<x2>][#<y2>][#<x3>][#<y3>][#<x4>][#<y4>]
#<pointsdir> = #<_dir:> ; direction of input points 2==cw
#<xctr> = #<_dir:cx> ; centroid
#<yctr> = #<_dir:cy> ; centroid
o<ifdir1> if [#<pointsdir> LE 0]
; failed to get direction -- pathological case
(print, failed to compute direction - EXITING)
(debug, failed to compute direction - EXITING)
(AXIS,notify, failed to compute direction - EXITING)
m2
o<ifdir1> endif
; Get data for x,y points
#<npoints> = 4
o<pointsdata> call [#<npoints>] [#<x1>][#<x2>][#<x3>][#<x4>]
#<xc> = #<_pointsdata:ctr>
#<xmin> = [#<_pointsdata:min> - #<xctr>]
#<xmax> = [#<_pointsdata:max> - #<xctr>]
o<pointsdata> call [#<npoints>] [#<y1>][#<y2>][#<y3>][#<y4>]
#<yc> = #<_pointsdata:ctr>
#<ymin> = [#<_pointsdata:min> - #<yctr>]
#<ymax> = [#<_pointsdata:max> - #<yctr>]
; Respecify input points about the x,y centroid
o<ifv0> if [#<verbose> GT 0]
(debug, centroid: #<xctr> #<yctr>)
o<ifv0> endif
#<x1> = [#<x1> - #<xctr>]
#<x2> = [#<x2> - #<xctr>]
#<x3> = [#<x3> - #<xctr>]
#<x4> = [#<x4> - #<xctr>]
#<y1> = [#<y1> - #<yctr>]
#<y2> = [#<y2> - #<yctr>]
#<y3> = [#<y3> - #<yctr>]
#<y4> = [#<y4> - #<yctr>]
; make order of points agree with input direction request
o<if40> if [#<pointsdir> NE #<dir>]
o<ifv1> if [#<verbose> GT 0]
(debug, reversing input point sequence: 1-4-3-2)
o<ifv1> endif
; swap points ordering: 1234 --> 1432
#<xt> = #<x2>
#<yt> = #<y2>
#<x2> = #<x4>
#<y2> = #<y4>
#<x4> = #<xt>
#<y4> = #<yt>
o<if40> endif
; determine min size for first outline pass
o<if50> if [[#<xmax>-#<xmin>] GT [#<ymax>-#<ymin>]]
#<minor> = [ABS[#<ymax>-#<ymin>]/2]
o<if50> else
#<minor> = [ABS[#<xmax>-#<xmin>]/2]
o<if50> endif
; load tool and establish scaling for first outline pass
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<thetooldiam> = #5410
#<tooldiam> = [#5410 + #<tdelta>]
#<r> = [#<tooldiam> / 2]
#<sizei> = [#<tooldiam> / #<minor>]
#<qscalei> = [#<scale> * #<sizei>]
o<ifsc> if [#<qscalei> GE #<scale>]
(print, qpocket: tooldiam is too big #<thetooldiam> - EXITING)
(debug, qpocket: tooldiam is too big #<thetooldiam> - EXITING)
(AXIS,notify, qpocket: tooldiam is too big - EXITING)
m2
o<ifsc> endif
; scale the centered feature and translate to original position
o<move> call [#<x1>][#<y1>][0][#<qscalei>][#<xctr>][#<yctr>]
#<x1i> = #<_move:x>
#<y1i> = #<_move:y>
o<move> call [#<x2>][#<y2>][0][#<qscalei>][#<xctr>][#<yctr>]
#<x2i> = #<_move:x>
#<y2i> = #<_move:y>
o<move> call [#<x3>][#<y3>][0][#<qscalei>][#<xctr>][#<yctr>]
#<x3i> = #<_move:x>
#<y3i> = #<_move:y>
o<move> call [#<x4>][#<y4>][0][#<qscalei>][#<xctr>][#<yctr>]
#<x4i> = #<_move:x>
#<y4i> = #<_move:y>
; xni,yni are the initial points at the smallest scaling
; apply input rotation and offset
o<move> call [#<x1i>][#<y1i>][#<rotate>][1][#<xoff>][#<yoff>]
#<x1i> = #<_move:x>
#<y1i> = #<_move:y>
o<move> call [#<x2i>][#<y2i>][#<rotate>][1][#<xoff>][#<yoff>]
#<x2i> = #<_move:x>
#<y2i> = #<_move:y>
o<move> call [#<x3i>][#<y3i>][#<rotate>][1][#<xoff>][#<yoff>]
#<x3i> = #<_move:x>
#<y3i> = #<_move:y>
o<move> call [#<x4i>][#<y4i>][#<rotate>][1][#<xoff>][#<yoff>]
#<x4i> = #<_move:x>
#<y4i> = #<_move:y>
;get angles for connecting lines
o<line> call [#<x1i>][#<y1i>][#<x2i>][#<y2i>]
#<cos12> = #<_line:cos>
#<sin12> = #<_line:sin>
o<line> call [#<x2i>][#<y2i>][#<x3i>][#<y3i>]
#<cos23> = #<_line:cos>
#<sin23> = #<_line:sin>
o<line> call [#<x3i>][#<y3i>][#<x4i>][#<y4i>]
#<cos34> = #<_line:cos>
#<sin34> = #<_line:sin>
o<line> call [#<x4i>][#<y4i>][#<x1i>][#<y1i>]
#<cos41> = #<_line:cos>
#<sin41> = #<_line:sin>
;compute angles at line intersections:
o<dot> call [#<x1i>][#<y1i>][#<x2i>][#<y2i>][#<x3i>][#<y3i>]
#<ang123> = #<_dot:ang>
o<dot> call [#<x2i>][#<y2i>][#<x3i>][#<y3i>][#<x4i>][#<y4i>]
#<ang234> = #<_dot:ang>
o<dot> call [#<x3i>][#<y3i>][#<x4i>][#<y4i>][#<x1i>][#<y1i>]
#<ang341> = #<_dot:ang>
o<dot> call [#<x4i>][#<y4i>][#<x1i>][#<y1i>][#<x2i>][#<y2i>]
#<ang412> = #<_dot:ang>
f #<feedrate>
s #<rpm> m3 ;spindle cw
o<if60> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>] ; optionally prompt user
o<if60> endif
g0 z#<zsafe>
; depth loop (outer)
#<zcurrent> = #<zstart>
#<depthpass> = 1
o<wh10> while [#<zcurrent> GT #<cutdepth>]
#<zlast> = #<zcurrent>
#<zcurrent> = [#<zcurrent> + #<zincr>]
o<wh11> if [#<zcurrent> LT #<cutdepth>]
#<zcurrent> = #<cutdepth>
o<wh11> endif
o<wh12> if [#<depthpass> GT #<depthpasslimit>]
(print, qpocket: depthpasslimit exceeded #<depthpasslimit> - EXITING)
(debug, qpocket: depthpasslimit exceeded #<depthpasslimit> - EXITING)
(AXIS,notify, qpocket: depthpasslimit exceeded - EXITING)
m2
o<wh12> endif
o<pas1> if [#<depthpass> EQ 1]
;entry point:
;go along the 1-->2 line to enter at a point where tool will fit
#<elen12> = [ #<r> / [TAN[#<ang412>/2]]]
#<k12> = [#<elen12> / #<r>]
;(print, entry 12 k=#<k12> elen12=#<elen12> angle=#<angle>)
#<xentry> = [#<x1i> + #<elen12> * #<cos12>]
#<yentry> = [#<y1i> + #<elen12> * #<sin12>]
;compute pre-entry points:
o<dir00> if [#<dir> EQ 2] ; dir EQ 2 CW (conventional)
#<prex2> = [#<xentry> + #<r> * #<sin12> - #<r> * #<cos12>]
#<prey2> = [#<yentry> - #<r> * #<cos12> - #<r> * #<sin12>]
#<prex1> = [#<prex2> + #<r> * #<cos12>]
#<prey1> = [#<prey2> + #<r> * #<sin12>]
#<vx> = [ #<r> * #<cos12>]
#<vy> = [ #<r> * #<sin12>]
o<dir00> else ;dir EQ 3 CCW (climb)
#<prex2> = [#<xentry> - #<r> * #<sin12> - #<r> * #<cos12>]
#<prey2> = [#<yentry> + #<r> * #<cos12> - #<r> * #<sin12>]
#<prex1> = [#<prex2> + #<r> * #<cos12>]
#<prey1> = [#<prey2> + #<r> * #<sin12>]
#<vx> = [ #<r> * #<cos12>]
#<vy> = [ #<r> * #<sin12>]
o<dir00> endif
g0 x #<prex1> y #<prey1> ;preentry 1
g0 x #<prex2> y #<prey2> ;preentry 2
o<dir10> if [#<dir> EQ 2] ; CW
/ g42 ;cutter radius comp right of path
g2 x #<xentry> y #<yentry> i #<vx> j #<vy> ;arc entry
o<dir10> else ;dir EQ 3 CCW
/ g41 ;cutter radius comp left of path
g3 x #<xentry> y #<yentry> i #<vx> j #<vy> ;arc entry
o<dir10> endif
g1 z #<zstart> ;plunge to start height from zsafe
o<pas1> else
; depthpass GT 1: return to interior entry point
g1 x #<xentry> y #<yentry> z#<zlast> ; use zlast
o<pas1> endif
; outline loop (inner)
#<outlinepass> = 1
#<qscale> = #<qscalei>
#<size> = #<sizei>
o<wh20> do
o<wh22> if [#<outlinepass> GT #<outlinepasslimit>]
(print, qpocket: outlinepasslimit exceeded #<outlinepasslimit> - EXITING)
(debug, qpocket: outlinepasslimit exceeded #<outlinepasslimit> - EXITING)
(AXIS,notify,qpocket: outlinepasslimit exceeded - EXITING)
m2
o<wh22> endif
#<seq> = [#<outlinepass> mod 4]
o<wh23> if [#<outlinepass> EQ 1]
; move through smallest interior outline
o<ramp1> if [#<seq> EQ 1]
g1 x #<x2i> y #<y2i> z#<zcurrent> ;ramp down to zcurrent
g1 x #<x3i> y #<y3i>
g1 x #<x4i> y #<y4i>
g1 x #<x1i> y #<y1i>
g1 x #<x2i> y #<y2i>
o<ramp1> endif
o<ramp2> if [#<seq> EQ 2]
g1 x #<x3i> y #<y3i> z#<zcurrent> ;ramp down to zcurrent
g1 x #<x4i> y #<y4i>
g1 x #<x1i> y #<y1i>
g1 x #<x2i> y #<y2i>
g1 x #<x3i> y #<y3i>
o<ramp2> endif
o<ramp3> if [#<seq> EQ 3]
g1 x #<x4i> y #<y4i> z#<zcurrent> ;ramp down to zcurrent
g1 x #<x1i> y #<y1i>
g1 x #<x2i> y #<y2i>
g1 x #<x3i> y #<y3i>
g1 x #<x4i> y #<y4i>
o<ramp3> endif
o<ramp0> if [#<seq> EQ 0]
g1 x #<x1i> y #<y1i> z#<zcurrent> ;ramp down to zcurrent
g1 x #<x2i> y #<y2i>
g1 x #<x3i> y #<y3i>
g1 x #<x4i> y #<y4i>
g1 x #<x1i> y #<y1i>
o<ramp0> endif
#<outlinepass> = [#<outlinepass> + 1]
o<wh23> else
; increasingly larger outlines
#<size> = [#<size> + #<stepover> * #<sizei>]
#<qscale> = [#<scale> * #<size>]
#<outlinepass> = [#<outlinepass> + 1]
o<wh24> if [#<qscale> GE #<scale>]
#<qscale> = #<scale>
#<outlinepass> = 0 ;terminate after this pass
o<wh24> endif
; scale the centered feature and translate to original position
o<move> call [#<x1>][#<y1>][0][#<qscale>][#<xctr>][#<yctr>]
#<x1t> = #<_move:x>
#<y1t> = #<_move:y>
o<move> call [#<x2>][#<y2>][0][#<qscale>][#<xctr>][#<yctr>]
#<x2t> = #<_move:x>
#<y2t> = #<_move:y>
o<move> call [#<x3>][#<y3>][0][#<qscale>][#<xctr>][#<yctr>]
#<x3t> = #<_move:x>
#<y3t> = #<_move:y>
o<move> call [#<x4>][#<y4>][0][#<qscale>][#<xctr>][#<yctr>]
#<x4t> = #<_move:x>
#<y4t> = #<_move:y>
; apply input rotation and offset
o<move> call [#<x1t>][#<y1t>][#<rotate>][1][#<xoff>][#<yoff>]
#<x1s> = #<_move:x>
#<y1s> = #<_move:y>
o<move> call [#<x2t>][#<y2t>][#<rotate>][1][#<xoff>][#<yoff>]
#<x2s> = #<_move:x>
#<y2s> = #<_move:y>
o<move> call [#<x3t>][#<y3t>][#<rotate>][1][#<xoff>][#<yoff>]
#<x3s> = #<_move:x>
#<y3s> = #<_move:y>
o<move> call [#<x4t>][#<y4t>][#<rotate>][1][#<xoff>][#<yoff>]
#<x4s> = #<_move:x>
#<y4s> = #<_move:y>
; move through scaled interior outline
o<seq0> if [#<seq> EQ 0]
g1 x #<x1s> y #<y1s> z #<zcurrent>
x #<x2s> y #<y2s>
x #<x3s> y #<y3s>
x #<x4s> y #<y4s>
x #<x1s> y #<y1s>
o<seq0> endif
o<seq1> if [#<seq> EQ 1]
g1 x #<x2s> y #<y2s> z #<zcurrent>
x #<x3s> y #<y3s>
x #<x4s> y #<y4s>
x #<x1s> y #<y1s>
x #<x2s> y #<y2s>
o<seq1> endif
o<seq2> if [#<seq> EQ 2]
g1 x #<x3s> y #<y3s> z #<zcurrent>
x #<x4s> y #<y4s>
x #<x1s> y #<y1s>
x #<x2s> y #<y2s>
x #<x3s> y #<y3s>
o<seq2> endif
o<seq3> if [#<seq> EQ 3]
g1 x #<x4s> y #<y4s> z #<zcurrent>
x #<x1s> y #<y1s>
x #<x2s> y #<y2s>
x #<x3s> y #<y3s>
x #<x4s> y #<y4s>
o<seq3> endif
o<wh23> endif
o<wh20> while [#<outlinepass> GT 0]
#<depthpass> = [#<depthpass> + 1]
o<wh10> endwhile
; after finishing at input scale, need to turn corner
; and go along the next line enough to turn off compensation
o<fin0> if [#<seq> EQ 0] ;end at pt 1
#<xfinal_a> = #<x1s>
#<yfinal_a> = #<y1s>
#<elen12> = [#<r> / [TAN[#<ang412>/2]]]
#<xfinal_b> = [#<x1s> + #<elen12> * #<cos12>]
#<yfinal_b> = [#<y1s> + #<elen12> * #<sin12>]
o<fin0> endif
o<fin1> if [#<seq> EQ 1] ;end at pt 2
#<xfinal_a> = #<x2s>
#<yfinal_a> = #<y2s>
#<elen23> = [#<r> / [TAN[#<ang123>/2]]]
#<xfinal_b> = [#<x2s> + #<elen23> * #<cos23>]
#<yfinal_b> = [#<y2s> + #<elen23> * #<sin23>]
o<fin1> endif
o<fin2> if [#<seq> EQ 2] ;end at pt 3
#<xfinal_a> = #<x3s>
#<yfinal_a> = #<y3s>
#<elen34> = [#<r> / [TAN[#<ang234>/2]]]
#<xfinal_b> = [#<x3s> + #<elen34> * #<cos34>]
#<yfinal_b> = [#<y3s> + #<elen34> * #<sin34>]
o<fin2> endif
o<fin3> if [#<seq> EQ 3] ;end at pt 4
#<xfinal_a> = #<x4s>
#<yfinal_a> = #<y4s>
#<elen41> = [#<r> / [TAN[#<ang341>/2]]]
#<xfinal_b> = [#<x4s> + #<elen41> * #<cos41>]
#<yfinal_b> = [#<y4s> + #<elen41> * #<sin41>]
o<fin3> endif
g1 x #<xfinal_a> y #<yfinal_a>
g1 x #<xfinal_b> y #<yfinal_b>
g0 z #<zsafe>
g40 ;cutter radius compensation off
o<qpocket> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,87 @@
( Rectangular area probe )
( adapted for ngcgui-compatibility from smartprobe.ngc written by Chris Radek )
( This program repeatedly probes a regular XY grid and writes the )
( probed locations to the file 'rectangle_probe_result.txt' in the same directory )
( as the INI file )
( Requires a probe connected to motion.probe-input )
( or use scripts/simulate_probe )
(info: Probe a rectangular area)
o<rectangle_probe> sub
#<xmin> = #1 (= -1.0)
#<xmax> = #2 (= 1.0)
#<xinterval> = #3 (= 0.1)
#<ymin> = #4 (= -1.0)
#<ymax> = #5 (= 1.0)
#<yinterval> = #6 (= 0.1)
#<zsafe> = #7 (= 1.1)
#<zprobe> = #8 (= -0.1)
#<probespeed> = #9 (= 20)
#<in_or_mm> = #10 (= 20 in|mm 20|21)
#<wait> = #11 (= 1 Wait for Start)
O1 if [ [#<in_or_mm> ne 20] and [#<in_or_mm> ne 21]]
(debug, in_or_mm invalid: #<in_or_mm> - EXITING)
(print, in_or_mm invalid: #<in_or_mm> - EXITING)
(AXIS,notify, rectangle_probe: in_or_mm invalid - EXITING)
m2
O1 endif
#<xsteps> = [fix [abs[#<xmax> - #<xmin>]/#<xinterval> + 1]]
#<ysteps> = [fix [abs[#<ymax> - #<ymin>]/#<yinterval> + 1]]
G#<in_or_mm>
#<points> = [#<xsteps> * #<ysteps>]
(debug, Probing #<xsteps> * #<ysteps> = #<points> points)
(LOGOPEN,rectangle_probe_result.txt)
(LOG,# xmin = #<xmin> xmax = #<xmax> xinterval = #<xinterval> xsteps = #<xsteps>)
(LOG,# ymin = #<ymin> ymax = #<ymax> yinterval = #<yinterval> ysteps = #<ysteps>)
#<yct> = 0
#<xct> = 0
G0Z#<zsafe>
F#<probespeed>
O2 while [#<yct> lt #<ysteps>]
#<xct> = 0
G0 Y[#<ymin>+#<yinterval>*#<yct>]
O3 while [#<xct> lt #<xsteps>]
#<xtarget> = 0
O4 if [[#<yct>/2] - fix[#<yct>/2] eq 0]
#<xtarget> = [#<xmin> + #<xinterval> * #<xct>]
O4 else
#<xtarget> = [#<xmin> + #<xinterval> * [#<xsteps> - #<xct> - 1]]
O4 endif
#<probesuccess> = 1
O5 while [#<probesuccess> NE 0]
G38.5 z#<zsafe> (probe until no contact away from work, no error)
#<probesuccess> = #5070
G38.3 x#<xtarget> (probe until contact, toward work, no error)
#<probesuccess> = #5070
O5 endwhile
O6 if [[#<wait> eq 1] and [[#<yct> eq 0] and [#<xct> eq 0]]]
(debug, S to Begin Rectangle Probe)
m0 (mandatory stop)
M110 (axisui.notifications-clear)
O6 endif
G38.2Z#<zprobe> (probe until contact, toward work, with error)
G0z#<zsafe>
#<probex> = #5061
#<probey> = #5062
#<probez> = #5063
(LOG,X#<probex> Y#<probey> Z#<probez>)
#<xct> = [#<xct> + 1]
O3 endwhile
G0Z#<zsafe>
#<yct> = [#<yct> + 1]
O2 endwhile
(LOG,# Finished: total points = #<points>)
(LOGCLOSE)
(debug, Finished: see rectangle_probe_result.txt)
G0Z#<zsafe>
G0X#<xmin>Y#<ymin>
o<rectangle_probe> endsub

View File

@@ -0,0 +1,11 @@
(info: simp -- simple subroutine example -- Ctrl-U to edit)
o<simp> sub
#<ra> = #1 (=.6 Radius A) ;Example parm with comment
#<radius_b> = #2 (=0.4) ;Example parm with no comment
#<feedrate> = #3 (=100)
(debug, feature: #<_feature:>)
(debug, remaining: #<_remaining_features:>)
g0x0y0z1
g3 i#<ra> f#<feedrate>
g3 i[0-#<radius_b>]
o<simp> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -0,0 +1,93 @@
(adapted from useful-subroutines.ngc)
(Original file is Copyright 2006 Chris Radek and released under the GPL v2.)
(info: slot: specify x1,y1 and x2,y2, applies radius compensation)
o<slot> sub
#<toolno> = #1 (=1)
#<rpm> = #2 (=2000)
#<feedrate> = #3 (=10)
#<zincr> = #4
#<cutdepth> = #5
#<zsafe> = #6 (=0.5)
#<zstart> = #7 (=0.005)
#<x1> = #8 (x1 center)
#<y1> = #9 (y1 center)
#<x2> = #10 (x2 center)
#<y2> = #11 (y2 center)
#<width> = #12
#<scale> = #13 (=1)
#<rotate> = #14 (=0)
#<xoff> = #15 (=0)
#<yoff> = #16 (=0)
#<spin_notify> = #17 (=0)
#<use_g43> = #18 (=1)
#<h_for_g43> = #19 (=0)
#<verbose> = #20 (=0)
o<i0> if [#<scale> EQ 0]
#<scale> = 1.0
(debug, scale was 0, setting #<scale>)
o<i0> endif
#<width> = [#<width> * #<scale>]
o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
#<tooldiam> = [#5410 + .001]
o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x1> = #<_move:x>
#<y1> = #<_move:y>
#<len1> = #<_move:len>
#<phi1> = #<_move:phi>
o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
#<x2> = #<_move:x>
#<y2> = #<_move:y>
#<len2> = #<_move:len>
#<phi2> = #<_move:phi>
#<radius>=[#<width>/2] (radius)
#<backdir>=[[atan [#<y2>-#<y1>]/[#<x2>-#<x1>]] + 180] ("backward" direction)
#<rtdir>=[#<backdir> + 90] ("right" side direction)
#<rcos_bd>=[#<radius> * [cos [#<backdir>]]]
#<rsin_bd>=[#<radius> * [sin [#<backdir>]]]
#<rcos_rd>=[#<radius> * [cos [#<rtdir>]]]
#<rsin_rd>=[#<radius> * [sin [#<rtdir>]]]
s #<rpm> m3
o<if1> if [#<spin_notify> GT 0]
o<spin> call [#<rpm>]
o<if1> endif
f#<feedrate>
g0 z#<zsafe>
g0 x[#<x1>+#<rcos_bd>+#<rcos_rd>] y[#<y1>+#<rsin_bd>+#<rsin_rd>]
g41 g1 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>]
g1 z#<zstart>
(#<dpercut>=[#<tooldiam>/2] rule-of-thumb)
#<dpercut>=#<zincr>
#<znow>=[#<zstart>-#<dpercut>] (z)
(down toward the specified depth a bit at a time)
o201 while [#<znow> GT [0-#<cutdepth>]]
g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>] z#<znow>
g3 x[#<x2>-#<rcos_rd>] y[#<y2>-#<rsin_rd>] r#<radius>
g1 x[#<x1>-#<rcos_rd>] y[#<y1>-#<rsin_rd>]
g3 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>] r#<radius>
#<znow>=[#<znow>-#<dpercut>]
o201 endwhile
(down to the actual depth and one more cut)
g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>] z[0-#<cutdepth>]
g3 x[#<x2>-#<rcos_rd>] y[#<y2>-#<rsin_rd>] r#<radius>
g1 x[#<x1>-#<rcos_rd>] y[#<y1>-#<rsin_rd>]
g3 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>] r#<radius>
g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>]
g0 z#<zsafe>
g40
o<slot> endsub

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -0,0 +1,3 @@
(not_a_subfile)
(debug, bye)
(print, bye)

View File

@@ -0,0 +1,40 @@
(cross product for two vectors 1-2 and 3-2 having a common vertex 2)
(ccw ==> + result but note:)
(if traversing 1->2->3, a cw cross product ==> a ccw traverse)
(return:)
( _cross:z magnitude)
( _cross:dir 1 for ccw per convention)
o<cross> sub
(not_a_subfile)
#<x1> = #1
#<y1> = #2
#<x2> = #3
#<y2> = #4
#<x3> = #5
#<y3> = #6
#<_cross:z> = [[#<x1>-#<x2>]*[#<y3>-#<y2>]-[#<x3>-#<y2>]*[#<y1>-#<y2>]]
#<_cross:dir> = 0 (default: 0)
o<l10> if [#<_cross:z> GT 0]
#<_cross:dir> = 1 (ccw)
o<l10> endif
o<l20> if [#<_cross:z> LT 0]
#<_cross:dir> = -1 (cw)
o<l20> endif
o<line> call [#<x2>][#<y2>][#<x1>][#<y1>]
#<len21> = #<_line:len>
o<line> call [#<x2>][#<y2>][#<x3>][#<y3>]
#<len23> = #<_line:len>
(print cross: #<x1> #<y1> #<x2> #<y2> #<x3> #<y3> #<x4> #<y4>)
(print cross: #<x1> #<x2> #<x3>)
(print cross: #<y1> #<y2> #<y3>)
(print cross: z=#<_cross:z> dir=#<_cross:dir>)
(print )
(debug cross: z=#<_cross:z> dir=#<_cross:dir>)
o<cross> endsub

View File

@@ -0,0 +1,129 @@
(info:dir determine direction for polygon described by ordered points)
(minimum 3 points, up to 6 points)
(return: #<_dir:> == 2 for CW, 3 for CCW, -1 for undetermined)
(return: #<_dir:area>)
(return: #<_dir:cx>, #<_dir:cy> centroid)
o<dir> sub
#<n> = #1 (=4 N neg:verbose)
#<x1> = #2
#<y1> = #3
#<x2> = #4
#<y2> = #5
#<x3> = #6
#<y3> = #7
#<x4> = #8 (=0)
#<y4> = #9 (=0)
#<x5> = #10 (=0)
#<y5> = #11 (=0)
#<x6> = #12 (=0)
#<y6> = #13 (=0)
#<verbose> = 0
o<i0> if [#<n> LT 0]
#<n> = [ABS[#<n>]]
#<verbose> = 1
o<i0> endif
o<i1> if [[#<n> GE 7] or [#<n> LE 2]]
(print, dir: problem bad n=#<n>)
(debug, dir: problem bad n=#<n>)
#<_dir:> = -1 ;undetermined with message, caller must handle
o<i1> endif
#<a> = 0
#<cx> = 0
#<cy> = 0
#<del> = [#<x1> * #<y2> - #<x2> * #<y1>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x2> + #<x1>] * #<del>]
#<cy> = [#<cy> + [#<y2> + #<y1>] * #<del>]
#<del> = [#<x2> * #<y3> - #<x3> * #<y2>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x3> + #<x2>] * #<del>]
#<cy> = [#<cy> + [#<y3> + #<y2>] * #<del>]
o<if3> if [#<n> eq 3]
#<del> = [#<x3> * #<y1> - #<x1> * #<y3>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x1> + #<x3>] * #<del>]
#<cy> = [#<cy> + [#<y1> + #<y3>] * #<del>]
o<if3> endif
o<if4> if [#<n> eq 4]
#<del> = [#<x3> * #<y4> - #<x4> * #<y3>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x4> + #<x3>] * #<del>]
#<cy> = [#<cy> + [#<y4> + #<y3>] * #<del>]
#<del> = [#<x4> * #<y1> - #<x1> * #<y4>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x1> + #<x4>] * #<del>]
#<cy> = [#<cy> + [#<y1> + #<y4>] * #<del>]
o<if4> endif
o<if5> if [#<n> eq 5]
#<del> = [#<x3> * #<y4> - #<x4> * #<y3>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x4> + #<x3>] * #<del>]
#<cy> = [#<cy> + [#<y4> + #<y3>] * #<del>]
#<del> = [#<x4> * #<y5> - #<x5> * #<y4>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x5> + #<x4>] * #<del>]
#<cy> = [#<cy> + [#<y5> + #<y4>] * #<del>]
#<del> = [#<x5> * #<y1> - #<x1> * #<y5>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x1> + #<x5>] * #<del>]
#<cy> = [#<cy> + [#<y1> + #<y5>] * #<del>]
o<if5> endif
o<if6> if [#<n> eq 6]
#<del> = [#<x3> * #<y4> - #<x4> * #<y3>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x4> + #<x3>] * #<del>]
#<cy> = [#<cy> + [#<y4> + #<y3>] * #<del>]
#<del> = [#<x4> * #<y5> - #<x5> * #<y4>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x5> + #<x4>] * #<del>]
#<cy> = [#<cy> + [#<y5> + #<y4>] * #<del>]
#<del> = [#<x5> * #<y6> - #<x6> * #<y5>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x6> + #<x5>] * #<del>]
#<cy> = [#<cy> + [#<y6> + #<y5>] * #<del>]
#<del> = [#<x6> * #<y1> - #<x1> * #<y6>]
#<a> = [#<a> + #<del>]
#<cx> = [#<cx> + [#<x1> + #<x6>] * #<del>]
#<cy> = [#<cy> + [#<y1> + #<y6>] * #<del>]
o<if6> endif
#<_dir:cx> = [#<cx> / #<a> / 3] ; signed area reqd here
#<_dir:cy> = [#<cy> / #<a> / 3] ; signed area reqd here
#<_dir:area> = [ABS[#<a>]/2] ; return unsigned area
o<f0> if [#<a> GT 0]
#<_dir:> = 3 (ccw)
o<f0> else
o<f1> if [#<a> LT 0]
#<_dir:> = 2 (cw)
o<f1> else
#<_dir:> = -1 ;undetermined
o<f1> endif
o<f0> endif
o<f2> if [#<verbose> GT 0]
o<f3> if [#<_dir:> eq 2]
(debug, dir: CW #<_dir:> area=#<_dir:area> cx=#<_dir:cx> cy=#<_dir:cy>)
o<f3> else
(debug, dir: CCW #<_dir:> area=#<_dir:area> cx=#<_dir:cx> cy=#<_dir:cy>)
o<f3> endif
o<f2> endif
o<dir> endsub
; ref: many sources for polygons on the web, for example:
; http://paulbourke.net/geometry/polyarea/

View File

@@ -0,0 +1,45 @@
(dot product for two vectors 1-2 and 3-2 having a common vertex 2)
(note u=[Ucos[a],Usin[a]], v=[V[cos[b],Vsin[b] then:)
( u dot v = U*Vcos[a-b] phi := a-b )
( u dot v > 0 ==> acute phi = [-90, 90] )
( u dot v < 0 ==> obtuse phi = [ 90,270] )
( u dot v = 0 ==> right phi = 90 )
(return:)
( _dot:dot scalar product)
(_dot:ang [ 0,180] angle between vectors -- for cw,ccw determination)
(_dot:phi [-180,180] actual angle between vectors)
(_dot:acu [ 0, 90] acute angle between the extended vectors)
o<dot> sub
(not_a_subfile)
#<x1> = #1
#<y1> = #2
#<x2> = #3
#<y2> = #4
#<x3> = #5
#<y3> = #6
#<dx1> = [#<x1>-#<x2>]
#<dy1> = [#<y1>-#<y2>]
#<dx3> = [#<x3>-#<x2>]
#<dy3> = [#<y3>-#<y2>]
#<_dot:dot> = [#<dx1>*#<dx3> + #<dy1>*#<dy3>]
#<magp> = SQRT[[#<dx1>*#<dx1>+#<dy1>*#<dy1>]*[#<dx3>*#<dx3>+#<dy3>*#<dy3>]]
#<_dot:ang> = ACOS[#<_dot:dot>/#<magp>]
#<_dot:phi> = #<_dot:ang>
o<dot0> if [#<_dot:dot> LT 0]
#<_dot:phi> = [ 0 - #<_dot:ang>]
o<dot0> endif
#<_dot:acu> = #<_dot:phi>
o<dot1> if [#<_dot:ang> GT 90]
#<_dot:acu> = [180 - #<_dot:ang>]
o<dot1> endif
(print dot: #<x1> #<y1> #<x2> #<y2> #<x3> #<y3> magp=#<magp> )
(print dot: dot=#<_dot:dot> ang=#<_dot:ang> phi=#<_dot:phi> acu=#<_dot:acu>)
o<dot> endsub

View File

@@ -0,0 +1,84 @@
(compute a quarter-arc preentry and radius vector to a point x,y)
(return: _entry:prex,prey == preentry point)
( _entry:vx,vy == vector from start x,y to center xctr,yctr)
(Usage: for entry to a point on an arc of a circle:)
( o<entry> call [inside][dir][tooldiam][x][y][xctr][yctr])
( then preentry point is: prex = #<_entry:prex>)
( prey = #<_entry:prey>)
( and the entry arc is: g2|3 x #<x> y #<y> i #<_entry:vx> j #<_entry:vy>)
o<entry> sub
(not_a_subfile)
#<inside> = #1 (1:in, 0:out)
#<dir> = #2 (2:cw, 3:ccw)
#<tooldiam> = #3
#<x> = #4
#<y> = #5
#<xctr> = #6
#<yctr> = #7
#<delx> = [#<x> - #<xctr>]
#<dely> = [#<y> - #<yctr>]
o<l20> if [[#<inside> NE 0] AND [#<inside> NE 1]]
(debug, entry: bad inside specifier #<inside> -- EXITING)
(print, entry: bad inside specifier #<inside> -- EXITING)
(AXIS,notify, entry: bad inside specifier -- EXITING)
m2
o<l20> endif
o<l30> if [[#<dir> NE 2] AND [#<dir> NE 3]]
(debug, entry: bad dir specifier #<dir> -- EXITING)
(print, entry: bad dir specifier #<dir> -- EXITING)
(AXIS,notify, entry: bad dir specifier #<inside> -- EXITING)
m2
o<l30> endif
#<rt> = [#<tooldiam> / 2.0]
#<epsilon> = 0.000001
o<l40> if [ABS[#<delx>] GT #<epsilon>]
#<phi> = ATAN[#<dely>]/[#<delx>]
o<l40> else
o<l50> if [#<dely> GE 0]
#<phi> = 90
o<l50> else
#<phi> = -90
o<l50> endif
o<l40> endif
(compute pre-entry px,py for 1/4 circle with radius rt)
(and vector from start x,y to center of circle)
o<l60> if [#<inside> EQ 1]
o<l70> if [#<dir> EQ 2] (cw)
#<px> = [#<delx> - #<rt>*sin[#<phi>] - #<rt>*cos[#<phi>]]
#<py> = [#<dely> + #<rt>*cos[#<phi>] - #<rt>*sin[#<phi>]]
#<vx> = [0 + #<rt>*sin[#<phi>]]
#<vy> = [0 - #<rt>*cos[#<phi>]]
o<l70> else (ccw)
#<px> = [#<delx> + #<rt>*sin[#<phi>] - #<rt>*cos[#<phi>]]
#<py> = [#<dely> - #<rt>*cos[#<phi>] - #<rt>*sin[#<phi>]]
#<vx> = [0 - #<rt>*sin[#<phi>]]
#<vy> = [0 + #<rt>*cos[#<phi>]]
o<l70> endif
o<l60> else
o<l80> if [#<dir> EQ 2] (cw)
#<px> = [#<delx> - #<rt>*sin[#<phi>] + #<rt>*cos[#<phi>]]
#<py> = [#<dely> + #<rt>*cos[#<phi>] + #<rt>*sin[#<phi>]]
#<vx> = [0 + #<rt>*sin[#<phi>]]
#<vy> = [0 - #<rt>*cos[#<phi>]]
o<l80> else (ccw)
#<px> = [#<delx> + #<rt>*sin[#<phi>] + #<rt>*cos[#<phi>]]
#<py> = [#<dely> - #<rt>*cos[#<phi>] + #<rt>*sin[#<phi>]]
#<vx> = [0 - #<rt>*sin[#<phi>]]
#<vy> = [0 + #<rt>*cos[#<phi>]]
o<l80> endif
o<l60> endif
#<_entry:prex> = [#<px> + #<xctr>]
#<_entry:prey> = [#<py> + #<yctr>]
#<_entry:vx> = #<vx>
#<_entry:vy> = #<vy>
o<entry> endsub

View File

@@ -0,0 +1,14 @@
(not_a_subfile)
g17 (xy plane)
g20 (inches)
g40 (cancel cutter radius compensation)
g49 (cancel tool lengthoffset)
g90 (absolute distance mode)
g94 (units/min feedrate)
g61 (exact stop)
#<_tol> = 0.001
g64 p#<_tol> (path control)
g59

View File

@@ -0,0 +1,29 @@
(Adapted from Program to mill a flowsnake.ngc by K. Lerman)
o<gosper_sub> sub
(not_a_subfile)
(one level of gosper recursive algorithm)
#<lvl> = #1
#<startX> = #2
#<startY> = #3
#<endX> = #4
#<endY> = #5
#<feedrate> = #6
#<fr> = #<feedrate>
o<l50> if [#<lvl> EQ 0]
g1 f #<feedrate> x #<endX> y #<endY>
o<l50> else
#<p1X> = [[#<startX> * 2 + #<endX>]/3]
#<p1Y> = [[#<startY> * 2 + #<endY>]/3]
#<p2X> = [[#<startX> + #<endX>]/2 + [#<endY> - #<startY>]/[SQRT[12.0]]]
#<p2Y> = [[#<startY> + #<endY>]/2 - [#<endX> - #<startX>]/[SQRT[12.0]]]
#<p3X> = [[#<startX> + 2 * #<endX>]/3]
#<p3Y> = [[#<startY> + 2 * #<endY>]/3]
o<gosper_sub> call [#<lvl>-1][#<startX>][#<startY>][#<p1X>] [#<p1Y>] [#<fr>]
o<gosper_sub> call [#<lvl>-1][#<p1X>] [#<p1Y>] [#<p2X>] [#<p2Y>] [#<fr>]
o<gosper_sub> call [#<lvl>-1][#<p2X>] [#<p2Y>] [#<p3X>] [#<p3Y>] [#<fr>]
o<gosper_sub> call [#<lvl>-1][#<p3X>] [#<p3Y>] [#<endX>][#<endY>][#<fr>]
o<l50> endif
o<gosper_sub> endsub

View File

@@ -0,0 +1,12 @@
(not_a_subfile)
g17 (xy plane)
g20 (inches)
g40 (cancel cutter radius compensation)
g49 (cancel tool lengthoffset)
g90 (absolute distance mode)
g94 (units/min feedrate)
g54 (Coordinate system 1 default)
#<tol> = 0.001
g64 p#<tol> (path control stop)

View File

@@ -0,0 +1,31 @@
(return: _line:len,phi,cos,sin)
o<line> sub
(not_a_subfile)
#<x1> = #1
#<y1> = #2
#<x2> = #3
#<y2> = #4
(print line: #<x1> #<y1> #<x2> #<y2>)
#<epsilon> = 0.000001
#<dely> = [#<y2> - #<y1>]
#<delx> = [#<x2> - #<x1>]
#<_line:len> = SQRT[#<delx>*#<delx> + #<dely>*#<dely>]
o<l01> if [ABS[#<delx>] GT #<epsilon>]
#<_line:phi> = ATAN[#<dely>]/[#<delx>]
o<l01> else
o<l02> if [#<dely> GE 0]
#<_line:phi> = 90
o<l02> else
#<_line:phi> = -90
o<l02> endif
o<l01> endif
#<_line:cos> = COS[#<_line:phi>]
#<_line:sin> = SIN[#<_line:phi>]
(print line: #<_line:len> #<_line:phi> #<_line:cos> #<_line:sin>)
o<line> endsub

View File

@@ -0,0 +1,51 @@
; loadtool: with options for G43 and H
o<loadtool> sub
(not_a_subfile)
#<toolno> = #1
#<use_g43> = #2
#<h_for_g43> = #3
#<verbose> = #4
o<l0> if [#<toolno> EQ 0]
;Uncomment next 4 lines to require a nonzero toolno
;(print, loadtool: EXIT: toolno required not 0)
;(debug, loadtool: EXIT: toolno required not 0)
;(AXIS,notify, loadtool: EXIT: toolno required not 0)
;m2 (quit)
(print, loadtool: Warning: toolno is 0)
(debug, loadtool: Warning: toolno is 0)
o<l0> endif
o<l1> if [#<use_g43> NE 0]
o<l11> if [#<h_for_g43> EQ 0]
o<l12> if [#<verbose> NE 0]
(debug, loadtool:G43 noH)
o<l12> endif
T#<toolno> M6 G43
o<l11> else
o<l13> if [#<verbose> NE 0]
(debug, loadtool:G43 H#<h_for_g43>)
o<l13> endif
T#<toolno> M6 G43 H#<h_for_g43>
o<l11> endif
o<l1> else
o<l14> if [#<verbose> NE 0]
(debug, loadtool:no G43)
o<l14> endif
T#<toolno> M6
o<l1> endif
o<loadtool> endsub
;G43 without an H word uses the currently loaded tool from the last Tn M6.
;G43 Hn uses the offset for tool n.
;Note
; G43 H0 is a little special. Its behavior is different on random tool
; changer machines and nonrandom tool changer machines
;
; On nonrandom tool changer machines, G43 H0 applies the TLO of the
; tool currently in the spindle, or a TLO of 0 if no tool is in the spindle.
;
; On random tool changer machines, G43 H0 applies the TLO of the tool T0
; defined in the tool table file (or causes an error if T0 is not defined
; in the tool table).

View File

@@ -0,0 +1,11 @@
(not_a_subfile)
g17 (xy plane)
g21 (mm)
g40 (cancel cutter radius compensation)
g49 (cancel tool lengthoffset)
g90 (absolute distance mode)
g94 (units/min feedrate)
g54 (Coordinate system 1 default)
#<tol> = 0.001
g64 p#<tol> (path control stop)

View File

@@ -0,0 +1,34 @@
(return: _move:x,y,len,phi,cos,sin)
o<move> sub
(not_a_subfile)
#<x> = #1
#<y> = #2
#<rotate> = #3 (=0 degrees)
#<scale> = #4 (=1)
#<xoff> = #5 (=0 after rotation)
#<yoff> = #6 (=0 after rotation)
o<if1> if [0]
(for offsetting before rotation)
#<x> = [#<x> + #<xpre>]
#<y> = [#<y> + #<ypre>]
o<if1> endif
o<line> call [0][0][#<x>][#<y>]
#<len> = #<_line:len>
#<phi> = #<_line:phi>
#<cos> = #<_line:cos>
#<sin> = #<_line:sin>
#<x> = [#<xoff> + #<scale> * #<len> * COS[#<rotate> + #<phi>]]
#<y> = [#<yoff> + #<scale> * #<len> * SIN[#<rotate> + #<phi>]]
o<line> call [0][0][#<x>][#<y>]
#<_move:len> = #<_line:len>
#<_move:phi> = #<_line:phi>
#<_move:cos> = #<_line:cos>
#<_move:sin> = #<_line:sin>
#<_move:x> = #<x>
#<_move:y> = #<y>
o<move> endsub

View File

@@ -0,0 +1,53 @@
(info: compute ctr, min, max, avg)
o<pointsdata> sub
#<howmany> = #1 (=4)
#<v1> = #2
#<v2> = #3
#<v3> = #4
#<v4> = #5
#<v5> = #6 (=0)
#<v6> = #7 (=0)
#<v7> = #8 (=0)
#<v8> = #9 (=0)
#<maxhowmany> = 8
o<if10> if [#<howmany> GT #<maxhowmany>]
(debug, pointsdata: howmany too big: #<howmany> - EXITING)
(debug, pointsdata: howmany too big: #<howmany> - EXITING)
(AXIS,notify, pointsdata: howmany too big - EXITING)
m2
o<if10> endif
o<if15> if [#<howmany> LT 2]
(debug, pointsdata: howmany too small: #<howmany> - EXITING)
(debug, pointsdata: howmany too small: #<howmany> - EXITING)
(AXIS,notify, pointsdata: howmany too small - EXITING)
m2
o<if15> endif
#<i> = 2
#<total> = 0
#<_pointsdata:min> = +99999999
#<_pointsdata:max> = -99999999
o<wh10> while [#<i> LE [1 + #<howmany>]]
#<val> = ##<i>
;(debug, val=#<val>)
o<if20> if [#<val> GT #<_pointsdata:max>]
#<_pointsdata:max> = #<val>
o<if20> endif
o<if30> if [#<val> LT #<_pointsdata:min>]
#<_pointsdata:min> = #<val>
o<if30> endif
#<total> = [#<total> + #<val>]
#<i> = [#<i> +1]
o<wh10> endwhile
#<_pointsdata:ctr> = [[#<_pointsdata:max>+#<_pointsdata:min>]/2]
#<_pointsdata:avg> = [#<total>/#<howmany>]
;(debug, min=#<_pointsdata:min>)
;(debug, ctr=#<_pointsdata:ctr>)
;(debug, max=#<_pointsdata:max>)
;(debug, avg=#<_pointsdata:avg>)
o<pointsdata> endsub

View File

@@ -0,0 +1,20 @@
;dng-- designed with the axis gui in mind
; but not very intuitive with touchy
; so changed message and remove mandatory stop
; for touchy testing
;helper routine to prompt setting of spindle speed
;use after giving operator message for example
; 1) prompt user to continue
; 2) M110 clears axis notifications (requires emc2.4)
o<spin> sub
(not_a_subfile)
#<rpm> = #1
o<l0> if [#<_feature:> LT 1]
;(debug, S to continue: Spindle rpm=#<rpm>)
;m0 (mandatory stop)
(debug, Spindle rpm = #<rpm>)
M110 (axisui.notifications-clear)
o<l0> endif
o<spin> endsub

View File

@@ -0,0 +1,85 @@
(info: xyz -- x,y,z axis exerciser, type 0: line, type 1: box)
o<xyz> sub
(for testing, tuning servo, etc)
(for single axis, set axes for zero travel)
(type 0: simple motion between two points)
(type 1: series of moves one,two,or three axes at a time)
#<feedrate> = #1 (=60 feedrate)
#<type> = #2 (=1 type: 0|1)
#<xmin> = #3 (=-0.5 x distance)
#<xmax> = #4 (=+0.5 x distance)
#<ymin> = #5 (=+2.0 y distance)
#<ymax> = #6 (=+3.5 y distance)
#<zmin> = #7 (=+1.0 z distance)
#<zmax> = #8 (=+2.0 z distance)
#<ct> = #9 (=5 iterations)
#<i> = 0
#<x0> = #<xmin>
#<x1> = #<xmax>
#<y0> = #<ymin>
#<y1> = #<ymax>
#<z0> = #<zmin>
#<z1> = #<zmax>
(debug, feature: #<_feature:>)
(debug, remaining: #<_remaining_features:>)
f #<feedrate>
g1 x #<x0> y #<y0> z #<z0>
o<l50> while [#<i> LT #<ct>]
o<l60> if [#<type> EQ 0]
x #<x1> y #<y1> z #<z1>
x #<x0> y #<y0> z #<z0>
o<l60> endif
o<l70> if [#<type> EQ 1]
(gray)
x #<x0> y #<y0> z #<z0>
x #<x1> y #<y0> z #<z0>
x #<x1> y #<y1> z #<z0>
x #<x0> y #<y1> z #<z0>
x #<x0> y #<y1> z #<z1>
x #<x1> y #<y1> z #<z1>
x #<x1> y #<y0> z #<z1>
x #<x0> y #<y0> z #<z1>
(gray)
x #<x0> y #<y0> z #<z0>
x #<x0> y #<y0> z #<z1>
x #<x0> y #<y1> z #<z1>
x #<x0> y #<y1> z #<z0>
x #<x1> y #<y1> z #<z0>
x #<x1> y #<y1> z #<z1>
x #<x1> y #<y0> z #<z1>
x #<x1> y #<y0> z #<z0>
(gray)
x #<x0> y #<y0> z #<z0>
x #<x0> y #<y0> z #<z1>
x #<x1> y #<y0> z #<z1>
x #<x1> y #<y0> z #<z0>
x #<x1> y #<y1> z #<z0>
x #<x1> y #<y1> z #<z1>
x #<x0> y #<y1> z #<z1>
x #<x0> y #<y1> z #<z0>
(binary)
x #<x0> y #<y0> z #<z0>
x #<x0> y #<y0> z #<z1>
x #<x0> y #<y1> z #<z0>
x #<x0> y #<y1> z #<z1>
x #<x1> y #<y0> z #<z0>
x #<x1> y #<y0> z #<z1>
x #<x1> y #<y1> z #<z0>
x #<x1> y #<y1> z #<z1>
o<l70> endif
#<i> = [#<i> + 1]
o<l50> endwhile
o<xyz> endsub

BIN
nc_files/ngcgui_lib/xyz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB