Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: Bruce Griffing on September 07, 2018, 10:23:40 PM
-
First, I used search (unsuccessfully) to see if I could find if someone has done this before. I have a CNC router running Mach3. 67x66x11 inch x,y,z. It has a 15 position rack type tool changer at one edge that holds ISO 20 tools for its 3HP atc spindle. So I have a tool change macro for it that seems to work. I also have a tool height setter at one end of the tool rack. Has anyone already written a macro to auto set all of the tools in the rack?
-
create am macro, lets say M1000.M1s
code of the probemacro can be something like this:
Sub Main()
'get Parameter ------------------------------------------------------
Tool = Param1()
'--------------------------------------------------------------------------------
'ceck toolnumber----------------------------------------
If ((Tool < 1) or (Tool > 16)) then
Message ("toolnumber not valid")
GoTo Ende
End If
'--------------------------------------------------------------------------------
'load the tool
Code "M6 T" + cstr(Tool) + " M5"
'--------------------------------------------------------------------------------
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' PUT HERE SOME CODE TO DRIVE TO THE PROPBEPOSITIO
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'do the probing
ZM_in = 100 'max probing distance
Code "G31 Z100" + CStr(ZM_In) +"F50"
While IsMoving()
z = GetOEMDRO(802) 'act Z-pos
If z <= ZM_In Then
DoOEMButton(1003) 'Stop if too far
MsgBox ("probe not hit" )
GoTo Ende
End If
Wend
'et the probepos
ZProbePos = GetVar(2002)
'put the value into tooltable
SetToolParam(Tool,2, ZProbePos)
'save tooltable
DoOEMButton(316)
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' PUT HERE SOME CODE TO COME OUT OF THE PROBEPOS
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'unload the tool
Code "M6 T0"
Exit Sub
Ende:
Code "M30"
'Message ("error while probing")
End Sub
then you can do a probing with
M1000 P1 to probe tool 1 or
M1000 P2 to probe tool 2
the P-Parameter is the toolnumber.
now you can create a smal G-code file, where you can call M1000 for all your Tools.
be Patient, the posted code is not tested and not complete, it is just to give you an idea.