Hello Guest it is July 08, 2020, 07:09:10 AM

Author Topic: VB Script  (Read 1633 times)

0 Members and 1 Guest are viewing this topic.

VB Script
« 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.

Offline ger21

*
  • *
  •  6,282 6,282
    • View Profile
    • The CNC Woodworker
Re: VB Script
« Reply #1 on: October 03, 2018, 08:07:00 AM »
Inside, or Outside, and how far do you need the movement to be?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB Script
« Reply #2 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.

Offline TPS

*
  •  1,607 1,607
    • View Profile
Re: VB Script
« Reply #3 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.

anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB Script
« Reply #4 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.
Re: VB Script
« Reply #5 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.
Re: VB Script
« Reply #6 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 ?

Offline TPS

*
  •  1,607 1,607
    • View Profile
Re: VB Script
« Reply #7 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


anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: VB Script
« Reply #8 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.

Offline ger21

*
  • *
  •  6,282 6,282
    • View Profile
    • The CNC Woodworker
Re: VB Script
« Reply #9 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.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html