'Check oemdro# And oemled#

'Code"1003"

SetOEMDRO(800,0.5)
SetOEMDRO(801,0.5)
SetOEMDRO(802,2.0)

Sleep(100)

CurrentFeed = GetOemDRO(818) 	'Get the current feedrate.
PlateThickness =1.250		'Set gauge thickness
ProbeFeed = 20			'Set feedrate during probing

Code "G90 F" &ProbeFeed		'Set to Absolute Distance mode

'X Axis Home

If GetOemLed (825)=0 Then	'Check LED to see probe is ready
Code "G4 P1"                	'Time to get to the X-plate
Code "G31X4 F" &ProbeFeed	'Start X probe routine
While IsMoving()		'Probe moving X axis
Sleep(100)
Wend				'End of move
Code "G4 P0.25"			'Pause
XProbePos = GetVar(2000)	'Get position of probe
Code "G0 X" &XProbePos
While IsMoving ()		'Axis moving 
Wend				'End of move
Call SetDro (0, PlateThickness)	'?
SetOEMDRO(800,0)		'Set X DRO for correct direction
Code "G4 P0.5" 			'Pause for Dro to update.
Code "G0 X-1.065"                 'Change the X retract distance here
Code "(X axis is now homed)"
'Code "F" &CurrentFeed		'Store current feedrate to F
Code "G54 P2"
End If

'Y Axis Home
Code "G90 F" &ProbeFeed		'Set to Absolute Distance mode

Sleep(1000) 			'Sleep to finish X routine

If GetOemLed (825)=0 Then	'Check LED to see probe is ready
'Code "G4 P1"                 	'Time to get to the  Y-plate
Code "G31Y4 F" &ProbeFeed	'Start Y probe routine
While IsMoving()		'Probe moving Y axis
Wend				'End of move	
Code "G4 P0.25"			'Pause	
YProbePos = GetVar(2001)	'Get position of probe
Code "G0 Y" &YProbePos
While IsMoving ()
Wend
Call SetDro (1, PlateThickness)
SetOEMDRO(801,0)
Code "G4 P0.5" 			'Pause for Dro to update.
Code "G0 Y-6.820 F20" 		'Change the Y retract distance here
Code "(Axis is now homed)"
'Code "F" &CurrentFeed		'Store current feedrate to F
Code "G54 P2"			'Pause to let code finish

Sleep(6000)			'Sleep to let program catchup
SetOEMDRO(800,8.8641)		'Set X work offset for Spoons
SetOEMDRO(802,2)		'Set Z work offset for All
SetOEMDRO(801,0.0000)		'Set Y work offset for Spoons

Else
Code "(Plate is grounded, check connection and try again)"
Exit Sub

End If 

Code "X0 Y0"  			 'Ready to make spoons 