Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: needleworks on October 03, 2018, 05:00:54 AM

Title: VB Script
Post 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.
Title: Re: VB Script
Post by: ger21 on October 03, 2018, 08:07:00 AM
Inside, or Outside, and how far do you need the movement to be?
Title: Re: VB Script
Post by: needleworks on October 03, 2018, 09:24:21 AM
Hi Gerry, inside measurements, no more than 100mm on the X, and probably the same on the Y. Obviously I am working in metric.
Title: Re: VB Script
Post by: TPS on October 04, 2018, 03:04:36 AM
here a simple sxript for X

Code: [Select]
'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.

Title: Re: VB Script
Post by: needleworks on October 04, 2018, 03:10:22 AM
here a simple sxript for X

Code: [Select]
'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.
Title: Re: VB Script
Post by: needleworks on October 05, 2018, 08:03:19 AM
Oops, I'm giving credit to the wrong person here :o Many thanks also to TPS, much appreciated mate.
Title: Re: VB Script
Post by: needleworks on October 07, 2018, 08:15:27 AM
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 ?
Title: Re: VB Script
Post by: TPS on October 07, 2018, 08:18:56 AM
Code: [Select]

'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


Title: Re: VB Script
Post by: needleworks on October 07, 2018, 08:48:09 AM
Code: [Select]

'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.
Title: Re: VB Script
Post by: ger21 on October 07, 2018, 10:06:30 AM
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.
Title: Re: VB Script
Post by: TPS on October 07, 2018, 10:28:32 AM
ok try this, sorry i can't test the code for the Moment.

Code: [Select]
'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


Title: Re: VB Script
Post by: needleworks on October 07, 2018, 12:57:12 PM
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.
Title: Re: VB Script
Post by: needleworks on October 07, 2018, 01:01:17 PM
ok try this, sorry i can't test the code for the Moment.

Code: [Select]
'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.
Title: Re: VB Script
Post by: TPS on October 07, 2018, 01:47:10 PM
no idea why this warning Comes up, but try this code:

Code: [Select]
'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


Title: Re: VB Script
Post by: needleworks on October 07, 2018, 03:26:46 PM
no idea why this warning Comes up, but try this code:

Code: [Select]
'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.
Title: Re: VB Script
Post by: TPS on October 08, 2018, 01:00:03 AM
Code: [Select]
'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


Title: Re: VB Script
Post by: needleworks on October 08, 2018, 03:35:43 AM
Code: [Select]
'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
Title: Re: VB Script
Post by: ger21 on October 08, 2018, 06:55:46 AM
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.
Title: Re: VB Script
Post by: needleworks on October 08, 2018, 08:49:14 AM
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 !
Title: Re: VB Script
Post by: TPS on October 09, 2018, 05:21:32 PM
ok was a "Little bit" ofline, added some debuging msg boxes, to see what is going on


Code: [Select]
'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




Title: Re: VB Script
Post by: needleworks on October 10, 2018, 03:45:52 AM
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 !

Title: Re: VB Script
Post by: TPS on October 10, 2018, 04:48:05 AM
the third number is the calculated Center of the two Pobepositions:


Center = ProbeXNeg + ((ProbeXPos - ProbeXNeg) / 2)







Title: Re: VB Script
Post by: needleworks on October 10, 2018, 06:39:45 AM
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+
Title: Re: VB Script
Post by: TPS on October 10, 2018, 07:00:12 AM
here is a Version with a small delay after the probes, maybe it is more acurate

Code: [Select]
'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

Title: Re: VB Script
Post by: needleworks on October 10, 2018, 12:04:14 PM
here is a Version with a small delay after the probes, maybe it is more acurate

Code: [Select]
'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.
Title: Re: VB Script
Post by: TPS on October 11, 2018, 02:29:46 AM
here we have the X-Center without the debug Windows
Code: [Select]
'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

Code: [Select]
'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


 
Title: Re: VB Script
Post by: needleworks on October 11, 2018, 03:09:16 AM
here we have the X-Center without the debug Windows
Code: [Select]
'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

Code: [Select]
'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.
Title: Re: VB Script
Post by: needleworks on October 11, 2018, 02:08:30 PM
here we have the X-Center without the debug Windows
Code: [Select]
'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

Code: [Select]
'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.