summaryrefslogtreecommitdiffstats
path: root/gcode/biquad.ngc
blob: 5a8b7277ff09e6b37b3f63a36a60fb345a035cb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
%
( *************************************************************************** )
( * Biquad tool                                                             * )
( * Metrical RS274/NGC program                                              * )
( * Copyright 2008 Michael Buesch <mb@bu3sch.de>                            * )
( * Licensed under the GNU/GPL version 3                                    * )
( *                                                                         * )
( * Origin is in the center of the leftmost quad [X-]. Z0 = surface.        * )
( *************************************************************************** )

#<_cutter_dia> = 6		( Cutter diameter )
#<_speed> = 1500		( min^-1 )
#<_feed> = 1000			( mm/min )

( Workpiece origin coordinates [in absolute machine coordinates] )
#<origin_x> = -30
#<origin_y> = 0
#<origin_z> = -10

( Quad dimensions )
#<_nr> = 4				( Number of quads. [For one biquad say 2] )
#<_depth> = 5			( Cutting depth )
#<_depth_step> = 2.5	( Step for cutting in depth)
#<wire_dia> = 1			( Diameter of the wire used )
#<width> = 30.5			( Square width [wire center] )

( Internal parameters )
#<width> = [#<width> - #<wire_dia>] ( Adjust to used wire )
#<_c> = [SIN[45] * #<width>] ( Cathetus )
#<_current_cutter_dia> = #<_cutter_dia>

G17 G21 G40 G49 G80 G90 G94 ( Initial modes )
G10 L2 P1 X#<origin_x> Y#<origin_y> Z#<origin_z>

G53 G0 X0 Y0 Z0
G54 S#<_speed> F#<_feed> M3


( Subroutine for the outlines of one quad )
O1 sub
	#<z> = 0
	G0 X-10 Y[#<_c> + 10]
	G0 Z0.5
	G1 Z0
	O911 while [#<z> lt #<_depth>]

		G1 X-10 Y[#<_c> + 10]
		G91 G1 Z[-1 * #<_depth_step>]
		G90
		G41.1 D#<_current_cutter_dia>
		G1 X0 Y#<_c> (Entry move)

		G1 X#<_c> Y0
		G1 X0 Y[-1 * #<_c>]
		G1 X[-1 * #<_c>] Y0
		G1 X0 Y#<_c>

		G40 X10 Y[#<_c> + 10]

		#<z> = [#<z> + #<_depth_step>]
	O911 endwhile
	G0 Z1
O1 endsub


( Sub-subroutine for the rest )
( #1 is the X factor, #2 is the Y factor. )
O3 sub
	#<z> = 0
	G0 X[[#<_c> + #<_cutter_dia>/2] * #1] Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
	G0 Z0.5
	G1 Z0
	O921 while [#<z> lt #<_depth>]
		G0 X[[#<_c> + #<_cutter_dia>/2] * #1] Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G91 G1 Z[-1 * #<_depth_step>]
		G90
		G1 Y[[1 + 6] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G0 X[[#<_c> + #<_cutter_dia>/2 - 5] * #1]
		G1 Y[[1 + 5] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G0 X[[#<_c> + #<_cutter_dia>/2 - 10] * #1]
		G1 Y[[1 + 10] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G0 X[[#<_c> + #<_cutter_dia>/2 - 15] * #1]
		G1 Y[[1 + 15] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G0 X[[#<_c> + #<_cutter_dia>/2 - 20] * #1]
		G1 Y[[1 + 20] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		G0 X[[#<_c> + #<_cutter_dia>/2 - 25] * #1]
		G1 Y[[1 + 23] * #2]
		G1 Y[[#<_c> + #<_cutter_dia>/2 + 2] * #2]
		#<z> = [#<z> + #<_depth_step>]
	O921 endwhile
	G0 Z1


O3 endsub

( Subroutine for the rest )
O2 sub
	O3 call [1] [1]		( X+, Y+ )
	O3 call [-1] [1]	( X-, Y+ )
	O3 call [-1] [-1]	( X-, Y- )
	O3 call [1] [-1]	( X+, Y- )
O2 endsub


#<z> = 0
G0 X[[#<_c> + #<_cutter_dia>/2 + 1] * -1 - 10] Y[#<_c> + #<_cutter_dia>/2 + 1]
G0 Z0.5
G1 Z0
O901 while [#<z> lt #<_depth>]
	G0 X[[#<_c> + #<_cutter_dia>/2 + 1] * -1 - 10] Y[#<_c> + #<_cutter_dia>/2 + 1]
	G91 G1 Z[-1 * #<_depth_step>]
	G90
	G1 X[[#<_c>*2 + #<_cutter_dia> + 1] * #<_nr>]
	G1 Y[[#<_c> + #<_cutter_dia>/2 + 1] * -1]
	G1 X[[#<_c> + #<_cutter_dia>/2 + 1] * -1]
	G1 Y[#<_c> + #<_cutter_dia>/2 + 1]
	#<z> = [#<z> + #<_depth_step>]
O901 endwhile
G0 Z1

O902 while [1 eq 1]
	( Remove parts that don't belong to the quads )
	O2 call

	( Mill quad outlines. First with a small diameter offset. )
	#<_current_cutter_dia> = [#<_cutter_dia> + 0.05]
	O1 call
	( And without offset and depth stepping )
	#<old_step> = #<_depth_step>
	#<_depth_step> = #<_depth>
	#<_current_cutter_dia> = #<_cutter_dia>
	O1 call
	#<_depth_step> = #<old_step>

	#<_nr> = [#<_nr> - 1]
	O903 if [ #<_nr> le 0 ]
		O902 break ( No more quad to go )
	O903 endif
	( Move origin to next quad )
	G0 X0
	G92 X[#<_c> * -2] ( Move origin FIXME! wire diameter!)
O902 endwhile

G53 G0 X0 Y0 Z0
M30

%
vim: syntax=rs274ngc ts=4
bues.ch cgit interface