Files
probe-basic-sim/configs/probe_basic_lathe/subroutines/tapping.ngc
2025-12-14 18:29:18 +01:00

57 lines
1.3 KiB
Plaintext
Executable File

;tapping
o<tapping> sub
; o<backup_status> call
#<tapping_diam> = #1
#<tapping_z> = #2
#<tapping_ss> = #3
#<tapping_pitch> = #4
#<tapping_tool> = #5
#<tapping_coolant> = #6
#<tapping_rampdistance> = #7
#<starting_Z> = #<_z> (starting Z)
o100 if [#<tapping_tool> NE #<_current_tool>]
(MSG,ERROR : Set tool before use macro)
o100 return [-2] ; indicate failure to epilog
o100 endif
G7 ; diameter mode
G17 ; XY Plane
G21 ; Metric Units
G90 ; Absolute Distance
G91.1 ; but not for arcs
#<speed_calc> = [[1000 * #<tapping_ss>] / [3.1415 * #<tapping_diam>]] ; metric mode RPM
G97 S#<speed_calc> ; Constant RPM mode
G97 S500
M3 ; Start Spindle
G4 P1 ; Wait to reach speed
o110 if [#<tapping_coolant>]
M8
o110 endif
(DEBUG,Tapping dia-#<tapping_diam> depth-#<tapping_z> asked-speed-#<tapping_speed> pitch-#<tapping_pitch> tool-#<tool_number> calculated-rpm-#<speed_calc> start-Z-#<starting_Z>)
#<new_z> = [#<tapping_z> + #<tapping_rampdistance>] ; taking care of spindle ramp distance
G98
G0 X0 ; must drill from the centerline. Tool should be zeroed here
G33.1 Z#<new_z> K#<tapping_pitch>
G80
M5
M9
; o<backup_restore> call ; restore g20/21, g90/g91, feedrate cuter-comp and other using now global _backup_var
o<tapping> endsub
M2
%