[4]

Tool Change Macro

[3]
[10] Like what you see?
Click here to donate to this forum and upgrade your account!

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#1
I've searched the net looking for info on how to tell my CNC mill to move to a safe tool change position. Going in I thought it would be easy but I found out that most of what I found was either incomplete or I needed a doctorate in computer programming to get what I needed.

I did find the following macro language that the author swears works as intended but no further explanation. It didn't work for me.

Code("G53G0Z3.5")
While IsMoving()
Sleep 100
Wend
Code("G53G0X48Y0")
While IsMoving()
Sleep 100
Wend

I copied this into Mach3/macros/"My Mill Profile"/M6Start.m1s. Should it go in the "End" macro instead? Is there a flaw in the macro itself? Is it me assuming this is M6 macro language? Maybe it's button script?

Thank you in advance and looking forward to your responses.
 

Boswell

Hobby Machinist since 2010
H-M Platinum Supporter ($50)
Joined
Feb 27, 2014
Messages
649
Likes
296
#2
I am in no way an expert in Gcode but I do have some programing background although I have never created a macro for Mach3, never needed to.
Some simple observations
1. This looks like it does two things when called
a) Cancles any work offsets, note that it does not put turn any work offsets back on when finished)
b) Moves to Z 3.5, X48 and Y0

2. I would expect that you would need to put this in some place that it would be called when you need to do a tool change. Putting it at the startup or end of some other process does not make sense to me but I may not understand how macros are called in Mach3
3. In order for any tool change process to move the spindle to a specific place it you MUST HOME the mill each time you use it. This way the G53 makes sure that the moves given are relative to the HOME Position and not the zero of the part you are working on. You must re-enable the Part offset or else the next moves will also be relative to the HOME and not the part with possibly disastrous results.
4. I was able to tell MACH3 to always go to Z5 for tool changes without using a macro. Now of course I don't home my mill and so this is Z6 relative to the Part Zero that I am working on. If I am working on a very tall part it could be too high and trip the Z Limit switch.

Some things to think about.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#3
I am in no way an expert in Gcode but I do have some programing background although I have never created a macro for Mach3, never needed to.
Some simple observations
1. This looks like it does two things when called
a) Cancles any work offsets, note that it does not put turn any work offsets back on when finished)
b) Moves to Z 3.5, X48 and Y0

2. I would expect that you would need to put this in some place that it would be called when you need to do a tool change. Putting it at the startup or end of some other process does not make sense to me but I may not understand how macros are called in Mach3
3. In order for any tool change process to move the spindle to a specific place it you MUST HOME the mill each time you use it. This way the G53 makes sure that the moves given are relative to the HOME Position and not the zero of the part you are working on. You must re-enable the Part offset or else the next moves will also be relative to the HOME and not the part with possibly disastrous results.
4. I was able to tell MACH3 to always go to Z5 for tool changes without using a macro. Now of course I don't home my mill and so this is Z6 relative to the Part Zero that I am working on. If I am working on a very tall part it could be too high and trip the Z Limit switch.

Some things to think about.
Thanks for your comments. I am no gcode expert either. I understand the Z, X and Y moves (I changed the numbers to reflect my mill run in inches) in the macro but I don't see or understand where it cancels work offsets. G53 moves the axis relative to machine coordinates, this I understand. I do Home my machine on startup. So how to I re-enable work offsets?

Maybe I'm over-thinking this and there is a more simple way to accomplish the same thing. What did you do to get Mach3 to go to Z5 without a macro?
 

Boswell

Hobby Machinist since 2010
H-M Platinum Supporter ($50)
Joined
Feb 27, 2014
Messages
649
Likes
296
#4
I have to go and look at my mach3 setup later when I can get to it. but it was some sort of setting in mach 3 I thought.
 

Boswell

Hobby Machinist since 2010
H-M Platinum Supporter ($50)
Joined
Feb 27, 2014
Messages
649
Likes
296
#5
Sorry been busy. Your other question about the G53. I this is what I would call a state command. It changes the coordinate system to the machine coordinates by canceling work offsets. Once this state is changed I would expect it to stay changed until explicitly changed to something else. but I may have this wrong. Hopefully someone with more GCode experience can comment
 

RJSakowski

H-M Supporter - Gold Member
H-M Supporter - Gold Member ($25)
Joined
Feb 1, 2015
Messages
3,572
Likes
4,121
#6
I've searched the net looking for info on how to tell my CNC mill to move to a safe tool change position. Going in I thought it would be easy but I found out that most of what I found was either incomplete or I needed a doctorate in computer programming to get what I needed.

I did find the following macro language that the author swears works as intended but no further explanation. It didn't work for me.

Code("G53G0Z3.5")
While IsMoving()
Sleep 100
Wend
Code("G53G0X48Y0")
While IsMoving()
Sleep 100
Wend

I copied this into Mach3/macros/"My Mill Profile"/M6Start.m1s. Should it go in the "End" macro instead? Is there a flaw in the macro itself? Is it me assuming this is M6 macro language? Maybe it's button script?

Thank you in advance and looking forward to your responses.
The Tormach flavor of Mach 3 had a macro, M998 that moved upward to a tool change position. I believe that post #6 in the following is the content of that macro.
https://forums.autodesk.com/t5/hsm-post-processor-forum/m998-tool-change-position-mach3/td-p/6088733
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#7
The Tormach flavor of Mach 3 had a macro, M998 that moved upward to a tool change position. I believe that post #6 in the following is the content of that macro.
https://forums.autodesk.com/t5/hsm-post-processor-forum/m998-tool-change-position-mach3/td-p/6088733
Thanks for pointing me to the macro. I know virtually nothing about computer language. Where do I put the macro language? In the Mach3 macro folder? In the Mach3 post processor? It frustrates me that Mach3 has a Tool Change Location feature on the Settings page but no language to make that feature operable.
 

RJSakowski

H-M Supporter - Gold Member
H-M Supporter - Gold Member ($25)
Joined
Feb 1, 2015
Messages
3,572
Likes
4,121
#8
It is in the macro folder in a sub folder named PCNC770. I'm not sure wher it would be in the standard Mach 3 version. It should do no harm if it is in the wrong folder. It just won't run.
 

JimDawson

Global Moderator
Staff member
H-M Platinum Supporter ($50)
Joined
Feb 8, 2014
Messages
7,142
Likes
5,393
#9
I do Home my machine on startup. So how to I re-enable work offsets?

You revert the the work offset with a G54, with no arguments, after the tool change. I'm surprised that Mach3 doesn't automatically go the G53 location when called without a macro.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#10
It is in the macro folder in a sub folder named PCNC770. I'm not sure wher it would be in the standard Mach 3 version. It should do no harm if it is in the wrong folder. It just won't run.
Thanks RJ. I'll try it tomorrow.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#11
You revert the the work offset with a G54, with no arguments, after the tool change. I'm surprised that Mach3 doesn't automatically go the G53 location when called without a macro.
Thanks Jim. I've tried a couple of macros I found on-line but couldn't get them to work. I'm going to try the one RJ suggested. Hopefully that will work.

After reading a lot about tool change position someone mentioned using G28 and modifying it's parameters to position the spindle where you want it for a tool change. I use CamBam, as you do, but don't see where to add it to the Mach3 post processor. Is this an option? If it is, can you point me to where I can find script language?

Thanks
 

JimDawson

Global Moderator
Staff member
H-M Platinum Supporter ($50)
Joined
Feb 8, 2014
Messages
7,142
Likes
5,393
#12
In CamBam scroll down to the bottom of the post processor edit selections, the last section is Tools, Tool Change. You could edit that to produce any code you want. You could insert a G28 command in there.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#13
I found quite a bit of info on a couple of other machining forums, including specific computer language, but none of it worked. I've got a few paying jobs lined up so I'm going to step away from this for a while. Thanks everyone for your help.
 

stuartw

H-M Supporter - Sustaining Member
H-M Platinum Supporter ($50)
Joined
Jun 17, 2018
Messages
39
Likes
20
#14
you shouldn't need to do anything complicated. I remember editing the m6 tool change macro which is empty by default. I am in the process of moving to mach4 but if you think it would help, I can try and dig out the m6 macro code I was using.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#15
you shouldn't need to do anything complicated. I remember editing the m6 tool change macro which is empty by default. I am in the process of moving to mach4 but if you think it would help, I can try and dig out the m6 macro code I was using.
Some of the info I've found says you can only set the tool change location by editing the M6 macro language yet there are others that offer up post processor language changes. Not sure how to make sense of this. If you have macro language that has worked I'll gladly give it a try. Thanks.
 

stuartw

H-M Supporter - Sustaining Member
H-M Platinum Supporter ($50)
Joined
Jun 17, 2018
Messages
39
Likes
20
#16
Here are the two macros I remember editing. I got this code off the internet somewhere, it's not mine but I may have modified it. The script should take care of any tool offsets you have set. I am sure I did not modify the post processor to make this work.

One other point worth mentioning, use caution if you're editing the post processor and the macros. things like having Z safe and other move operations in both places can cause movement that's unexpected.

So my suggestion is if you're modifying the macro do not modify the post processor & I think the macro is probably the place you should make this change.

sorry, one other thing. I found the yt videos that finally helped me make sense of it. I would add it here but I remember seeing a post about not posting yt videos, feel free to pm me and I will send you the links.
 

Attachments

Last edited:

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#17
Here are the two macros I remember editing. I got this code off the internet somewhere, it's not mine but I may have modified it. The script should take care of any tool offsets you have set. I am sure I did not modify the post processor to make this work.

One other point worth mentioning, use caution if you're editing the post processor and the macros. things like having Z safe and other move operations in both places can cause movement that's unexpected.

So my suggestion is if you're modifying the macro do not modify the post processor & I think the macro is probably the place you should make this change.

sorry, one other thing. I found the yt videos that finally helped me make sense of it. I would add it here but I remember seeing a post about not posting yt videos, feel free to pm me and I will send you the links.
Thanks I'll give it a try tomorrow.
 

Boswell

Hobby Machinist since 2010
H-M Platinum Supporter ($50)
Joined
Feb 27, 2014
Messages
649
Likes
296
#18
Well, I thought it was a Mach3 setting I used, but when I looked into it, I had made the change in the post-Processor for the CAM system I use (Bobcad). This has worked well for me.
 

TomS

Active User
H-M Supporter - Gold Member ($25)
Joined
May 20, 2013
Messages
1,780
Likes
731
#19
Well, I thought it was a Mach3 setting I used, but when I looked into it, I had made the change in the post-Processor for the CAM system I use (Bobcad). This has worked well for me.
Thanks. I tried modifying my post processor and the M6 macro. Tried some new macro language today and still haven't found anything that works. I've got one job in a holding pattern and two waiting. I'll come back to this later.
 

stuartw

H-M Supporter - Sustaining Member
H-M Platinum Supporter ($50)
Joined
Jun 17, 2018
Messages
39
Likes
20
#20
Well, I thought it was a Mach3 setting I used, but when I looked into it, I had made the change in the post-Processor for the CAM system I use (Bobcad). This has worked well for me.
I thought about doing it this way, but I like being able to walk up to the machine and issue gcode into the midi screen to do simple operations without bothering to setup the job in cam first. Either approach is fine though depending on what you want to do.
 
[6]
[5] [7]
Top