Just tidied up the macro a wee bit and added comments so I can follow in a years time
Hopefully it will work tomorrow and I have not made any mistakes as my VB is, as you can see, basic but hopefully functional
Have also altered my screenset to add a few dros such as Probe Speed.
PierceHeight = GetUserDRO (1555) 'Screen DRO to enter Pierce Height required
ZOffset = GetUserDRO(1556) 'Screen DRO to enter Z offset of switch from torch
XOffset = GetUserDRO(1557) 'Screen DRO to enter X offset of switch from torch
YOffset = GetUserDRO(1558) 'Screen DRO to enter y offset of switch from torch
ProbeSpeed = GetUserDRO(1559) 'Screen DRO to enter speed of G31 probe
ZHeight = GetOemDRO(85) 'Machine coordinates DRO for Z Axis
Sleep 50
SetHeight = (ZOffset - PierceHeight ) * -1 'Calculate distance required to move Z back for pierce height
If ZHeight > -30 Then 'Check to see if Z Axis is less than 30mm from Z Max
Code "G91G0Z-30" 'If it is then rapid to 30mm below Z Max
End If
Code "G91G0Z20" 'Incrementally move Z to provide clearance for probe
While IsMoving()
Wend
Code"G91G0X" & XOffset & "Y" & YOffset 'Incrementally move X and Y to offset for probe distance from torch
While IsMoving()
Wend
SetOutBit(90,10) 'Set output to air solenoid valve to extend probe
sleep 100
Code "G31Z-100F" & ProbeSpeed 'Command probe routine at speed set by ProbeSpeed DRO
While IsMoving()
Wend
ResetOutBit(90,10) 'Reset output to air solenoid valve to retract probe
Code"G91G0X" & XOffset*-1 & "Y" & YOffset*-1 & "Z"& SetHeight 'Incremental move to set torch back to original position on X,Y and Pierce Height on Z
While IsMoving()
Wend
Code "G92Z" & PierceHeight 'Set Z DRO to Pierce Height
Code"G90" 'Set back to absolute mode