/ nc_files / probe / basic_probe / macros / probe_cal_square_boss.ngc
probe_cal_square_boss.ngc
  1  (author: Chris P)
  2  (version: 0.1)
  3  (date: 05/8/19)
  4  
  5  (Probe calibration offset using defined width square boss)
  6  (Start probe position is over center of stock in X and Y axis)
  7  (within max z distance, ensure all settings have been)
  8  (set properly according to help diagrams)
  9  
 10  o<probe_cal_square_boss> sub
 11  
 12    (uses NGCGUI style arg spec)
 13    (number after "=" in comment is default value)
 14    #<probe_tool_number> = #1    (=99)
 15    #<max_z_distance> = #2       (=0.5000)
 16    #<max_xy_distance> = #3      (=0.5000)
 17    #<xy_clearance> = #4         (=0.1000)
 18    #<z_clearance> = #5          (=0.1000)
 19    #<step_off_width> = #6       (=0.5000)
 20    #<extra_probe_depth> = #7    (=0.0000)
 21    #<probe_slow_fr> = #8        (=0.0)
 22    #<probe_fast_fr> = #9        (=10.0)
 23    #<calibration_offset> = #10  (=0.0000)
 24    #<x_hint> = #11              (=1.0000)
 25    #<y_hint> = #12              (=1.0000)
 26    #<diameter_hint> = #13       (=1.0000)
 27    #<edge_width> = #14          (=0.5000)
 28    #<probe_mode> = #15          (=0)
 29    #<cal_diameter> = #16        (=0.0000)
 30    #<x_cal_width> = #17         (=1.0000)
 31    #<y_cal_width> = #18         (=1.0000)
 32    #<sq_cal_axis> = #19         (=1)
 33  
 34  
 35    (Cancel G92 offsets)
 36    G92.1
 37  
 38    #<workspace_x> = #[5201 + [20 * #5220]]
 39    #<workspace_y> = #[5202 + [20 * #5220]]
 40    #<workspace_z> = #[5203 + [20 * #5220]]
 41  
 42    (Probe Tool Safety Check)
 43    o<110> if [#5400 NE #<probe_tool_number>]
 44    (MSG, Specified probe tool #<probe_tool_number> not in spindle, aborting)
 45     o<probe_cal_square_boss> return
 46    o<110> endif
 47  
 48    (Probe Diameter)
 49    #<probe_diameter> = #5410
 50  
 51    (Probe Radius)
 52    #<probe_radius> = [#<probe_diameter> / 2]
 53  
 54    (Probe Centerline Offset)
 55    #<probe_center_offset> = [#<probe_radius> - #<calibration_offset>]
 56  
 57    (remove probe tip diam and cal offset from probed width calculations)
 58    #<probe_diameter_offset> = [#<probe_diameter> - [#<calibration_offset> * 2]]
 59  
 60    #<z_probe_stack> = [#<z_clearance> + #<probe_diameter> + #<extra_probe_depth>]
 61  
 62    (Call sub "probe_z_minus_sub" to Probe top of Workpiece)
 63    o<probe_z_minus_sub> call [#1][#2][#5][#8][#9][#15]
 64  
 65    (Probe X Positioning Move, X hint/2 + Step Off Width)
 66    G91
 67    G0 X-[#<x_hint>/2 + #<step_off_width>]
 68  
 69    (Probe X Positioning Move, to Probing Depth)
 70    F[#<probe_fast_fr>]
 71    G1 Z-[#<z_probe_stack>]
 72  
 73    (Call sub "probe_x_plus" to Probe x+ side of Workpiece)
 74    o<probe_x_plus> call [#1][#3][#4][#8][#9][#10]
 75  
 76    #<x_plus_probed> = #5061
 77  
 78    (first side Probe Completion Move to Z Clearance Plane)
 79    G91
 80    G0 Z[#<z_probe_stack>]
 81  
 82    (Positioning move in X, X Hint + Step Off Width at Rapid Speed)
 83    G91
 84    G0 X[#<x_hint> + #<step_off_width> + #<xy_clearance>]
 85  
 86    (Probe X Positioning Move, to Probing Depth)
 87    F[#<probe_fast_fr>]
 88    G1 Z-[#<z_probe_stack>]
 89  
 90    (Call sub "probe_x_minus" to Probe x- side of Workpiece)
 91    o<probe_x_minus> call [#1][#3][#4][#8][#9][#10]
 92  
 93    #<x_minus_probed> = #5061
 94  
 95    (probed center calulation)
 96    #<x_center_probed> = [[#<x_minus_probed> + #<x_plus_probed>] / 2]
 97  
 98    (calculate X Width Probed)
 99    #<raw_width> = [#<x_minus_probed> - #<x_plus_probed>]
100  
101    (Completed probed width calculations)
102    #<x_probed_width> = [#<raw_width> - #<probe_diameter_offset>]
103  
104    M68 E0 Q[#<x_probed_width>]
105  
106    M68 E10 Q[#<x_center_probed>]
107  
108    G91
109    G0 Z[#<z_probe_stack>]
110    G90
111    G0 X[#<x_center_probed>]
112  
113    (Probe Y Positioning Move, Y hint/2 + Step Off Width)
114    G91
115    G0 Y-[#<y_hint>/2 + #<step_off_width>]
116  
117    (Probe Y Positioning Move, to Probing Depth)
118    F[#<probe_fast_fr>]
119    G1 Z-[#<z_probe_stack>]
120  
121    (Call sub "probe_y_plus" to Probe y+ side of Workpiece)
122    o<probe_y_plus> call [#1][#3][#4][#8][#9][#10]
123  
124    #<y_plus_probed> = #5062
125  
126    (first side Probe Completion Move to Z Clearance Plane)
127    G91
128    G0 Z[#<z_probe_stack>]
129  
130    (Positioning move in Y, Y Hint + Step Off Width at Rapid Speed)
131    G91
132    G0 Y[#<y_hint> + #<step_off_width> + #<xy_clearance>]
133  
134    (Probe Y Positioning Move, to Probing Depth)
135    F[#<probe_fast_fr>]
136    G0 Z-[#<z_probe_stack>]
137  
138    (Call sub "probe_y_minus" to Probe y- side of Workpiece)
139    o<probe_y_minus> call [#1][#3][#4][#8][#9][#10]
140  
141    #<y_minus_probed> = #5062
142  
143    (probed center calulation)
144    #<y_center_probed> = [[#<y_minus_probed> + #<y_plus_probed>] / 2]
145  
146    (calculate Y Width Probed)
147    #<raw_width> = [#<y_minus_probed> - #<y_plus_probed>]
148  
149    (Completed probed width calculations)
150    #<y_probed_width> = [#<raw_width> - #<probe_diameter_offset>]
151  
152    M68 E1 Q[#<y_probed_width>]
153  
154    M68 E11 Q[#<y_center_probed>]
155  
156    G91
157    G0 Z[#<z_probe_stack>]
158    G90
159    G0 X[#<x_center_probed>] Y[#<y_center_probed>]
160  
161    o<120> if [#<x_cal_width> GT #<x_probed_width>]
162      (calculate calibration error and adjust calibration offset)
163      #<x_cal_error> = [[#<x_cal_width> - #<x_probed_width>] / 2]
164      #<new_x_cal_offset> = [#<calibration_offset> - #<x_cal_error>]
165    o<120> else
166      #<x_cal_error> = [[#<x_probed_width> - #<x_cal_width>] / 2]
167      #<new_x_cal_offset> = [#<calibration_offset> + #<x_cal_error>]
168    o<120> endif
169  
170    o<130> if [#<y_cal_width> GT #<y_probed_width>]
171      (calculate calibration error and adjust calibration offset)
172      #<y_cal_error> = [[#<y_cal_width> - #<y_probed_width>] / 2]
173      #<new_y_cal_offset> = [#<calibration_offset> - #<y_cal_error>]
174    o<130> else
175      #<y_cal_error> = [[#<y_probed_width> - #<y_cal_width>] / 2]
176      #<new_y_cal_offset> = [#<calibration_offset> + #<y_cal_error>]
177    o<130> endif
178  
179    #<new_avg_cal_offset> = [[#<new_x_cal_offset> + #<new_y_cal_offset>] / 2]
180  
181    o<140> if [#<sq_cal_axis> EQ 0]
182      M68 E12 Q[ABS[#<new_avg_cal_offset>]]
183    o<140> else if [#<sq_cal_axis> EQ 1]
184      M68 E12 Q[ABS[#<new_x_cal_offset>]]
185    o<140> else
186      M68 E12 Q[ABS[#<new_y_cal_offset>]]
187    o<140> endif
188  
189    #<x_zero> = [#<x_center_probed> + #<workspace_x>]
190  
191    #<y_zero> = [#<y_center_probed> + #<workspace_y>]
192  
193    (probe mode rules for WCO or probe position measuring only)
194    o<150> if [#<probe_mode> EQ 0]
195      (Record XY Zero in selected WCO)
196      G10 L2 P#5220 X[#<x_zero>] Y[#<y_zero>]
197      (Probe Completion Move to Z Clearance Plane, and X Zero, Y Zero)
198      o<probe_cal_square_boss> return
199    o<150> endif
200  
201  o<probe_cal_square_boss> endsub
202  
203  M2 (end program)
204