Home
Downloads
Mach and LazyCam
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
German Forum
Italian Forum
Portugese Forum
Resources
Links
User Reviews
User Videos
Contact Us
CNCZone
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
December 02, 2008, 03:30:13 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
Need help with manual toolchange macro
Pages:
1
Go Down
« previous
next »
Author
Topic: Need help with manual toolchange macro (Read 890 times)
0 Members and 1 Guest are viewing this topic.
rickturner646
Active Member
Offline
Posts: 5
Need help with manual toolchange macro
«
on:
June 05, 2008, 02:30:41 PM »
Hi All:
I have a new mill running under Mach3 and need to create a macro for manual tool changing, since it is a single tool machine. The g-code files that I am using contain an M998 call and this simply causes the machine to stop and wait for a cycle start press. I could change the tool then but usually the head is too close to the workpiece, and in any event, I still need to reset the Z offset for the new tool since they're not standard length.
What I want to be able to do therefore is to have the machine move 'home' and pause so that I can manually change the tool and set a new Z offset for it. Then I want to hit cycle start and have the machine return to the point where it originally stopped (and then hit cycle start again to recommence machining).
It's not complex, but I am tearing my hair out trying to figure out how to do this. I'd like to be able to 'trap' the G998 call in some way and modify the behaviour. VB is no problem for me but I cannot find where this macro is coded in Mach3 or how to modify it (the documentation is kinda sparse here, as far as I can see).
Any pointers as to where to get started (and to Mach3 programming docs) would be appreciated, as will any existing examples or code skeletons that I can 'borrow' from or modify.
Regards,
Rick
Logged
Chaoticone
South Carolina, US
Administrator
Online
Posts: 2,810
Precision Chaos
Re: Need help with manual toolchange macro
«
Reply #1 on:
June 05, 2008, 03:25:56 PM »
For information look on the wiki, videos, docs., ect. in the support tab at the top of this page. Can also ask questions here and do searches. The standard macros for tool cahnge are M6. Mach has two, M6 start and M6end. In general config., top left there are check boxes to choose ignore tool change, stop and wait, and auto. Ignor will do nothing if a M6 is called, stop and wait will run thru the M6 start macro and wait on a press of cycle start to run the M6 end macro. The auto will just run thru the M6 start I think and ignor the M6. You can make your on macro in a text file and save them as M6start.m1s and M6end.m1s or edit the ones allready there. They will be in you c/mach3/macros folder. In there all of the profiles are listed and the macros for each are in those folders. Also, with Mach open their is a tap at the top, operator. Two vb editors in their button script and vb editor. You can open the editor and scroll thru the code and see what mach does at each line.
Here is a M6start macro that stops the spindle, goes to the tool change pos. set by the tool change pos. DROs on the settings page, ask if you want to do an auto touch off, runs the auto tool touch off if you choose and then you have the M6 end macro that returns it to state prior to tool change. Doesn't return it to the pos. though. I had that in there but going back to where it requested the tool change was a waste of time mostly for me. Usually after a tool change it starts back in a different pos. any ways. I will try to find that one for if you really want it though.
Be sure to test these!!!!! Been a long time since I messed with these particular ones.
'M6 start macro with auto tool touch off
'M6Start.m1s
tool = GetselectedTool()
oldTool = GetOEMDRO(1212)
If (oldTool <> tool) Then
Old_tool = GetCurrentTool()
New_Tool = GetSelectedTool()
DoSpinStop()
If getoemled(13) Then
'coolant is on
setuserled(1000,1)' set user led on
Code "M9"
Else
'coolent is off
setuserled(1000,0) ' set user led off
End If
'Get the tool change pos from the settings page
ChangeX = GetOEMDRO(1200)
ChangeY = GetOEMDRO(1201)
ChangeZ = GetOEMDRO(1202)
Code "G00 G54 Z.25"
Code "G00 G53 X" & ChangeX & "Y" & ChangeY
'Code "G00 G53 Z" & ChangeZ, You may want to use this.
Response = MsgBox ( "Would you like to set your Z height automatically? If so, click OK", 1 )
If Response = 1 Then
CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness =0.062
ProbeFeed = 5
Code "G90 F" &ProbeFeed
If GetOemLed (825)=0 Then
'Code "G4 P5" 'Time to get to the z-plate
Code "G31Z-5 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 Z0.25" 'Change the Z retract height here
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
Else
Code "(Z-Plate is grounded, check connection and try again)"
Exit Sub
End If
End If
SetCurrentTool( tool )
End If
This is the M6 End Macro
'M6End.m1s
tool = GetDRO(24)
oldTool = GetOEMDRO(1212)
If getuserled(1000) Then ' check user led
'coolant was on
Code "M8"
End If
If (oldTool <> tool) Then
SetOEMDRO(1212,tool)
End If
Brett
Logged
If you could see the things I have in my head, you would be laughing too.
www.precisionchaos1.com
My guard dog is not what you need to worry about!
rickturner646
Active Member
Offline
Posts: 5
Re: Need help with manual toolchange macro
«
Reply #2 on:
June 06, 2008, 09:53:23 AM »
Ta Brett,
I'll start from there.
Rick
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Online
Posts: 770
Briceville, TN, USA
Re: Need help with manual toolchange macro
«
Reply #3 on:
June 06, 2008, 12:33:44 PM »
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
Logged
All things Mach3, Screens, Wizards, Plugins, Brians, complete control solutions for complex machines, Macros, ATC's, any kind of CNC machine build, retrofit or repair.
Pages:
1
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*e*i*n*g
=> Mach Screens
=> Feature Requests
=> Non English Forums
=> FAQs
===> Finished Plugins for Download
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> Lazy Cam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> dspMC/IP motion controller
=> Third party software and hardware support forums.
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Promote and discuss your product .
=> Sieg Machines
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
=> One on one phone support.
=> Forum suggestions and report forum problems.
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
Loading...