Hello Guest it is April 19, 2024, 04:35:13 AM

Author Topic: Tool Length Offset Macro Program  (Read 5135 times)

0 Members and 1 Guest are viewing this topic.

Re: Tool Length Offset Macro Program
« Reply #10 on: May 15, 2021, 05:34:02 PM »
GREAT! SEEMS TO WORK PERFECT!
Just need to figure out how to call the subroutine during the m6 script
Re: Tool Length Offset Macro Program
« Reply #11 on: May 23, 2021, 09:12:57 AM »
I have seen A LOT of people asking about a tool length offset macro.
I made this Macro Program (G Code) for my tool length offsets. 

This is not a Macro in the sense of Mach4 Macros.  This is a Macro B Program.  It is G Code.

Put the 9001 and 9002 programs in the Subroutines folder in the Mach4 Directory.
Put two buttons on the screen to probe the tool length offset and to probe a rotating tool.  One or both, you do you.
Put the attached scripts into the appropriate button script.
This will probe the current tool that is active in Mach4. 

This Macro Program will set the tool offsets at a Machine Position.  So homing the Z Axis is a must for this to work well for you.
This will set every tool to the same position (your tool setter).  So you can (and need to) set your Z Work Offset with any tool that has been touched off.
You MUST have your Tool Height Offset active when you set your Z Work Offset. 
You MUST have your Tool Height Offset active when you set your Z Work Offset.
You MUST have your Tool Height Offset active when you set your Z Work Offset.

The rotating tool probe will use the diameter value in the tool table.  So be sure to put something in there if you intend to use that one. 
It will offset half of the diameter and rotate CCW and probe slow.  This is for tools tool large for the tool setter (exp:  Face Mills)

You will see variables inside the code that you will need to change for yourself.
Tool Setter X and Y positions. 
Feedrate for fast probe and slow probe.
Lift Height after fast probe.
ETC.....
Just be sure to adjust to your own needs. 

I also use G31 instead of G28 so I be sure you have something 0.000 in #5183 (I think it's #5183) so it will go to Z Home; or change it to G28, or take it out and make sure you put a safe Z in there first.

USE AT YOUR OWN RISK. 
I am using Mach4 Hobby so I'm not able to do conditions in the Macro Program for safety checks. 
Check the macro manually first.  Get it set up, hit the probe button and press the tool setter manually and be sure everything works.
As always when using CNC Machines, be safe and diligent.   
How do you call this subroutine in an m6?
Re: Tool Length Offset Macro Program
« Reply #12 on: May 24, 2021, 11:52:25 AM »
Put this line in your M6.  rc = mc.mcCntlGcodeExecuteWait(inst, "M98 P9001")

This works stepping through the zero brane editor and from G Code; but for some reason it doesn't work when you call it from MDI.
So....When you call an M6 from MDI.... just be sure it acts like it is supposed to.   Otherwise just make a program and call toolchanges.

Maybe Steve can give insight as to why it isn't working in MDI.
Chad Byrd
Re: Tool Length Offset Macro Program
« Reply #13 on: June 15, 2021, 06:35:44 PM »
Thanks for the macro program Chad!

Everything seems to work for me except it doesn't save the new tool length in the tool table. Also, the rotating macro isn't picking up the tool diameter from the tool table.

In the macro, the code below is used to save the tool's offset. Is there something here I need to change to make it work for my machine?

Code: [Select]
(Set the current tool's offset in the tool table.)
/#[11000 + #2029] = #5073

Kenny
Re: Tool Length Offset Macro Program
« Reply #14 on: June 15, 2021, 06:38:48 PM »
It should save the tool length in the tool table. It does for me anyway.
I can watch it change when I probe a tool. Also, it picks up the diameter for me as well.
Not sure if it is a version thing or not. I’m not at the shop so I can’t check the machines to see what version. But I know one is on build 4300.
Chad Byrd
Re: Tool Length Offset Macro Program
« Reply #15 on: June 15, 2021, 06:41:50 PM »
Chad, Where do the variables from the macro come from?  Is there a list available somewhere?

Kenny
Re: Tool Length Offset Macro Program
« Reply #16 on: June 15, 2021, 06:59:29 PM »
Kenny,
mach4 emulates a fanuc 24i if I recall correctly.
So I just looked up fanuc macro variables and found some.
I also did a lot of playing around with ranges in the register and found the numbers pop up for the tool length offset haha.
Chad Byrd
Re: Tool Length Offset Macro Program
« Reply #17 on: June 16, 2021, 08:16:03 AM »
Kenny,
Artsoft added a lot of variables to the programming manuals as well.
Chad Byrd
Re: Tool Length Offset Macro Program
« Reply #18 on: June 16, 2021, 09:37:27 AM »
I did look at the programming manual. I don't see any reference to which variables to use to retrieve or enter values in the tool table.

Where does the 11000 come from in the line below?  #2029 is the current tool and #5073 is the value for the tool length measured from G31.

Code: [Select]
/#[11000 + #2029] = #5073

BTW, I'm actually using G31.1 for my tool setter. I have my work Z probe on G31 (G31.0). Not sure if that changes the #5073 from above.

Kenny
Re: Tool Length Offset Macro Program
« Reply #19 on: June 16, 2021, 09:51:25 AM »
I suppose that’s what you’ll have to use for G31.1 the 5073.
Also, the manual on the website isn’t correct. I just checked.
You’ll need to look in your mach4 directory under docs.
It has a current programming manual.
Chad Byrd