Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: needleworks on October 03, 2018, 05:00:54 AM
-
Hi guys, another newbie request again.
Can anyone give me a script that will probe, and find the centre in the X axis only ? Similarly I would like to be able to do the same in the Y axis.
I am using Hoss's probing screenset at the moment and although I can probe to find the centre of a circle, I can't probe to find the centre of a single axis.
Any help would be gratefully received ;)
Thanks in advance guys.
-
Inside, or Outside, and how far do you need the movement to be?
-
Hi Gerry, inside measurements, no more than 100mm on the X, and probably the same on the Y. Obviously I am working in metric.
-
here a simple sxript for X
'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
ProbeX- = GetVar(2000)
'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
ProbeX+ = GetVar(2000)
'goto the center
middle = ProbeX- + ((ProbeX+ - ProbeX-)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
be careful, not tested, just written down.
z-axis has to be in probe hight.
-
here a simple sxript for X
'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
ProbeX- = GetVar(2000)
'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
ProbeX+ = GetVar(2000)
'goto the center
middle = ProbeX- + ((ProbeX+ - ProbeX-)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
be careful, not tested, just written down.
z-axis has to be in probe hight.
Many thanks Gerry, very much appreciated.
-
Oops, I'm giving credit to the wrong person here :o Many thanks also to TPS, much appreciated mate.
-
Just tested the above script and I am getting "Scripter Compile Error" it could well be something that I have done wrong, but am unsure ?
-
'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)
'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)
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
-
'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)
'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)
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
Now we are getting somewhere, only problem now is that, when the probe hits the first edge on X- I get a "Probe Ignore, activated at call for probe" error
Can't thank you enough for your help so far mate.
-
That's a Mach3 internal message that the probe input is active when the probe move is called.
Make sure your probe is wired and working properly. Look at the LED on the diagnostics page. The LED should be off, and come on when the probe is triggered.
-
ok try this, sorry i can't test the code for the Moment.
'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)
'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)
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
-
That's a Mach3 internal message that the probe input is active when the probe move is called.
Make sure your probe is wired and working properly. Look at the LED on the diagnostics page. The LED should be off, and come on when the probe is triggered.
Everything is good with the probe Gerry, it works great on all other probing routines.
-
ok try this, sorry i can't test the code for the Moment.
'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)
'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)
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
We are certainly getting closer my friend, It now probes X- no problem, touches off, then starts to go X+, as soon as it touches the X+ I get the warning again.
Sorry for being a pain in the a** guys.
-
no idea why this warning Comes up, but try this code:
'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)
'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)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
-
no idea why this warning Comes up, but try this code:
'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)
'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)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
SetOEMDro(800,0)
End Sub
Ok buddy, this is what I am getting now.
Start probing routine and the first move is X- After touching off on X- , it starts to go X+ , and after touching off, it now retracts 2mm, and the X dro now updates to read 0.000
I am completely baffled by all this.
-
'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)
'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)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
-
'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)
'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)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 Y" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
Still the same I'm afraid ! On one attempt it done the X- no problem and then when it touched off on X+ it backed off 2mm, moved Y+ 2mm and the dro then updated to X 0.000 Y2.000
-
Are you using a parallel port, or a motion controller? Many motion controllers don't work properly with the GetVAR commands. Especially the Chinese controllers.
-
I'm using a genuine UC300 USB controller, and as I said before, every other probing routine works perfectly, in both Mach3 and UCCNC, it's just this "finding the centre in X" move that's got me beat !
-
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
-
Once again mate, many thanks for the time you are taking to help me out here :)
Gave this a try this morning and we are certainly getting somewhere. I am probing between two edges that I know to be roughly 40mm apart.
I place the probe (deliberately) off centre in the space and click on "Probe" The probe starts to move X- and stops when it touches the edge and I now get this message
(http://i1197.photobucket.com/albums/aa433/g4fmc/11_1.jpg)
I click "OK" again and the probe starts to move X+, after touching the opposite edge, it stops and I get this message
(http://i1197.photobucket.com/albums/aa433/g4fmc/22.jpg)
I click "OK" once more and it then backs off a tiny amount and I get this message
(http://i1197.photobucket.com/albums/aa433/g4fmc/33.jpg)
Clicking "OK" once more will then return the probe to the centre of the part and the X dro will update to 0.000, so it is in fact now working. I just don't understand the third message that I get with the tiny number !
-
the third number is the calculated Center of the two Pobepositions:
Center = ProbeXNeg + ((ProbeXPos - ProbeXNeg) / 2)
-
the third number is the calculated Center of the two Pobepositions:
Center = ProbeXNeg + ((ProbeXPos - ProbeXNeg) / 2)
Ahh, I see. Looks like it is giving the centre of the tiny amount that it backs off, after probing X+
-
here is a Version with a small delay after the probes, maybe it is more acurate
'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
Sleep(200)
'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
Sleep(200)
'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)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
-
here is a Version with a small delay after the probes, maybe it is more acurate
'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
Sleep(200)
'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
Sleep(200)
'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)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
Success !!! That seems to have got it my friend. It is now working perfectly (apart from having to click on the "OK" buttons) I am assuming that the debugging can be removed.
Also, while I am at it, could a Y centre script be done by replacing all instances of X- X+ with Y- Y+ ?
Thank you so much for all your help, much appreciated.
-
here we have the X-Center without the debug Windows
'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
Sleep(200)
'get the exact probepos
ProbeXNeg = GetVar(2000)
'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
Sleep(200)
'get the exact probepos
ProbeXPos = GetVar(2000)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
and the y-Center
'simple Y-center script
Sub Main()
SetOEMDro(801,0)
'do the Y- probe
Message ("probe Y- ")
Code "G31 Y-100 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y <= -100 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y- canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYNeg = GetVar(2001)
'clear the probe
Code "G91 Y2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'do the Y+ probe
Message ("probe Y+ ")
Code "G31 Y200 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y >= 200 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y+ canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYPos = GetVar(2001)
'clear the probe
Code "G91 Y-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeYNeg + ((ProbeYPos - ProbeYNeg)/2)
Code "G90 G01 Y" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(801,0)
End Sub
hope i did everthing right
-
here we have the X-Center without the debug Windows
'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
Sleep(200)
'get the exact probepos
ProbeXNeg = GetVar(2000)
'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
Sleep(200)
'get the exact probepos
ProbeXPos = GetVar(2000)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
and the y-Center
'simple Y-center script
Sub Main()
SetOEMDro(801,0)
'do the Y- probe
Message ("probe Y- ")
Code "G31 Y-100 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y <= -100 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y- canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYNeg = GetVar(2001)
'clear the probe
Code "G91 Y2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'do the Y+ probe
Message ("probe Y+ ")
Code "G31 Y200 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y >= 200 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y+ canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYPos = GetVar(2001)
'clear the probe
Code "G91 Y-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeYNeg + ((ProbeYPos - ProbeYNeg)/2)
Code "G90 G01 Y" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(801,0)
End Sub
hope i did everthing right
Thank you again for all your help my friend. It will be later tonight before I can try it but I will let you know how it goes.
-
here we have the X-Center without the debug Windows
'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
Sleep(200)
'get the exact probepos
ProbeXNeg = GetVar(2000)
'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
Sleep(200)
'get the exact probepos
ProbeXPos = GetVar(2000)
'clear the probe
Code "G91 X-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeXNeg + ((ProbeXPos - ProbeXNeg)/2)
Code "G90 G01 X" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(800,0)
End Sub
and the y-Center
'simple Y-center script
Sub Main()
SetOEMDro(801,0)
'do the Y- probe
Message ("probe Y- ")
Code "G31 Y-100 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y <= -100 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y- canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYNeg = GetVar(2001)
'clear the probe
Code "G91 Y2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'do the Y+ probe
Message ("probe Y+ ")
Code "G31 Y200 F150"
While IsMoving()
y = GetOEMDRO(801) 'Y actpos
If y >= 200 Then
DoOEMButton(1003) 'Stop too far no probe hit
MsgBox ("Probe Y+ canceled , no probe hit!" )
Exit Sub
End If
Wend
Sleep(200)
'get the exact probepos
ProbeYPos = GetVar(2001)
'clear the probe
Code "G91 Y-2 F150"
While IsMoving()
Sleep(10)
Wend
Code "G90"
'goto the center
middle = ProbeYNeg + ((ProbeYPos - ProbeYNeg)/2)
Code "G90 G01 Y" + CStr(middle)
While IsMoving()
Sleep(10)
Wend
SetOEMDro(801,0)
End Sub
hope i did everthing right
Thank you again for all your help my friend. It will be later tonight before I can try it but I will let you know how it goes.
Just tried the codes you provided and they are working perfectly. Once again, many thanks for helping me out with this, you are indeed a top man.