Ok had to put this down to get other issues sorted but now that my manual tool release brain is working nicely time to get back into measuring these tools!
So I have pulled together a few different auto tool zero macros and really happy with this mashup as it has a few key protection features and leave the cnc in the state it was found in. The only issue is I am constantly hitting my z+ soft limit and getting movement that is not what I expect from the G53 command.
I will highlight the lines below to show you where I am having issues but it was my understanding that G53 is in machine coordinates and therefore any offset should have NO effect. With the 0 in the tool offset table I have no issues and the script runs well. Once the offset is set tho on the G53 to Z0 the cnc seems to want to go much higher ( I am assuming the offset value but have a +1mm soft limit on the z at the moment to stop my ball screw nut slamming into bearing blockā¦.)
I have tried many different work arounds but none worked well and I would prefer to fine the problem than have to back road methods to be honest.
'Author: Christopher Esser (Smokingman). Based on the work done by Greolt
' modded by jestah 10 dec 2012
' Define fixed parameters (Currently in Metric )
Tnumber = GetDRO(24) ' gets current tool
ProbeDist = "-50" 'Set the maximum distance to move the Z-axis before probe touches contact plate.
ProbeFeed = "500" 'Set the first plunge speed for the probe
ProbeFeed2 = "30" 'Set the second plunge speed for the probe
Retract = "0.5" 'Set distance to retract after probe (incremental move away from touch plate)
Retract2 = "0" 'Set distance to retract after probe ( in mech. coor.)
Xprobpos = "100" 'Centre of tool sensor X in mech coor
Yprobpos = "100" 'Centre of tool sensor Y in mech coor
' Declare Global Variables
Dim CurrentFeed
Dim CurrentAbsInc
Dim CurrentGmode
Dim StartingPoint
' Begin the Program
Call GetState
Call doProbe
Call RestoreState
' Get the Starting states
Sub GetState()
CurrentFeed = GetOemDRO(818) ' Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) ' Get the current G90/G91 state (Abs Coordinate Mode)
CurrentGmode = GetOemDRO(819) ' Get the current G0/G1 state
StartingPoint = GetOemDRO(85) - GetOemDRO(832) ' Get starting Z position in work coordinates (Z Machine Coord DRO - Z Fixture Orig Off DRO)
End Sub
' Restore the states
Sub RestoreState()
Code "F" &CurrentFeed ' Returns to prior feed rate
If CurrentAbsInc = 0 Then Code "G91" ' If G91 was in effect before then return to it
If CurrentGMode = 0 Then Code "G0" ' If G0 was in effect before then return to it
End Sub
' Probe routine
Sub doProbe()
'Check to see if the probe is already grounded or faulty
If isActive(DIGITIZE) Then
MsgBox "Ground fault in probe detected. Fix probe and try again. "
Exit Sub
End If
'Start the actual probe
code "G49" 'remove any tool offset (tried both of these options to stop hitting soft limits on z)
'SetToolParam(Tnumber,2,0)
'Code "G43 H" &Tnumber Code "G0 G53 Z" & Retract2 ' ( this is where the movement hits the soft limits even with the above removing tool length offsets...?!??!?) While IsMoving()
Wend
Code "G0 G53 X" & Xprobpos
While IsMoving()
Wend
Code "G0 G53 Y" & Yprobpos
While IsMoving()
Wend
Code "F" &ProbeFeed ' Set the probe plunge speed
Code "G91 G31 Z" &ProbeDist ' Probing move using incremental move mode.
While IsMoving() ' Wait while it happens
Wend
ZProbePos = GetVar(2002) ' Get the exact point the probe was hit
If (ProbeDist+StartingPoint = ZProbePos) Then ' No contact was made during plunge
Code "(Probe failed!)"
Exit Sub
End If
Code "G90 G0 Z" &ZProbePos ' Go back to that point. Always a very small amount of overrun.
While IsMoving ()
Wend
Code "G91 G0 Z" & Retract ' Retract
While IsMoving() ' Wait while it happens
Wend
Code "F" &ProbeFeed2 ' Set the probe plunge speed
Code "G91 G31 Z-" &Retract+0.5 ' Probing move using incremental move mode.
While IsMoving() ' Wait while it happens
Wend
ZProbePos = GetVar(2002) ' Get the axact point the probe was hit
Code "G90 G0 Z" &ZProbePos ' Go back to that point. Always a very small amount of overrun.
While IsMoving ()
Wend
SetToolParam(Tnumber,2,ZProbePos)
Code "G0 G53 Z" & Retract2 ' Retract to mech zero Have seen this drive z- into the tool sensor but not recently so may have solved this somewhere While IsMoving ()
Wend
Code "G43 H" &Tnumber' apply offset to tool
Code "(Tool offset set)" 'is it possible to but the actual offset set in this box? not really a issue but would be nice End Sub