Hello Guest it is April 18, 2024, 06:52:11 PM

Author Topic: Macro does stop  (Read 1430 times)

0 Members and 1 Guest are viewing this topic.

Macro does stop
« on: October 30, 2017, 11:14:59 AM »
I am reusing a macro I loaded somewhere to zero the tool.

Here is the macro:

Code: [Select]
[code]'VB Code Start
'-------------------
CurrentFeed = GetOemDRO(818)
DoSpinStop()
CODE"G90"
code"G0 X100 Y100"
code"G0 Z-50"
Sleep (100)


ZMove = 80.00 'Distance of Probe to move from 0 absolute before Stop or no Contact Made.
ZOffset = 2 ' Plate Hight
ZSal = ZOffset + 8.00 '+ Free Hight, Will possition the Proble 2 MM over the Material.

StopZmove = 0
If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G4 P2.5"
Code "G31 Z-"& ZMove & "F25"
While IsMoving()
Sleep(200)
Wend
Probepos = GetVar(2002)
If Probepos = - ZMove Then

'****************
Code "G0 Z-10" 'this does not happen
responce = MsgBox ("**ERROR** " , 4 , "Probe **ERROR**" ) 'this message never pops out
'***************

StopZmove = 1
Code "F" &CurrentFeed
End If
If StopZmove = 0 Then
Code "G0 Z" & Probepos
While IsMoving ()
Sleep (200)
Wend
Call SetDro (2, ZOffset)
Code "G4 P1"
Code "G0 Z" & ZSal
Code "(Z zeroed)"
Code "F" &CurrentFeed
End If
Else
Code "(Check Ground Probe)"
End If
Exit Sub
'-------------------
'VB Code Stop
[/code]

I have commented two lines in the middle of the code that should show an error message and move the z up to -10 in the event that the probe is not found.
Actually is not happening, if the probe is not found within the given ZMove, nothing happens it just stop.

If the ZMove is reached, I would like to move  Z up to -10 and pop out the error message "Probe Error".
I do not get the problem. Any help will be appreciated.

Thanks
Felice

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Macro does stop
« Reply #1 on: October 30, 2017, 02:55:21 PM »
Hi,

why should your Probepos be equal -ZMove when the probe was never hit ??

--> Probepos = GetVar(2002)
--> If Probepos = - ZMove Then

something like this should work:

While IsMoving()
        z = GetOEMDRO(802) 'Z-actpos
        If z <=  - ZMove _In Then
            DoOEMButton(1003) 'Stop
            MsgBox ("Probe **ERROR**" )
        End If
 Wend

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