Heres a Bit of Code from the main Button.
'Pull in common Information so we know which process we need
ProbeFeed = GetOEMDRO(1053) 'Get the probe feedrate.
TipD = GetOEMDRO(1050) 'Get the Probe Tip O.D.
ProgCNC = GetOEMDRO(1062) 'Which Program to run
XStart = GetOEMDRO(800) ' X DRO
YStart = GetOEMDRO(801) ' Y DRO
ZSafe = GetOEMDRO(1306) ' Z Safe Distance
ZProbe = GetOEMDRO(1307) ' Z Probe Depth
XDist = GetOEMDRO(1304)
YDist = GetOEMDRO(1305)
SetUserLabel(34,"")
Call SetVar(2000,0)
Msg = "YStart = " & YStart
MsgBox Msg, 64 ,"Step"
Msg = "XStart = " & XStart
MsgBox Msg, 64 ,"Step"
Select Case ProgCNC
Case 1
Msg= "Probing Round Centre"
MsgBox Msg, 64 ,"Probe Information"
If GetOEMDRO(1304)=0 Then 'First If Then
Msg= "No Set User Bar Size to Probe - Terminating"
MsgBox Msg, 64 ,"Error - Bar Size Zero"
End
Else 'First Else
'Next Check and Program
Code "G91 F" & ProbeFeed
' This is the Probe hit LED and Second If Then
If GetOEMLED (825)=0 Then
' add outside moves
PrepMoveY = (YDist/3) - (YDist*0.05) + (TipD/2)
Do
Code "G90 G00 Z" & ZSafe
Code "G91 G00 Y" & PrepMoveY
Code "G90 G31 Z-" & ZProbe
While IsMoving()
Sleep(100)
Wend
YPosZVal=GetVar(2002)
Code "G90 G00 Z" & ZSafe
Code "G90 G00 Y" & YStart
Msg = "Should Be at Y Start"
MsgBox Msg, 64 ,"Step"
Code "G91 G00 Y-" & PrepMoveY
Code "G90 G31 Z-" & ZProbe
While IsMoving()
Sleep(100)
Wend
YNegZVal=GetVar(2002)
Code "G90 G00 Z" & ZSafe
Code "G90 G00 Y" & YStart
' Do the Math
TrigB = PrepMoveY
If Abs(YPosZVal) > Abs(YNegZVal) Then 'Third If Then
CBar = Abs(YPosZVal) - Abs(YNegZVal)
FMove = CBar/2
Doy = 1
Else 'Third Else
CBar = Abs(YNegZVal) - Abs(YPosZVal)
FMove = CBar/2
Doy = 2
End If 'Third End If
'Do the Move or Exit
If CBar <= 0.002 Then 'Fourth If Then
Msg= "Z Probe difference <= 0.002 - To Small Exiting"
MsgBox Msg, 64 ,"Probe Information"
Exit Do
Else 'Fourth Else
If Doy = 1 Then 'Fifth If Then
ZFin = Abs(YNegZVal) + FMove
Code "G91 G01 Y" & PrepMoveY
Code "G90 G31 Z-" & ZFin
While Ismoving()
Sleep(100)
Wend
Code "G91 G31 Y-" & PrepMoveY
While IsMoving()
Sleep(100)
Wend
YProbeVal = GetVar(2001)
Code "G90 G00 Z" & ZSafe
Code "G00 Y" & YProbeVal
Code "G91 Y-" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
Call SetOEMDRO(802, YStart)
Sleep(250)
Code "G90 F" & ProbeFeed
Else ' Fifth Else
ZFin = Abs(YPosZVal) + FMove
Code "G91 G01 Y-" & PrepMoveY
Code "G90 G31 Z-" & ZFin
While Ismoving()
Sleep(100)
Wend
Code "G91 G31 Y" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
YProbeVal = GetVar(2001)
Code "G90 G00 Z" & ZSafe
Code "G00 Y-" & Abs(YProbeVal)
Code "G91 Y" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
Call SetOEMDRO(801, YStart)
Sleep(250)
Code "G90 F" & ProbeFeed
End If 'Fifth End If
End If ' Fourth End If
Loop
Else ' Second Else
MsgBox("probe is touching")
End If 'Second End If
End If 'First End If
If GetOEMLED(1006) = True Then ' Set to Zero
Msg = "Axis set to Zero for Centre of Hole"
MsgBox Msg,64,"Successful Probe to Zero"
Call SetOEMDRO(801,0)
Call SetOEMDRO(800,0)
Sleep(250)
Else
SetUserLabel(34,"" )
End If
Case 2
Msg= "Probing Round Parallel"
MsgBox Msg, 64 ,"Probe Information"
Case 3
Msg= "Probing Round Parallel while Centring"
MsgBox Msg, 64 ,"Probe Information"
Case 4
Msg= "Probing for The End Of a Round Bar"
MsgBox Msg, 64 ,"Probe Information"
'Start the Checks
'Checking for X Data
If GetOEMDRO(1304)=0 Then
Msg= "No Set User Bar Size to Probe - Terminating"
MsgBox Msg, 64 ,"Error - Bar Size Zero"
End
Else
'Next Check and Program
Code "G91 F" & ProbeFeed
If GetOEMLED (825)=0 Then 'This is the Probe hit LED
' add outside moves
PrepMoveX = XDist + (TipD*2)
Code "G90 G00 Z" & ZSafe
Code "G91 G00 X" & PrepMoveX
Code "G90 G31 Z -" & ZProbe
While IsMoving()
Sleep(100)
Wend
Code "G04 P250"
If GetOEMLED (825) = True Then
Code "G90 G00 Z" & ZSafe
Msg= "Probe hit prior to Z depth " & ZProbe & ". "
Msg= Msg & " X Block dimensions are from Probe to the end of the Bar"
MsgBox Msg, 16 ,"Program Has Ended"
End
Else
Code "G91 G31 X-" & XDist
While IsMoving()
Sleep(100)
Wend
Code"G04 P250"
XProbePos = GetVar(2000)
Msg= "Probed Value = " & XProbePos
MsgBox Msg, 64 ,"XProbe Value "
XCentre = XProbePos - (TipD / 2)
Msg= "Centre Vale = " & XCentre
MsgBox Msg, 64 ,"XCentre Value"
Code " G91 G01 X0.1"
Code "G90 G00 Z" & ZSafe
'Reset to Zero or Pass the Value
If GetOEMLED(1006) = True Then
Code "G90 G00 X" & XCentre
While IsMoving()
Sleep(100)
Wend
Call SetOEMDRO(801,0)
Call SetOEMDRO(800,0)
Sleep(250)
Else
Code"G90 G00 X" & XStart
While IsMoving()
Sleep(100)
Wend
SetUserLabel(34,"Edge of the Round Bar is " & XCentre)
End If
End If
Else
MsgBox("probe is touching")
End If
End If
Case 8
Msg= "Probing the Centre of a Rectangle Bar"
MsgBox Msg, 64 ,"Probe Information"
Case 16
Msg= "Probing Rectangle Bar Parallel"
MsgBox Msg, 64 ,"Probe Information"
Case 24
Msg= "Probing Rectangle Bar Parallel and Centre"
MsgBox Msg, 64 ,"Probe Information"
Case 32
Msg= "Probing for the End of a Rectangular Bar"
MsgBox Msg, 64 ,"Probe Information"
Case 64
Msg= "X Axis Probe of Vise Jaw for Square"
MsgBox Msg, 64 ,"Probe Information"
Case 128
Msg= "Y Axis Probe of Vise for Square"
MsgBox Msg, 64 ,"Probe Information"
Case Else
Msg= "Nothing selected to Probe"
MsgBox Msg, 64 ,"Probe Information"
End Select
End