Code:
(Probe Left/Back set as program zero, move to Right/Front, set program zero to half/current position)
GLOBAL REAL #XWidth
GLOBAL REAL #YWidth
GLOBAL REAL #XCenter
GLOBAL REAL #YCenter
GLOBAL STRING #Message
#XWidth = 0
#YWidth = 0
#XCenter = 0
#YCenter = 0
(Switch to imperial)
G20
M06 T100
(Go to Program Z0)
G01Z0F5
(Go to Program X0Y0)
G01Y0X0F12
(search z for .5" at feed rate of 1) input line 7
G31 Z-.5 I7 S1 E0 F1
(Program.Z is ?)
(set Program Z to 0, no compensation since its the bottom of the probe, not the middle)
G92 Z0
(Dwell .1 second)
G04 P.1
(Move to Program.Z.1 above part)
G01Z.1F20
(Move to Program.X-.3, since origin is rough)
G01X-.3F20
(Move to Program.Z-.03 below part , maybe use ball size + ?)
G01Z-.07F20
(fast search X for .5" at feed rate of 6) input line 7
G31 X.5 I7 S1 E0 F5
(quickly step back a tad)
G01 X#Program.X - .1F20
(slow search X for .5" at feed rate of 1) input line 7
G31 X.15 I7 S1 E0 F1
(set Program X to 0, with compensation)
G92 X-#Probe1SizeL/2
(move away from part in X)
G01 X-.2F20
(Move to Program.Y, still below part in Z)
G01 Y.2F20
(move into part on X, z is below top)
G01 X.1F20
(fast search Y for -1" at feed rate of 6 input line 7 )
G31 Y-1 I7 S1 E0 F6
(move back away from part)
G01 Y#Program.Y + .1 F12
(slow search Y for .15" at feed rate of 1 input line 7 )
G31 Y-.15 I7 S1 E0 F1
(set Program Y to 0, with probe ball compensation)
G92 Y#Probe1SizeL/2
(move back away from part)
G01 Y#Program.Y + .1 F12
(move above part)
G01Z.2F20
(move over RoughX,RoughY guessed size of box at F5)
G01 X#RoughX Y-#RoughY/2 F40
(move down to below edge of part)
G01Z-.07F20
(fast search for X2, search for -1 in X)
G31 X-1 I7 S1 E0 F6
(move out a tad)
G01 X#Program.X + .1 F12
(slow search)
G31 X-.2 I7 S1 E0 F1
( size of object in X , these fail when not in simulator mode)
#XWidth = #Program.X - #Probe1SizeL/2
#XCenter = #XWidth/2
(move away from x in positive direction)
G01 X#Program.X + .2 F12
( this moves XY and Z for some reason in simulator? )
G01Z.2F20
(Move to Program.Y-.4, still below part in Z)
G01 X#RoughX/2 Y-#RoughY F40
(move into part on X, z is below top)
G01Z-.07F12
(search Y for 1" at feed rate of 6 input line 7)
G31 Y.1 I7 S1 E0 F6
G01 Y#Program.Y-.1 F12
(search Y for 1" at feed rate of 1 input line 7)
G31 Y.1 I7 S1 E0 F1
( size of object in Y - #Probe1SizeL/2)
#YWidth = #Program.Y + #Probe1SizeL/2
(away from part)
G01 Y#Program.Y - .1F12
#YCenter = #YWidth/2
(move z above part)
G01Z.2F12
G01 X#XCenter Y#YCenter F40
(update screen)
#XWidth1 = #XWidth
#YWidth1 = #YWidth