-
Notifications
You must be signed in to change notification settings - Fork 19
/
SO3_XL_ToolChange_fixedLocation
98 lines (91 loc) · 2.7 KB
/
SO3_XL_ToolChange_fixedLocation
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
;This macro allows you to use a fixed machine location for a tool change/probe. Ideal when you're workpiece surface has been carved away.
; Wait until the planner queue is empty
%wait
; Set user-defined variables
%SAFE_HEIGHT = -5 ;clear everything height (negative number, distance below Z limit)
;Following set probe location
%TOOL_PROBE_X = -30 ;machine coordinates
%TOOL_PROBE_Y = -350 ;machine coordinates
%TOOL_PROBE_Z = -20 ;machine coordinates --> lower this (more negative) to start the probing closer to wasteboard
%PROBE_DISTANCE = 100
%PROBE_FEEDRATE = 75
%RETRACTION_DISTANCE = 10
; Keep a backup of current work position
%X0=posx, Y0=posy, Z0=posz
; Save modal state
; * Work Coordinate System: G54, G55, G56, G57, G58, G59
; * Plane: G17, G18, G19
; * Units: G20, G21
; * Distance Mode: G90, G91
; * Feed Rate Mode: G93, G94
; * Spindle State: M3, M4, M5
; * Coolant State: M7, M8, M9
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant
; Stop spindle
M5
; Absolute positioning
G90
G21 ;Force metric mode
; Go to Safe Z
G53 Z[SAFE_HEIGHT]
; Go to tool probe X,Y
G53 X[TOOL_PROBE_X] Y[TOOL_PROBE_Y]
G53 Z[TOOL_PROBE_Z]
; Wait until the planner queue is empty
%wait
; Pause the program before probing
M0
; Probe toward workpiece with a maximum probe distance
G91 ; Relative positioning
G38.2 Z-[PROBE_DISTANCE] F[PROBE_FEEDRATE]
G0 Z2 ;lift 2mm
G38.2 Z-5 F45 ;Probe Z
G90 ; Absolute positioning
%ORIGINAL_TOOL = posz ;store current work position
; A dwell time of one half second to make sure the planner queue is empty
G4 P0.5
; Retract from the touch plate for tool change
G91 ; Relative positioning
G0 Z[RETRACTION_DISTANCE]
G90
G53 Z[SAFE_HEIGHT]
; Wait until the planner queue is empty
%wait
; Pause the program for a manual tool change
M0
; Wait until the planner queue is empty
%wait
G53 Z[TOOL_PROBE_Z]
; Probe toward workpiece with a maximum probe distance
G91 ; Relative positioning
G38.2 Z-[PROBE_DISTANCE] F[PROBE_FEEDRATE]
G0 Z2 ;lift 2mm
G38.2 Z-25 F45 ;Probe Z
G90 ; Absolute positioning
; A dwell time of one second to make sure the planner queue is empty
G4 P0.25
; Update Z offset for new tool
G10 L20 Z[ORIGINAL_TOOL]
; A dwell time of one second to make sure the planner queue is empty
G4 P0.25
; Retract from the touch plate
G91 ; Relative positioning
G0 Z[RETRACTION_DISTANCE]
G90 ; Absolute positioning
; Raise to tool change Z
G53 Z[SAFE_HEIGHT]
; Wait until the planner queue is empty
%wait
; Pause the program for cleanup (e.g. remove touch plate, wires, etc)
M0
; Go to previous work position
G0 X[X0] Y[Y0]
G0 Z[Z0]
; Restore modal state
[WCS] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]