% (UBACKCUT OPERATION SEQUENCE) G21 (Set units to mm) G17 (Select XY plane) G90 (Absolute programming) (Define parameters) #SPINDLE_SPEED = 1000 (Spindle speed in RPM) #COOLANT_WAIT = 2 (Coolant wait time in seconds) #Z_SAFE = 1 (Safe height) #FL = 17 (Feed length) #SPOT_DEPTH = 10 (Spotface depth) #HOLE_DEPTH = 20 (Hole depth) #RAPID_FEED = 3000 (Rapid feed rate) #MACHINE_FEED = 200 (Machine feed rate) #ENGAGE_FEED = 80 (Feed rate for controlled moves) (Start Spindle) M3 S#SPINDLE_SPEED G4 P#COOLANT_WAIT (Wait for spindle to stabilize) (Step 1: Initial Position A - Tool above workpiece) G0 Z#Z_SAFE (Step 2: Position A - Coolant ON, insert retracts) M8 (Coolant ON) G4 P#COOLANT_WAIT (Step 3: Moving to Position B – With Rapid Feed) G0 Z[#HOLE_DEPTH + #FL] F#RAPID_FEED (Rapid move to pilot hole depth) (Step 4: Position B - Coolant OFF, insert retracts) M9 (Coolant OFF) G4 P#COOLANT_WAIT (Step 5: Moving to Position C - Below the workpiece) G1 Z[#HOLE_DEPTH + #Z_SAFE] F#ENGAGE_FEED (Controlled move to Position C) (Step 6: Moving to Position D - Insert touches workpiece, Coolant ON) M8 G1 Z[#HOLE_DEPTH] F#ENGAGE_FEED (Controlled approach to workpiece) (Step 7: Position E - Machining spotface) G1 Z[#HOLE_DEPTH - #SPOT_DEPTH] F#MACHINE_FEED (Step 8: Moving back to Safe Position B - Coolant OFF) M9 G0 Z[#HOLE_DEPTH + #FL] F#RAPID_FEED (Step 9: Position B - Coolant ON, insert retracts) M8 G4 P#COOLANT_WAIT (Step 10: Moving to Position A With Rapid Feed) G0 Z#Z_SAFE F#RAPID_FEED (Rapid retract to safe height) (End Spindle and program) M5 (Spindle OFF) M9 (Coolant OFF) G4 P#COOLANT_WAIT M30 (End of program) %