/ nc_files / ngcgui_lib / slot.ngc
slot.ngc
 1  (adapted from useful-subroutines.ngc)
 2  (Original file is Copyright 2006 Chris Radek and released under the GPL v2.)
 3  
 4  (info: slot: specify x1,y1 and x2,y2, applies radius compensation)
 5  o<slot> sub
 6  
 7  #<toolno>    =  #1 (=1)
 8  #<rpm>       =  #2 (=2000)
 9  #<feedrate>  =  #3 (=10)
10  #<zincr>     =  #4
11  #<cutdepth>  =  #5
12  #<zsafe>     =  #6 (=0.5)
13  #<zstart>    =  #7 (=0.005)
14  #<x1>        =  #8 (x1 center)
15  #<y1>        =  #9 (y1 center)
16  #<x2>        = #10 (x2 center)
17  #<y2>        = #11 (y2 center)
18  #<width>     = #12
19  #<scale>     = #13 (=1)
20  #<rotate>    = #14 (=0)
21  #<xoff>      = #15 (=0)
22  #<yoff>      = #16 (=0)
23  #<spin_notify> = #17 (=0)
24  #<use_g43>     = #18 (=1)
25  #<h_for_g43>   = #19 (=0)
26  #<verbose>     = #20 (=0)
27  
28  o<i0> if [#<scale> EQ 0]
29          #<scale> = 1.0
30          (debug, scale was 0, setting #<scale>)
31  o<i0> endif
32  
33  #<width> = [#<width> * #<scale>]
34  
35  o<loadtool> call [#<toolno>][#<use_g43>][#<h_for_g43>][#<verbose>]
36  #<tooldiam>   = [#5410 + .001]
37  
38  o<move> call [#<x1>][#<y1>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
39  #<x1>      = #<_move:x>
40  #<y1>      = #<_move:y>
41  #<len1>    = #<_move:len>
42  #<phi1>    = #<_move:phi>
43  o<move> call [#<x2>][#<y2>][#<rotate>][#<scale>][#<xoff>][#<yoff>]
44  #<x2>      = #<_move:x>
45  #<y2>      = #<_move:y>
46  #<len2>    = #<_move:len>
47  #<phi2>    = #<_move:phi>
48  
49  
50  #<radius>=[#<width>/2] (radius)
51  #<backdir>=[[atan [#<y2>-#<y1>]/[#<x2>-#<x1>]] + 180] ("backward" direction)
52  #<rtdir>=[#<backdir> + 90] ("right" side direction)
53  #<rcos_bd>=[#<radius> * [cos [#<backdir>]]]
54  #<rsin_bd>=[#<radius> * [sin [#<backdir>]]]
55  #<rcos_rd>=[#<radius> * [cos [#<rtdir>]]]
56  #<rsin_rd>=[#<radius> * [sin [#<rtdir>]]]
57  
58  
59          s #<rpm> m3
60  o<if1>   if [#<spin_notify> GT 0]
61  o<spin>    call [#<rpm>]
62  o<if1>   endif
63          f#<feedrate>
64  
65          g0 z#<zsafe>
66          g0 x[#<x1>+#<rcos_bd>+#<rcos_rd>] y[#<y1>+#<rsin_bd>+#<rsin_rd>]
67  
68          g41 g1 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>]
69          g1 z#<zstart>
70  
71          (#<dpercut>=[#<tooldiam>/2] rule-of-thumb)
72          #<dpercut>=#<zincr>
73  
74          #<znow>=[#<zstart>-#<dpercut>] (z)
75          (down toward the specified depth a bit at a time)
76  
77  o201    while [#<znow> GT [0-#<cutdepth>]]
78           g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>] z#<znow>
79           g3 x[#<x2>-#<rcos_rd>] y[#<y2>-#<rsin_rd>] r#<radius>
80           g1 x[#<x1>-#<rcos_rd>] y[#<y1>-#<rsin_rd>]
81           g3 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>] r#<radius>
82           #<znow>=[#<znow>-#<dpercut>]
83  o201    endwhile
84           (down to the actual depth and one more cut)
85           g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>] z[0-#<cutdepth>]
86           g3 x[#<x2>-#<rcos_rd>] y[#<y2>-#<rsin_rd>] r#<radius>
87           g1 x[#<x1>-#<rcos_rd>] y[#<y1>-#<rsin_rd>]
88           g3 x[#<x1>+#<rcos_rd>] y[#<y1>+#<rsin_rd>] r#<radius>
89           g1 x[#<x2>+#<rcos_rd>] y[#<y2>+#<rsin_rd>]
90  
91           g0 z#<zsafe>
92           g40
93  o<slot> endsub