Hello Guest it is January 23, 2021, 06:01:47 PM

Author Topic: Last Revision of Auto Too Zero for XY & Z  (Read 2048 times)

0 Members and 1 Guest are viewing this topic.

Last Revision of Auto Too Zero for XY & Z
« on: March 22, 2014, 06:46:15 PM »
My apologies for not keeping up with updates on earlier posts on this topic.  A recent message made me aware that I had not provided my latest version of this button macro for Auto Tool Zero.

This new version adds prompting to input the tool diameter at the beginning, and auto-calculates the tool offset.

This code was last updated on 12/6/2011...time passes  ;)

Sub Main()

Dim ConfirmReady As String
Dim DoXY As String
Dim DoZ As String
Dim TouchPlate As Double
Dim XaxisDRO As Integer
Dim YaxisDRO As Integer
Dim ZaxisDRO As Integer
Dim ToolDia As Double

Message ( " Prepare to enter tool diameter. " )
ConfirmReady = AskTextQuestion("Confirm Touch plate leads are connected and ready. (y/n)")
If ConfirmReady = "y" Then GoTo 1 Else GoTo 5

DoXY = AskTextQuestion("Zero X and Y also? (y/n)")
If DoXY = "y" Then GoTo 2 Else GoTo 3

ToolDia = AskTextQuestion("What is the tool diameter?")
Message( "Auto Zeroing X...")
SetOEMDRO(XaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 X-2 F10"
   While IsMoving()
   Sleep 100
   SetOEMDRO(XaxisDRO, ToolDia/2)
        Sleep 1000
   code "G1 X.5"
End If

Message( "Auto Zeroing Y..." )
SetOEMDRO(YaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 Y-1 F10"
   While IsMoving()
   Sleep 100
   SetOEMDRO(YaxisDRO, ToolDia/2)
   Sleep 1000
   code "G1 Y.5"
End If

DoZ = AskTextQuestion("Position the touch plate to zero Z.  y  to continue or n to skip.  (y/n)")
If DoZ = "y" Then GoTo 4 Else GoTo 6

TouchPlate = AskTextQuestion("Enter Touch Plate thickness: e.g. 0 or .182")
Message( "Auto Zeroing Z..." )
SetOEMDRO(ZaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 Z-2 F5"
   While IsMoving()
   Sleep 100
   SetOEMDRO(ZaxisDRO, TouchPlate)
   Sleep 1000
   code "G1 Z1"
End If
GoTo 6

Message ("Tool zeroing aborted.  Try again when ready.")
GoTo 7

Message "Tool zeroing complete.  Check the results on the DROs."

End Sub             

Holler if you have any questions.


Everything depends on everything else