20
« on: December 22, 2016, 07:17:45 PM »
I think I have it worked out...simple really (If I am doing it correctly!) just have to grab the remote Z touch value after you set the first tool...then on the next tools, just go remote, probe till it stops, then write the value you got the on the first tool into the Z...I tried to get clever and use the gcode line number to automatically run the correct code...anyway I am posting it for review and comments...
' This routine checks if this is the first time tool change using the current GCode line number
' less than 20 means this is the first tool change
' then it does the correct Z touch off
lnum = GetOEMDro(816) 'Get the current line number in the code window
PlateOffset = GetUserDRO(1151) 'Get plate offset DRO
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
If lnum < 20 Then ' must be the first one
If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar
Else
Code "G4 P1" 'Pause 1 seconds to give time to position probe plate
Code "F4" 'slow down feedrate to 4 ipm
'Probe wherever we are
ZNew = GetDro(2) - 2 'probe move to current z - 2 inches
Code "G31Z" &ZNew
While IsMoving() 'wait for probe move to finish
Wend
ZNew = GetVar(2002) 'read the touch point
Code "G0 Z" &ZNew 'move back to hit point incase there was overshoot
While IsMoving ()
Wend
If PlateOffset <> 0 Then
Call SetDro (2, PlateOffset) 'set the Z axis DRO to plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
'now lets probe at the remote point to get the Z dro offset for subssequent tool changes
Code "G53F200Z-.1" 'go to a safe Z
While IsMoving()
Wend
CODE "G53F200X0.315Y4.125" 'go to where the remote touch off is
While IsMoving()
Wend
CODE "G53F200Z-2.5" 'come down fast to get us close
While IsMoving()
Wend
MsgBox "Move the touch plate to the remote location. Press okay to continue" ' let the op know
CODE "G31F4Z-2" 'do the probe thing
While IsMoving()
Wend
Code "G4 P1" 'hold on on second for the DRO to update
tooloffset = GetDro(2)
SetUserDRO(1205, tooloffset) 'set the Z DRO to the value we got when the initial Z touch was done
Code "G53F200Z-.1" 'go to a safe Z height
While IsMoving()
Wend
Code "G0X0Y0" 'go back to 0
End If
Code "F" &CurrentFeed 'Returns to prior feed rate
End If
Else
If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Else
Code "G4 P1" 'Pause 1 seconds to give time to position probe plate
PlateOffset = GetUserDRO(1151) 'Get plate offset DRO
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
Code "F4" 'slow down feedrate to 4 ipm
Code "G53F200Z-.1" 'go to a safe Z height
While IsMoving()
Wend
CODE "G53F200X0.315Y4.125" 'go to where the remote touch off is
While IsMoving()
Wend
CODE "G53F200Z-2.5" 'get close on the Z at a fast rate
While IsMoving()
Wend
MsgBox "Move the touch plate to the remote location. Press okay to continue" ' let the op know
CODE "G31F4Z-1" 'now lets probe Z
While IsMoving()
Wend
Code "G4 P1" 'give it s second to update
toolOffset = GetUserDRO(1205)
Call SetDro (2, toolOffset) 'set the Z DRO to the offsset value we got when we did the first tool
Code "G53F200Z-.1" 'go to a safe Z height
While IsMoving()
Wend
Code "F" &CurrentFeed 'Returns to prior feed rate
End If
End If