Hi all,
I am trying to make a useful z-height thing to run during an M6 tool change call. This is for a router-style machine where the tool height is variable because of the collet-holder, so i want to read and zero the tool at each change.
But Mach does not seem to work right if i try to call G31 two times in the same macro. Does this make sense?
Additionally, it seems that my chinese break-out-board w/ Ethernet SmoothStepper does not implement GetVar(2002), so i'm loading the z-height from the DRO.
That seems to work fine for the first run of G31, but the second time G31 runs, it will not stop its negative z travel before it reaches the point where the first G31 stopped! Yikes! During that time, i can see the "probe" LED turn on and off in the "diagnostics Alt-7" page, so signals are going places.
Once we pass the point where the first G31 stopped, it will respond to probe input and quit its negative z travel. Whew.
But the DRO value for z, whether we check
GetDRO(2)
or
GetOEMDRO(1002)
always contain the z-height from the first run of G31, never the second.
Banannas! Anybody know a fix? I've spent all day thinking i was either crazy or braindead trying to fix this before finally deciding it must be a bug of some sort, or??
Code:
slowFeed = 10 'in/min
OldProbeTouch = 0
NewProbeTouch = 0
ToolHeightDifference = 0
currentZ = 0
newZ = 0
allowedBreakThrough = 0.002 '2 thousandths of an inch
ToolChangeX = GetUserDRO(1200)
ToolChangeY = GetUserDRO(1201)
ToolChangeZ = GetUserDRO(1202) 'use Settings / tool change location / for touchplate location
GageH = GetOEMDRO( 1001 ) 'Gage Block Height from offsets screen *upper left hand one
Code "G53 G0 Z" & ToolChangeZ ' go to tool change z location FIRST
Code "G53 G0 X" & ToolChangeX & "Y" &ToolChangeY ' go to tool change x & y location SECOND
'FIRST PROBE CHECK'
Code "G31 Z" & -3 & " F" & slowFeed 'G31 is probe command
'enabling G53 (absolute coordinates' for z argument could help us target the bed of the machine
'or let soft limits help prevent a crash?
'If we don't find the probe within the z move
'we throw an error
While IsMoving()
Sleep(10)
Wend
' If GetOEMLed(825) = True Then 'Probing successful
'OldProbeTouch = GetVar(2002) 'Exact height touch plate was contacted // DOES NOT WORK ON CHINESE MACHINES?
OldProbeTouch = GetDRO(2)
'OldProbeTouch = GetOEMDRO(1002)
code "g4 p.5"
Code "G1 Z" & OldProbeTouch 'Go there (corrects for potential over-run)
While IsMoving()
Wend
' Else
' Message("Zero not achieved - Check probe and try again manually")
' End If
'FIRST PROBE CHECK'
MsgBox ("hit cycle start to begin second probe")
SystemWaitFor (Start) 'Pause macro to jog the Z axis close to the switch
'SECOND PROBE CHECK'
Code "G53 G0 Z" & ToolChangeZ ' go to tool change z location
Code "G31 Z" & -3 & " F" & slowFeed 'G31 is probe command
'enabling G53 (absolute coordinates' for z argument could help us target the bed of the machine
'or let soft limits help prevent a crash?
'If we don't find the probe within the z move
'we throw an error
' If GetOEMLed(825) = True Then 'Probing successful
'NewProbeTouch = GetVar(2002) 'Exact height touch plate was contacted // DOES NOT WORK ON CHINESE MACHINES?
NewProbeTouch = GetDRO(2)
'NewProbeTouch = GetOEMDRO(1002)
code "g4 p.5"
Code "G1 Z" & NewProbeTouch 'Go there (corrects for potential over-run)
While IsMoving()
Wend
' Else
' Message("Zero not achieved - Check probe and try again manually")
'End If
'SECOND PROBE CHECK'
ToolHeightDifference = OldProbeTouch - NewProbeTouch
currentZ = GetDRO(2)
newZ = currentZ - ToolHeightDifference
Call SetDRO(2, currentZ) 'set work coordinate z0 based on difference between old and new tool
newZMin = NewProbeTouch - GageH - allowedBreakThrough
Message("Old Height " & OldProbeTouch & " New Height " & NewProbeTouch & " Toolheighdifference " & ToolHeightDifference & " new Z should be: " & newZ & " new Zmin should be: " & newZMin)
' SetOEMDRO(158, newZMin) 'OEMDRO 158 is the z min limit
'set it to be at the tip of the tool when the touchplate is removed
Similar Threads: