ok was a "Little bit" ofline, added some debuging msg boxes, to see what is going on
'simple X-center script
Sub Main()
SetOEMDro(800,0)
'do the X- probe
Message ("probe X- ")
Code "G31 X-100 F150"
While IsMoving()
x = GetOEMDRO(800) 'X actpos
If x <= -100 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe X- canceled , no probe hit!" )
Exit Sub
End If
Wend
'get the exact probepos
ProbeXNeg = GetVar(2000)
MsgBox "X Probe - : " + CStr(ProbeXNeg)
'clear the probe
Code "G91 X2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'do the X+ probe
Message ("probe X+ ")
Code "G31 X200 F150"
While IsMoving()
x = GetOEMDRO(800) 'X actpos
If x >= 200 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe X+ canceled , no probe hit!" )
Exit Sub
End If
Wend
'get the exact probepos
ProbeXPos = GetVar(2000)
MsgBox "X Probe + : " + CStr(ProbeXPos)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
MsgBox "center : " + CStr(middle)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub