You are on page 1of 5

Dim Answer

Dim Axis_Pos As Double

Dim WrkZero As Double

Dim FtoDRO As Double

Dim NewToolZero As Double

Dim Z_Offset As Double

FixedTouchOffsetDRO = 2015
WorkZeroDRO = 2016
Wh =2017
Code "G49" 'Tool Ofsetts Off

Tool_Num = GetDRO (24)

LineNo = GetOEMDRO(816)

If (Tool_Num = 0) Then

Dim Msg, Style, Title, Help, Ctxt, Response, MyString


Msg = "Have You Positioned Axis Above Sensor On Work ?" ' Define message.
'Style = vbYesNo + vbCritical + vbDefaultButton2 ' Definebuttons.
Style = 4 + 16 + 256 ' Define buttons.
Title = "Auto ToolSetter Setup" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = 6 Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Else ' User chose No.
Exit Sub
End If

Rem Auto Tool Zero Z- Metric Version

DiameterParam = 1
ZoffsetParam = 2
XwearParam = 3
ZwearParam = 4

Tool_Num = GetDRO (24)


SetCurrentTool (0) 'resets current tool to zero
SetFeedRate(800/60) 'sets feedrate

For ToolNumber = 1 To 250 'Zeros all tool Parameters


SetToolParam( ToolNumber , DiameterParam, 0)
SetToolParam( ToolNumber , ZoffsetParam, 0)
SetToolParam( ToolNumber , XwearParam, 0)
SetToolParam( ToolNumber , ZwearParam, 0)

Next

Code "(All Tools Zero'd)"

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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-25 F200" 'probing move, can set the feed rate here as well as how
far to move
While IsMoving() 'wait while it happens
sleep 50
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
sleep 100
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of
overrun
While IsMoving ()
sleep 50
Wend

Code "G4 P1.25" 'Pause for Dro to update.


Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate
thickness

Code "G4 P01" 'Pause for Dro to update.

Axis_Pos = GetOEMDRO(85)
SetUserDRO(WorkZeroDRO, Axis_Pos)

'Code "G4 P01" 'Pause for Dro to update.


Code "G0 G53 Z0 " 'put the Z retract height you want here
While IsMoving ()
sleep 50
Wend
SetOEMDRO (109 , PlateThickness) 'set the Z axis DRO to whatever is set as plate
thickness
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the
status bar if aplicable
Msg = "ERROR Z-Plate is grounded - Check and retry"
MsgBox Msg
Exit Sub
End If
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
'Exit Sub

End If

Msg = "Now Going To Move To Fixed Touch Plate. "


MsgBox Msg

Code "(Moving to Touch Plate)"

Code("G00 G53 Z0.00")'Rapid the head up


Code("G00 G53 X" & GetOEMDRO(1100) & " Y" & GetOEMDRO(1101) )
Code("G00 G53 Z" & GetOEMDRO(1102) )

While IsMoving() 'wait while it happens


sleep 50
Wend

Code "(Executing GazS Auto Z Zero)"

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
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
'DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-100 F200" 'probing move, can set the feed rate here as well as how
far to move g90 removed
While IsMoving() 'wait while it happens
sleep 50
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 ()
sleep 50
Wend
Code "G4 P1"

Tool_Num = GetDRO (24)

If Tool_Num =0 Then
ZprobeOffset = GetOEMDRO(85)

SetUserDRO(FixedTouchOffsetDRO, ZprobeOffset)
End If

If Tool_Num <>0 Then

Axis_Pos = GetOEMDRO(85)
WrkZero = GetUserDRO(WorkZeroDRO)
FtoDRO = GetUserDRO(FixedTouchOffsetDRO)
WrkHeight = WrkZero + FtoDRO
NewToolZero =Axis_Pos - FtoDRO
Z_Offset = NewToolZero
SetUserDRO(2017, WrkHeight)

'Tool_Offset = Axis_Pos - Z_Offset


Call setOEMDRO(42, Z_Offset)
Code "G4 P1"
End If

Code "G4 P01" 'Pause for Dro to update.


Code "G0 G53 Z0 " 'put the Z retract height you want here

Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the
status bar if aplicable
Msg = "ERROR Z-Plate is grounded - Check and retry"
MsgBox Msg
Exit Sub
End If
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

SetFeedRate (800/60)

Code "(All Done - Press 'Cycle Start')"

Exit Sub

You might also like