CurrentFeed = GetOEMDRO(818) 'Get the current feedrate to return to later
PlateThickness = GetUserDRO(1002) 'Z-plate thickness DRO
tool = GetCurrentTool
PFR = GetUserDRO(1118)
'######### Check Tool Offsets########
If GetOEMLED (28) <> 0 Then 'Check to see if Tool Offsets are on
DoOEMButton (136) 'Remove tool Offsets
Code "(Tool Offsets turned off when probing)" 'this goes in the status bar if aplicable
Else

End If
'######## Check Probe#########
If GetOEMLED (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Else
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P0.025" ' one second delay
Code "G31 Z-1.0 F" &PFR  'Z goes down a max of 1.0 at User feed rate
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
Code "G43 H" &tool
While IsMoving ()
Wend
Call SetDRO (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z1.0" 'retract Z to 1.0 inch
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
DoOEMButton (136) 'Remove tool Offsets

End If 

Exit Sub