Ok, on paper at least, I think this macro will work
...
Ref machine,
Place 3-taster in spindle,
Place touch-plate,
Jog Z to zero on plate,
Press macro start button or MDI it
User is asked if they want to store the new reference offset (this bit needs automating somehow)
If yes then current Z machine DRO is stored in var
then z raises to zero so drawbar can be released
user prompted to fit first tool
height is probed
difference in new z machine DRO and reference one calculated and passed to code for storage in tool table as per Hoods' idea (nice)
rinse and repeat
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 via Mach3 forum
' Machine Z should be set with 3d Height Probe first to top of touch-plate
Dim ZNew, ZMachineEnd
Dim ClearAllow, NewOffSet
If GetOemLED(800) Then
MsgBox ("Mach In Reset, Enable And Start Again")
End
End If
If MsgBox ("Reset Reference Tool Offset?", 260, "Master Reset")=6 Then
SetVar(500, GetOEMDRO(85)) ' Get Current Z Machine Coordinate at first pass of routine - this was set manually with 3d-Taster
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
MsgBox "Please Mount First Tool In Spindle"
'//////// 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
Code "(Please change to working coordinates)"
Exit Sub ' Exit if in Machine Coordinates
End If
If GetOemLED(825)<>0 Then
Code "(Touch-Plate Is Grounded Check connection and try again)"
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
MsgBox "Touch-plate should be in position" ' 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 = GetVar(500) - ZMachineEnd 'calculate the result
Tool = Question("Enter Tool Number For This Offset")
Code "G90" & "G10" & "L1" & "P" & Tool &"Z" & NewOffset
DoOemButton(121) 'show the tool table
End Sub
What we reckon ??
Will have a play with it tonight on the machine just to see what happens.