Hello Guest it is April 18, 2024, 07:25:33 PM

Author Topic: VB Script  (Read 4855 times)

0 Members and 1 Guest are viewing this topic.

Offline TPS

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


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

Offline TPS

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


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

Offline TPS

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


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

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB Script
« Reply #17 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.
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 #18 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 !

Offline TPS

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




anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.