1392
« on: August 14, 2016, 10:30:23 AM »
Hmm, i thought I had this working, seems not.
My routine seems to be coming up with odd results, here's the setup...
Ref tool = 126mm long approx
T1 = 145mm long approx
With ref tool in and zeroed at touch-plate surface manually, Machine Z = -66.7062
With T1 in and run to the touch-plate manually, Machine Z = -45.9865
So my length difference = 20.7187mm
I *think* the tool table should show 20.7187 (positive because T1 length > Ref Tool)
BUT
What it's showing is 25.970250 - totally wrong and off by some 5mm.
Anyone care to whale in and offer some help here?
Macro for height setting is below.
Sub Main()
' Tool Height Offset Measuring
' Based on the macros created be Big Tex - May 25 2010
' and modified by D. Kearley 29 July 2017 with help from Hood and others on the Mach3 forum
' Machine Z should be set manually with 3d Height Probe first to top of touch-plate
Dim ZNew, ZMachineEnd
Dim ClearAllow, NewOffSet
Dim Response, Style
Style = 48
If GetOemLED(800) Then
Response = MsgBox ("Mach In Reset, Enable And Start Again", Style, "Tool-Height Setting")
End
End If
Style = 48
If GetOemDRO(42) > 0 Then
Response = MsgBox ("Please Use A Zero Offset Length Tool For This Routine", Style, "Tool-Height Setting")
End
End If
Style = 3 + 32 + 256
Response = MsgBox ("Reset Reference Tool Offset?", Style, "Tool-Height Setting")
If response = 6 Then 'user pressed yes
SetVar(500, GetOEMDRO(85)) ' Get Current Z Machine Coordinate at first pass of routine - this was set manually with 3d-Taster
End If
If Response = 2 Then 'user pressed cancel
End
End If
' Move the Z axis up so 3d-taster can be replaced with a tool
Code "G0 G53 Z0" 'move in machine coordinates to Z zero
Style = 64
Response = MsgBox ("Please Mount First Tool In Spindle", Style, "Tool-Height Setting")
'//////// the block below will set all your reusable vars depending on Inch or mm.
'//////// this sets the vars so you only need ONE large block of probing code.
If GetOEMLED(801) Then ' On = English Measure INCH
FirstProbeDist = 6.0 ' Probe down 6 inches
FirstRetractDist = 0.05 ' Then retract .05 inch
SecProbeDist = 0.25 ' Then probe down .25 inches
FirstProbeFeed = 10.0 ' First probe feed @ 10 ipm
SecondProbeFeed = 1.0 ' Second probe feed @ 1 ipm
ClearAllow = 0.125 ' Max Allowable Clearance = Z Machine Zero - .125in
Else ' Off = Metric Measure MM
FirstProbeDist = 150.0 ' Probe down 150mm
FirstRetractDist = 1.0 ' Then retract 1mm
SecProbeDist = 6.0 ' Then probe down 6mm
FirstProbeFeed = 250.0 ' First probe feed @ 250 mm/min
SecondProbeFeed = 25.0 ' Second probe feed @ 25 mm/min
ClearAllow = 2.0 ' Max Allowable Clearance = Z Machine Zero - 2mm
End If
'//////// Error Condition checking...
If GetOemLED(16)<>0 Then ' Check for Machine Coordinates
Style = 48
Response = MsgBox ("Please Change To Working Coordinates", Style, "Tool-Height Setting")
Exit Sub ' Exit if in Machine Coordinates
End If
If GetOemLED(825)<>0 Then
Style = 48
Response = MsgBox ("Touch-Plate Is Grounded, Check Connection And Try Again)", Style, "Tool-Height Setting")
Exit Sub ' Exit if probe is tripped
End If
'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment
Style = 64
Response = MsgBox ("Ensure Touch-plate Is In Position", Style, "Tool-Height Setting") ' Get user to check probe plate
Code "F" & FirstProbeFeed ' Set feedrate to 10 ipm or 300mm/min
Code "(Probing for Z Zero.....)" ' Puts this message in the status bar
ZNew = (GetOEMDro(802) - FirstProbeDist ) ' Probe move to current Z - 6 inches
Code "G90 G31 Z" & Znew
While IsMoving() ' Wait for probe move to finish
Wend
ZNew = GetVar(2002) ' Read the touch point
Code "G0 Z" & ( ZNew + FirstRetractDist ) ' Move up .05 inch or 1mm in case of overshoot
While IsMoving()
Wend
Code "F" & SecondProbeFeed ' Set feedrate to 1 ipm or 25mm/min
ZNew = (GetOEMDro(802) - SecProbeDist ) ' Probe move to current Z - .25 inches
Code "G90 G31 Z" & Znew
While IsMoving()
Wend
ZNew = GetVar(2002) ' Read the touch point
ZMachineEnd = GetVar(2002) 'store the final machine co-ordinate
Code "G0 G53 Z0" 'Fully Retract the Z ready for next tool
While IsMoving()
Wend
NewOffset = ZMachineEnd - GetVar(500)'calculate the result
Tool = Question("Enter Tool Number For This Offset")
Code "G90" & "G10" & "L1" & "P" & Tool &"Z" & NewOffset
DoOemButton(121) 'show the tooltable
End Sub