Rick,
Ok, here is something that may help you out.
First let me ask you this Question, do you have Tool Holders???
If you do, you can set up all your tool Ht. offsets in Mach3's tool library
on the setup page. That way, once you run your program, it will just call
the offset by the tool number you previously set in the library. It would
save you alot of time.
I am going to work on the assumption though at your post that you DON'T have
tool holders and have something like an R-8 that you have to set the tool H, for
each tool change, the macros below will be for that scenerio, if you have holders
let me know, and I will try and help you modify for that situation.
Ok your M998 will be used AFTER the a M6 call.
For M6 to work, you will need to go under:
config>general and tick the Auto Tool changer
also under general you will need to tick off "use M1" for optional stop.
under config>homing limits, you will need to set the coordinates of your G28 move
under config>SafeZ settings, you will need to set the type of Safe Z you want, for this
example I used "1" above "Program" corrdinates.
Note: the Tool path does NOT see the moves of your M998 so, your tool path may look a little funny.
ASSUMPTIONS:
here are the assumptions that this macro makes about your machine, change them if not true
to your machine.
It assumes that "Z0" is the Top of your Work Piece, OR, some Place on
your table that you reference your tool Zero's. Z0 MUST be the same physical
point hiegth for all the tools to zero againts that you will use on the part.
Assumes Negative Z is DOWN into your part, and Z0 is the top of your stock or some
other repeatable point. Positive Z goes up away from your table/part.
It assumes you have Ref'ed your machine
prior to the tool change, if not, it will kick out and make your ref your machine.
It also assumes that any complex tool/paths like reverse counter bores that you have brought
the tool out, at least where it can safely be drawn Straight up after the tool completes
its path.
It assumes "English" measure.
you will NOT be doing any fixture, or other coordinate offsets between tool changes or
until this part is finished.
Sequence of Events:
A M6 tool change is called
it grabs the Z location of the the current cutting tool tip
the m6 moves your old tool to program z0.1, and then grabs the xyz positon in program cord.
stores that location in your Mach Vars
it then moves to SafeZ, and then goes to your G28 location
Does a "M1" optional stop (you will need that ticked off in gen, see above).
You will then change your tool.
then goto your offsets page.
You will then jog the new tool to your program "0" point, and zero (touch off) what ever the next tool # is set its zero.
If you dont want crap in your tool library, then use all T0's for each tool
You will then hit "Cycle Start"
your spindle will start running, at the new speed and direction
Your M998 will then run this will move to Safe Z hieght directly above
where your last tool left off.
it will rapid down to slightly above your part or (program "z0")
it will move down into the work to the hiegth the last tool left off at new Feed speed
Your M998 will exit, and the new tool follow the new path.
G-code Programming notes:
After your M6 and before your M998 you will need to program in your S word,
and M3 or M4, any F Feed speed canges,
EXAMPLE G-code:
M3 S1000 F10 'sets the rot. dir, feed and speed for your new tool.
T2 M6 'Set tool# and execute M6
M998 'returns to last point, spindle spinning, at G0, and safe Z ht.
'then it will feed at last F speed, to where the Old tool left off
G code FILE:
there is G-code at the bottom of this post that you can run to test all of this
M6 TOOL CHANGE CODE:
'M6Start.m1s
Sub Main()
'Semi-Auto Tool Change
Dim OldTool
Dim NewTool
Dim CurX, CurY, CurZ, ZLast
Dim SafeZ
OldTool = GetCurrentTool() 'get old tool number
NewTool = GetSelectedTool() 'get new tool number
SafeZ = GetParam("SafeZ") 'get Safe Z ht, from Config>SafeZ setup
If (GetOemLed(807) Or GetOemLed(808) Or GetOemLed(809)) Then 'Check all axes referenced
Message(" Please Home Machine before Tool Change")
DoButton(3) 'Cycle Stop
Exit Sub
End If
'******************************************************************************
ZLast = GetOemDRO(802)
SetVar(103,ZLast)
'get current Z position in program Coords where
'this tool, (oldtool), has stopped cutting IN the work at what ever level and position in the
'work where it stopped spinning at. This is so the new tool can have a place in the
'work to pick up exactly where the old tool left off. The danger here is for example
'if the new tool is bigger than the slot you just cut, The M998 will bring the new
'tool above the work at Safe Z, then it will feed directly Down at Feed Speed to
'the level the old tool left off. If this is not what you want, take this code out.
'*******************************************************************************
DoSpinStop() 'Request spindle stop
While IsMoving()
Wend
Code "G90 G1 Z0.1 F20" 'Move oldtool up from its current
'cutting depth to slightly above part/program "Z0" coordinates
CurX = GetOemDRO(800) 'get current X position in program Coords
CurY = GetOemDRO(801) 'get current Y position in program Coords
CurZ = GetOemDRO(802) 'get current Z position in program Coords
SetVar(100,CurX) 'sets the "0" return point for X for your M998
SetVar(101,CurY) 'sets the "0" return point for Y for your M998
SetVar(102,CurZ) 'sets the "0" return point for Z for your M998
Code "G0 Z" & SafeZ 'Move to safe Z travel hieght
While IsMoving() 'Wait for spindle up
Wend
Code "G28" 'this will move to the G28 homing position for tool
'change
While IsMoving()
Wend
SetOEMDRO(824, NewTool) 'set old tool to New tool
Code "M1" 'sets a machine pause for you to change tool
'When you have changed to your new tool, zero it to your zero point then hit
'cycle start.
End Sub
'End of M6
'===================================================================================
'===================================================================================
'===================================================================================
'M998.m1s
Sub Main()
Dim SafeZ, CurX, CurY, CurZ, ZLast, CurFeed
SafeZ = getParam("SafeZ") 'gets your safe Z settings.
CurX = getVar(100) 'gets the "0" return point for X from your M6
CurY = getVar(101) 'gets the "0" return point for Y from your M6
CurZ = getVar(102) 'gets the "0" return point for Z from your M6
ZLast = getVar(103) 'gets the last Z program cutting ht that the
CurFeed = GetOemDro(818) 'get current feed rate 'old tool left off at.
Code "G0 Z" & SafeZ 'Move to safe Z travel hieght
While IsMoving()
Wend
Code "G0 X" & CurX & " Y" & CurY
Code "G0 Z" & CurZ
'The new tool will rapid move directly over the x,y where your old tool left off
'Then it will rapid down to slightly above your Program Z0.
While IsMoving()
Wend
Code "G01 Z" & ZLast & " F" & CurFeed
'The new cutter moves down from slightly above Program/Part Z0 (z0.1 in this case)
While IsMoving()
Wend
'once it reaches the -Z plane that the last cutter left off at, this macro will
'exit and the new tool will follow what ever path you have laid out for it.
End Sub
'End M998 =================================================================
G code testing file
G28M6testfile.TAP
(Turn on your Single block so you can step through)
(the Gcode, once done, run regular)
m3 S500 F10
T0
g1 x1
g1 Z-1
T2 (m6 open vb window and step through the code here)
(look under Operator>Gcode Var monitor, punch in vars)
(100, 101, 102, 103 you will see the saved last coordinates)
(close the vb window after you have stepped all the way through)
(Zero your next tool here)
m3 s1000 F5
(M998 step through this one as well)
g1 y1
g1 z-1
g1 z0
m30
'Enjoy,
'Scott