-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZzero.sbp
More file actions
226 lines (196 loc) · 9.68 KB
/
Zzero.sbp
File metadata and controls
226 lines (196 loc) · 9.68 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
' The following licensing information must accompany this file at all times.
' ********** Licensing Information ******************************************************
' Copyright 2001 - 2014 ShopBot Tools
' We encourage ShopBot users to modify this part file to suit their own needs and have licensed it
' under the Creative Commons Atribution 3.0 license. This license allows you to copy, distribute,
' or modify the file with certain restrictions. Any other use requires permission from ShopBot Tools.
'
' A simplified explanantion of this license is available at
' http://creativecommons.org/licenses/by/3.0/us/
' and the full legal code can be found at
' http://creativecommons.org/licenses/by/3.0/us/legalcode
' We encourage you to read this legal code before modifying or distributing this file,
' ESPECIALLY sections 5 and 6 that cover warranties and liability.
'
' If you plan on distributing your new version, you must also state in the header of your file that it
' is a modification of a file supplied by Shopbot Tools, supply information on finding the original file,
' and rename the file to make it clear to the user that it is a modified version.
' ********** End Licensing Information **************************************************
'
'****************************************************************************************
'ZZERO.SBP -- Zero Z Axis on Contact with Zeoring Plate
'Copyright 1998-2014. ShopBot Tools, Inc.
'----------------------------------------------------------------------------------------
'*NOTE* This file will always be over-written during software update installations to insure
' it is kept standard and current.
'*NOTE* If you want to make a custom version of this file that is called with the C2 Command
' you should save it with a different name, say "ZZERO_Joes_8_23_08.sbp", then change the
' C2 Command (found in C:\SbParts\Custom\Custom2.sbc to call your file rather than the
' standard file. You may need to update this Custom2.sbc file when you update software.
'----------------------------------------------------------------------------------------
'!!Table Base Coordinates are also Zeroed During Routine
'Variables in this file are read from the my_variables.sbc file in c:\Sbparts\Custom
'Recent Updates by ShopBot:
' 11/15/12 - Routine no longer tries to swap between measurement systems. If Setup (under 'T'ools in ShopBot)
' has configured my_variable.sbc file for inches, ZZERO will expect inches; IF mm then mm; *will attempt to spot error!
' 11/15/12 - Now uses system SafeZ for pull-up (that is set in [VC])
' 8/20/13 - Adds speed downshift for XY to reduce packet size to allow a STOP on plunge
' 3/12/14 - Includes new tests for Prox Switch on Z-axis
' 7/18/14 - Refactored (GAB) for consistency
'**TEST YOUR PLATE BY TAPPING IT AGAINST BIT --> SWITCH INDICATOR SHOULD ACTIVATE ON SCREEN
'Initialize
SA, 'Let's be in Absolute Mode
SF,0 'Turn off limit checking temporarily here
'Confirm Spindles OFF
SO, 1, 0
SO, 2, 0
'Determine whether we are in Preview mode or Move/Cut mode
&modenow = %(22)
IF &modenow = 1 then GoTo CHANGEMODE
'Load variables from my_variables.sbc, process called by Custom Cut 90
C#,90
'This version of XYzero deals with only two possibilities ...
&SW2_SwitchType = %(92) ' If #2 Input is 2, then we have (PRS) normally-closed switches on #2 and #3
' Otherwise, we have a (PRT) with normally-open switches on #3
VN, 0 'Deactivate the limit switch functionality on input #3
'INDIRECTLY - Make sure that the units are those used with the Set-Up Program and expected by my_variables.sbc
&zbot = &my_ZzeroThickness
GOSUB CheckPlateThickness 'No longer trying to adjust for incorrect units; just quit IF plate seems incorrect
'Set thickness and pull-up distance
&zup = %(28)
IF &zup = "" THEN &zup = 0
IF &zup < &zbot THEN &zup = &Zbot * 2 'If pull up not greater than thickness, just double thickness
'Set a value for our first Z move
&big_plunge = %(3) - 50
IF %(25) = 1 THEN &big_plunge = %(3) - 1200
&MoveZ = .125 'For re-positioning after Z prox touch-off
IF %(25) = 1 THEN &MoveZ = 3
'Check to see if we should move to a zeroing location
IF &my_ZzeroStartX <> no THEN GOSUB STARTMOVE
'Save current speeds and set zeroing speed
&start_Zmove_Speed = %(73)
&start_XYmove_Speed = %(71)
&new_Zmove_Speed = .25
&new_XYmove_Speed = .25
IF %(25) = 1 THEN &new_Zmove_Speed = 6
IF %(25) = 1 THEN &new_XYmove_Speed = 6
'----------------------------------------------------------------Zeroing PROGRAM
FIRST PLUNGE:
'Make First Plunge... the following line will display first and wait for key stroke
' *** Hit ENTER When above plate and Ready to Zero ***
PAUSE
GOSUB TEST_CLEAR 'Test to make sure the plate is not already contacting or probe hooked up
'Now set-up the contact switch action ...
VS, &new_XYmove_Speed, (&new_Zmove_Speed * 2 ) 'Set XY speed to reduce packet size and distance to STOP
ON INP(&my_ZzeroInput,1) GOTO CONTACT1 'this is where we'll go on contact with plate
MZ, &big_plunge 'Start continuous plunge ... while looking for contact to occur
'If we don't contact anything for some reason we end up here
ON INP(&my_ZzeroInput,1) 'Turn off switch check
VS, &start_XYmove_Speed, &start_Zmove_Speed 'Reset Speeds because zeroing failed
'Zeroing Failed!
PAUSE
END 'This END statement causes the program to end here IF no contact
SECOND PLUNGE:
'Make a Second Slower Plunge to get it really accurate
GOSUB TEST_CLEAR 'Check for clear again
'Set-up the second contact switch action ...
VS, , &new_Zmove_Speed
&little_plunge = %(3) - (&Zbot + &zup)
ON INP(&my_ZzeroInput,1) GOTO CONTACT2 'this is where we'll go on contact with plate
MZ, &little_plunge 'Start continuous plunge ... looking for second contact to occur
'If we don't contact anything for some reason we end up here
ON INP(&my_ZzeroInput,1) 'Turn off switch check
VS, &start_XYmove_Speed, &start_Zmove_Speed 'Reset Speeds because zeroing failed
'Zeroing Failed!
PAUSE
END 'This END statement causes the program to end here IF no contact
'================================================================Subroutines
CONTACT1:
'This is our subroutine for action on hitting the plate the first time
&first_Z_touch = %(3) 'Just a diagnostic variable; touch location can be checked with [UL]
VA,,,&zbot,,,,,0 'Set the approximate Z location based on thickness
PAUSE 1
JZ, &zup 'Pull-up SLIGHTLY ...
'Now We're Ready to Make Slow Move for Accurate Reading
PAUSE 1
GOTO SECOND PLUNGE
CONTACT2:
'This is our subroutine for action on hitting the plate the second time
&second_Z_touch = %(3) 'Just a diagnostic variable that can be checked with [UL]
VA,,,&zbot,,,,,0 'Set final Z location AND Zero Table Base Coordinate
PAUSE 1
VS, &start_XYmove_Speed, &start_Zmove_Speed
JZ, &zup 'Pull-up to safe height
IF &my_hasZProx = 1 THEN GOTO Has_ZProx
'***ZEROED! REMEMBER TO REMOVE ALLIGATOR CLIP, AND PUT AWAY PLATE!***
PAUSE
END '*** NORMAL END HERE
Has_ZProx:
'Check status of current inputs to know if we have to clear switches
IF &SW2_SwitchType = 2 THEN GOTO Check_PRS
Check_PRT:
&TrgtHIT = 1
&Ztrgt = 3
GoTo Status_Checked
Check_PRS:
&TrgtHIT = 0
&Ztrgt = 5
Status_Checked:
&ZProx = &Ztrgt + 50
IF %(&ZProx) = &TrgtHIT THEN GOTO Getoffprox
ON INP(&Ztrgt,&TrgtHIT) GOTO PROX_CONTACT
MZ, -1 * &big_plunge
MSGBOX (Error reaching Z prox switch!, OKONLY, PROX SWITCH ERROR)
END
PROX_CONTACT:
ON INP(&Ztrgt,&TrgtHIT)
&my_XYzeroOffsetZ = %(3)
MZ, %(3)- &MoveZ
SHELL, "C:\SbParts\Custom\MyVars.exe [&]my_XYzeroOffsetZ = &my_XYzeroOffsetZ"
'Z Prox measured ...
PAUSE 1
'***ZEROED! REMEMBER TO REMOVE ALLIGATOR CLIP, AND PUT AWAY PLATE!***
PAUSE
END
Getoffprox:
'Use Arrow Keys to move Off of Prox Switch (ESC when Clear)
PAUSE
SK
GOTO Status_Checked 'Go Back to Re-check Status
TEST_CLEAR:
&cleared = &my_ZzeroInput + 50
IF %(&cleared) = 1 THEN PAUSE 3
IF %(&cleared) = 1 THEN GOTO NO_CLEAR
RETURN
NO_CLEAR:
'Reset the orginal Z speed
VS, &start_XYmove_Speed, &start_Zmove_Speed
'Z-contact did not clear. Check the location of alligator clip and plate. If cutting metal, try placing a sheet of paper between the material and the plate. Exiting Zzero!
PAUSE
END
STARTMOVE:
IF &AllReadyThere = 1 THEN RETURN 'This variable produced in MTC routine if user offset used
'Hit OK to move to your preferred starting point to start the routine.
PAUSE
IF %(3) < &zup THEN JZ, &zup
J2, &my_ZzeroStartX, &my_ZzeroStartY
RETURN
CheckPlateThickness:
IF %(25) = 1 THEN GOTO MT
IF %(25) = 0 THEN GOTO IT
'If the units are metric: check whether the plate thickness looks too thin
MT:
IF &Zbot < 1 THEN GOTO PlateIncorrect
RETURN
'If the units are in inches: check whether the plate thickness is too thick
IT:
IF &Zbot > 2 THEN GOTO PlateIncorrect
RETURN
PlateIncorrect:
'Plate thickness may be incorrect due to selected units. Use Shopbot Setup [TS] in the tools menu to correct plate thickness or units for zeroing.
PAUSE
END
CHANGEMODE:
'Tool won't home in Preview Mode. Quit and change Move/Cut mode ...
PAUSE
END