Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: birillo1959 on April 29, 2018, 07:27:43 AM

Title: Auto corner finding problem
Post by: birillo1959 on April 29, 2018, 07:27:43 AM
Good morning
I have a problem with the following script
if I cast Y-Y + X-X + everything works fine instead for the corner search gives me problems
1 press the corner button
2 part and touch the z-
3 rises, moves for probing in x +
4 goes down
at this point it crashes and I get out the words "Probe plate is grounded, check and try again" I state that if I run the script from the window works well, I have done many tests I can not get over it.
Ps: the problem and with all 4 corners

Rem   Auto corner finding X-Y+Z-(button4) With tool diameter Input Metric Version

   Speak (" CONFERMARE RICERCA ANGOLO INFERIORE DESTRO") 'Avviso Vocale
Message "INIZIO RICERCA ANGOLO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE RICERCA ANGOLO")

CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825)<>0 Then 'Check to see if the probe is already grounded or faulty
   Call ProbeGrounded()
   Exit Sub
Else
   DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
   Code "G4 P2" ' two second delay
   Code "G90 G31 Z-25 F100" 'Z goes down a max of 25mm at 100mm/sec
   While IsMoving() 'wait while it happens
   Wend
   ZProbePos = GetVar(2002) 'get the axact point the probe was hit
   Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
   While IsMoving ()
   Wend
   Call SetDro (2,0.000)
   Code "G4 P0.25" 'Pause for Dro to update.
   Code "G90 G0 Z15" 'retract Z to 15mm
   Code "G91 G0 Y3 X25"
   Code "G90 G0 Z-5"
   Code "F" &CurrentFeed 'Returns to prior feed rate
End If

Rem   VBScript For probing In the x- direction

If GetOemLed (825)<>0 Then    'May need to use =0 if it errors
   Call ProbeGrounded()    'Check to see if the probe is already grounded or faulty
   Exit Sub
Else
   Code "G4 P1"         'Pause 1 second to give time to position probe plate

   CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later
   Code "F100"

Rem   Probe Left

   XNew = GetDro(0) - 75      'probe to current position - 75mm
   Code "G31 X" &XNew
   While IsMoving()      'wait for prob move to complete
   Wend
   XNew = GetVar(2000)      'read the touch point

Rem   move back To the hit point incase there was an overshoot

   Code "G90 G0 Z15"
   Code "G90 G0 X" &XNew
   Code "G91 X-" &CurrentToolDiameter/2  'moves the probe half the tool diameter to center on edge
       
   
   While IsMoving ()
   Wend
        Call SetDro (0,0.000)
        Code "G4 P0.25"
        Code "G91 G0 X-5 Y-25"
        Code "G90 G0 Z-5"
   Code "F" &CurrentFeed       'restore original feed rate
End If

Rem   VBScript For probing In the Y+ direction

If GetOemLed (825) <> 0 Then       'Check to see if the probe is already grounded or faulty
   Call ProbeGrounded()
   Exit Sub
Else
   Code "G4 P1"         'Pause 1 second to give time to position probe plate

   CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later
   Code "F100"         'Slow feedrate to 100mm

Rem   Probe up

   YNew = GetDro(1) + 75      'move to current y position + 75mm
   Code "G31 Y" &YNew
   While IsMoving()      'wait for the move to finish
   Wend
   YNew = GetVar(2001)      'read the touch point

Rem   move back To the hit point incase there was an overshoot
   
        Code "G90 G0 Z15"
   Code "G90 G0 Y" &YNew
        Code "G91 Y" &CurrentToolDiameter/2  'moves the probe half the tool diameter to center on edge

   While IsMoving ()
   Wend
        Call SetDro (1,0.000)
        Code "G4 P0.25"
        Code "G90 G0 X0.0"
   Code "F" &CurrentFeed       'restore original feed rate
        Code "(X, Y, and Z axis' are now zeroed)"
        Call ReturnG90G91State()
        Exit Sub
End If

   
Sub ProbeGrounded()
   Code "(Probe plate is grounded, check connection and try again)"
   Call ReturnG90G91State()
End Sub

Sub ReturnG90G91State()
   If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
      Code "G91"
   End If
   If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
      Code "G0"
   End If
End Sub

Title: Re: Auto corner finding problem
Post by: ger21 on April 29, 2018, 07:31:49 AM
What version of Mach3, and what motion controller, if you are using one?
Title: Re: Auto corner finding problem
Post by: birillo1959 on April 29, 2018, 08:24:11 AM
thanks for the reply Gr21
use mach3 Version R3.043.062 port lpt
Title: Re: Auto corner finding problem
Post by: TPS on April 30, 2018, 12:02:52 PM
then you hit the probe during Z- move

VBScripter Window step through
Title: Re: Auto corner finding problem
Post by: birillo1959 on April 30, 2018, 01:15:54 PM
thanks for the help of TPS
I do not know what you mean
I did a test I changed:
If GetOemLed (825) <> 0 Then 'May need to use = 0 if it errors
with
If GetOemLed (825) = 0 Then 'May need to use = 0 if it errors
it works, but I do not know if it's done well or if it's dangerous, from some tests it works well
Title: Re: Auto corner finding problem
Post by: TPS on April 30, 2018, 01:23:49 PM
your Change is defintly nor ok.

try this:




Rem   Auto corner finding X-Y+Z-(button4) With tool diameter Input Metric Version

   Speak (" CONFERMARE RICERCA ANGOLO INFERIORE DESTRO") 'Avviso Vocale
Message "INIZIO RICERCA ANGOLO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE RICERCA ANGOLO")

CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825)<>0 Then 'Check to see if the probe is already grounded or faulty
   Call ProbeGrounded()
   Exit Sub
Else
   DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
   Code "G4 P2" ' two second delay
   Code "G90 G31 Z-25 F100" 'Z goes down a max of 25mm at 100mm/sec
   While IsMoving() 'wait while it happens
   Wend
   ZProbePos = GetVar(2002) 'get the axact point the probe was hit
   Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
   While IsMoving ()
   Wend
   Call SetDro (2,0.000)
   Code "G4 P0.25" 'Pause for Dro to update.
   Code "G90 G0 Z15" 'retract Z to 15mm
   Code "G91 G0 Y3 X25"
   Code "G90 G0 Z-5"

   while IsMoving()
     sleep(10)
   Wend
   

   Code "F" &CurrentFeed 'Returns to prior feed rate
End If

Rem   VBScript For probing In the x- direction

If GetOemLed (825)<>0 Then    'May need to use =0 if it errors
   Call ProbeGrounded()    'Check to see if the probe is already grounded or faulty
   Exit Sub
Else
   Code "G4 P1"         'Pause 1 second to give time to position probe plate

   CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later
   Code "F100"

Rem   Probe Left

   XNew = GetDro(0) - 75      'probe to current position - 75mm
   Code "G31 X" &XNew
   While IsMoving()      'wait for prob move to complete
   Wend
   XNew = GetVar(2000)      'read the touch point

Rem   move back To the hit point incase there was an overshoot

   Code "G90 G0 Z15"
   Code "G90 G0 X" &XNew
   Code "G91 X-" &CurrentToolDiameter/2  'moves the probe half the tool diameter to center on edge
       
   
   While IsMoving ()
   Wend
        Call SetDro (0,0.000)
        Code "G4 P0.25"
        Code "G91 G0 X-5 Y-25"
        Code "G90 G0 Z-5"

   while IsMoving()
     sleep(10)
   Wend
   
 
  Code "F" &CurrentFeed       'restore original feed rate
End If

Rem   VBScript For probing In the Y+ direction

If GetOemLed (825) <> 0 Then       'Check to see if the probe is already grounded or faulty
   Call ProbeGrounded()
   Exit Sub
Else
   Code "G4 P1"         'Pause 1 second to give time to position probe plate

   CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later
   Code "F100"         'Slow feedrate to 100mm

Rem   Probe up

   YNew = GetDro(1) + 75      'move to current y position + 75mm
   Code "G31 Y" &YNew
   While IsMoving()      'wait for the move to finish
   Wend
   YNew = GetVar(2001)      'read the touch point

Rem   move back To the hit point incase there was an overshoot
   
        Code "G90 G0 Z15"
   Code "G90 G0 Y" &YNew
        Code "G91 Y" &CurrentToolDiameter/2  'moves the probe half the tool diameter to center on edge

   While IsMoving ()
   Wend
        Call SetDro (1,0.000)
        Code "G4 P0.25"
        Code "G90 G0 X0.0"
   Code "F" &CurrentFeed       'restore original feed rate
        Code "(X, Y, and Z axis' are now zeroed)"
        Call ReturnG90G91State()
        Exit Sub
End If

   
Sub ProbeGrounded()
   Code "(Probe plate is grounded, check connection and try again)"
   Call ReturnG90G91State()
End Sub

Sub ReturnG90G91State()
   If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
      Code "G91"
   End If
   If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
      Code "G0"
   End If
End Sub
Title: Re: Auto corner finding problem
Post by: birillo1959 on April 30, 2018, 01:52:32 PM
ok TPS works well (as always you're a big one ;) ;))
I have also added
XNew = GetVar (2000) 'read the touch point
Code "G91 G0 X2"

is
YNew = GetVar (2001) 'read the touch point
Code "G91 G0 y-2

it works, but can it create problems?
greetings and again THANK YOU !!