Hello Guest it is April 18, 2025, 07:39:08 PM

Author Topic: TOOL INFORMATION FROM GCODE TO MACH3  (Read 2096 times)

0 Members and 1 Guest are viewing this topic.

TOOL INFORMATION FROM GCODE TO MACH3
« on: February 14, 2025, 02:10:56 PM »
Good evening everyone,
Using the cam I insert information about the tools into the gcode such as tool number, cutter diameter and description.
I use a semi-automatic tool change in Mach3 in the sense that I go to manually change the cutter and during the m6 I go to probe the length and insert it into the tool table so that I can then subsequently recall the UT having the possibility of not performing the measurement probe.
This leads me to having to manually insert the cutter diameter and description into the tool table.
I would like to ask the community if anyone knows how to read these 2 pieces of information directly into the GCODE during the M6 ​​and write them automatically into the table, given that in any case these 2 pieces of information are always present in the programs that I make with the CAM
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #1 on: February 14, 2025, 04:42:35 PM »
Yes it can be done with a macro.  I do this on my lathe using a set of macros to probe a setter with a tool and write the values into the tool table. When I get into the workshop I'll remind myself how it's done.
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #2 on: February 14, 2025, 05:29:26 PM »
I have looked at my code and re-read your post and actually I'm not sure what you are asking.  There could be 2 approaches.

In one you have a T6 macro which, when a new tool is inserted, goes off to a tool setter of known height, probes it, lifts up to another known height and sets the Z DRO to that value.  The tool is now calibrated and you can carry on the job.  The tool table isn't needed at all in this approach since the tool is re-calibrated on each change.

Alternatively you could pre-calibrate all the tools provided you can guarantee they are always reinserted with the same projection.  So each tool would need its own holder.  The tool table is pre-populated with this data.  When you insert Tool No. N then you tell the machine which tool is being used and it will know the diameter and height from the table. 

My lathe uses the second approach.  The tools are held in QC holders that clamp precisely onto the toolpost.  I tell the machine what tool number is being used and it adjusts the offsets as needed to turn a precise diameter, and if needed a precise Z offset.

The tool table is populated by a macro which controls the probing process.  I'd be happy to share a copy but as it's for the lathe and depends on my own custom probing system it may not be quite what you need.  The key statements in it for you are:

Call SetToolParam(ToolNo, 3, X_pos)    'Writes X offset to tool table

This calls a Mach3 routine which writes a number "X_pos" to column 3 of the table in the row labelled ToolNo.  A similar statement is used for the Z offset but in a different column.

To share tool data between your CAM and M3 you will probably need to first export the CAM tool table into a suitable file format then write it into Mach3.  Unfortunately there isn't a "native" M3 tool to do that but there are macros written by people in this community which can import and export into/from Mach3.  Somewhere I have copies but can't lay my hands on them right now, will have a look tomorrow.
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #3 on: February 15, 2025, 02:13:52 AM »
thanks for the reply. I already do what you described. tool change etc etc... what I ask is if there is a way to export a data or a description from the gcode loaded in Mach3 and read it in a macro...
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #4 on: February 15, 2025, 02:39:19 AM »
for example
m6 t3 desc = 3-edge aluminium cutter toolDiam = 8
Make the tool change macro read an instruction like this
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #5 on: February 15, 2025, 04:59:01 AM »
Well I don't think there is even a way to encode the tool information (including length of course) in the G code. You would have to modify the G code interpreter to accept the extra data fields - and I don't think there is any way to do this.  It is expected in the design of the system that tool data is communicated via the tool table and is pre-defined before the G code is run.  I'm not really clear what you are trying to achieve in the way you operate?  If you just want a way to change the tool data for a given tool, or even add a new tool, then perhaps you could write a user-defined macro which you might call as "M<user-defined macro n.> but you can't add parameters; the the macro could ask for info such as tool number, length, diameter etc; or even initiate a measurement routine.  It all seems very convoluted, much better to follow the operating model that is implied by the "tool table" route.  So then in the command "M6 T3" the tool table carries the information in the third row.
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #6 on: February 15, 2025, 05:19:58 AM »
obviously I measure the length with the macro included in the tool change that automatically writes it in the table. What I want to do is not have to manually write the tool diameter and tool description in the table, since they are parameters that the gcode compiled by the cam already gives me... It seems like a good idea to have it written by the tool change macro.. but I don't know if it can be done :-)
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #7 on: February 15, 2025, 05:23:43 AM »
it could also be a new macro that reads a parameter created by me contained in the Gcode.. is it possible to do it??
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #8 on: February 15, 2025, 05:34:37 AM »
Well as I said there are macros around that can read and write to the tool table, so if you can export the tool table from your CAM in a suitable format it should be possible to use one of those to write the description and diameter values into the Mach3 tool table.  I will have another look, I have copies somewhere.
Re: TOOL INFORMATION FROM GCODE TO MACH3
« Reply #9 on: February 15, 2025, 05:54:11 AM »
You can find the import and export macros here:

https://www.machsupport.com/forum/index.php?action=dlattach;topic=46729.0;attach=57522

The zip file contains macros to reset the TT, export and import it.  Of course the TT includes the tool lengths which have to be measured for each tool, so it wouldn't be very straightforward, you would need to export the TT, open it in something like Excel (it's a semi-colon delimited text file), open the CAM TT also in Excel, copy the information you want to add across to the TT, save it as a semi-colon delimited text file, and import it back.   Alternatively of course just export the CAM TT to Excel, adjust the format to correspond to M3, export it to M3 and then add the tool length parameters using a suitable macro.  In principle there ought to be a standard format for tool information but if there is I'm not aware of it.