Hello Guest it is October 16, 2019, 11:31:15 PM

Author Topic: Last Revision of Auto Too Zero for XY & Z  (Read 1863 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
XaxisDRO=800
YaxisDRO=801
ZaxisDRO=802

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


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


2:
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
   Wend
   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
   Wend
   SetOEMDRO(YaxisDRO, ToolDia/2)
   Sleep 1000
   code "G1 Y.5"
End If

3:
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

4:
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
   Wend
   SetOEMDRO(ZaxisDRO, TouchPlate)
   Sleep 1000
   code "G1 Z1"
End If
GoTo 6

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

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

7:
End Sub             


Holler if you have any questions.

airnocker

Everything depends on everything else