'Z zeroing macro by Scott Worden - Timber Lake Creations


CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness = GetUserDRO(1151) 'You could put your z-plate thickness here instead.
ProbeFeed = GetUserDRO(1152) 'You could put a probing feedrate here instead.
ZHeight = GetOemDRO(54) 'You could put a Z retract height here.

SetUserLed (1055,1)

Code "G90 F" &ProbeFeed

If GetOemLed (825)=0 Then
Code "G4 P1" 'Time to get to the z-plate.
Code "G31Z-1.5 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 Z" &ZHeight 
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
SetUserLed (1055,0)
Else
Code "(Z-Plate is grounded, check connection and try again)"
SetUserLed (1055,0)
Exit Sub
End If      