Hello Guest it is July 15, 2025, 03:40:31 AM

Author Topic: ATC Build With Macros - Use it if you like  (Read 13400 times)

0 Members and 3 Guests are viewing this topic.

Re: ATC Build With Macros - Use it if you like
« Reply #10 on: January 22, 2025, 12:40:55 PM »
That is exactly what I added - The 2nd CSV file - What tool is loaded where.    Bascially the tool rack setup.   

The tool table in MACH holds the tool ids with the length offsets.
Re: ATC Build With Macros - Use it if you like
« Reply #11 on: January 22, 2025, 12:58:45 PM »
Gotcha.  So then your m6 uses the tool number from the PP to access the tool slot number.  Nice approach.

That may not be possible for me because my tool changing is spread out over a number of functions.  I think i use ‘current tool’ and ‘selected tool’ too much in sub functions to save the trouble of passing tool numbers.  Maybe not though.  I’ll investigate!
Re: ATC Build With Macros - Use it if you like
« Reply #12 on: January 22, 2025, 01:29:20 PM »
I just want to add a comment for clarification for other users that might read this -

PP (Post Processor) is loosely used but it refers to the CAM Software that generates the GCODE - The post processor's function is to convert the calculated tool paths to specific gcode for a specific implementation.    Not all CNC machines uses the same gcode - The post processor is the layer in-between.

Im sure if you just review your code, you would certainly optimize it a bit - All gets cleared once you have a good plan of how you want to do it.  What works for your workflow.  That is the beauty of MACH4 - Nobody is forced to do it a certain why -  I removed so many functions that I dont use because I like a clean simple smart interface. 
Re: ATC Build With Macros - Use it if you like
« Reply #13 on: January 23, 2025, 12:28:02 PM »
I think i can probably use this idea.  One question: does Mach4 copy the mc.mcToolSetData values into the tool table or just use them for the current gcode file/modal execution/whatever the "non persistent" lifetime is?   It looks like some of the values go into the tool table but the API doc doesn't say explicitly.

Before I go and make changes to my code, let me try to explain the "standard" tool change flow as I understand it and you can correct me:

-CAM SW needs to change to tool "3"
-PP passes this Change to tool 3 command to the G code as T3 M6
-When Mach4 reads the T3, the selectedTool becomes "3"
-The M6 macro uses the currentTool (mc.mcToolGetCurrent) and the new selectedTool (mc.mcToolGetSelected) to direct the tool changer

-Before the current tool is removed, the tool is measured and this value is saved somewhere temporarily
-Current tool is replaced
-New tool is grabbed
-New tool is measured using toolsetter, difference between old and new tool lengths is applied somehow
-Tool offset is changed or Z height is modified to accommodate new tool

-Cutting resumes


So there appear to be a couple of methods that I have seen people use to apply the difference between old and new tools.  Some scripts simply change the Z height immediately after measuring the tool so that the tool tip's Z height is the same as the previous tool.  Others
(I believe yours) use the tool height offset instead.

As I will be migrating to 5 axis as soon as I get my machine dialed in, I think the tool height offset (which is stored in the tool table?) is a better option.  The whole reason I have a toolchanger is because Mach4 can do 5 axis motion but not the 5 axis inverse kinematics necessary to recompute the toolpath for different tool length offsets, so I needed a way to have stable tool lengths that could be used in the 5 axis CAM and not need to be recalculated every time I change a tool.

Are there any "gotchas" about using the tool offset?  In my previous machines without tool changers I never used it.
Re: ATC Build With Macros - Use it if you like
« Reply #14 on: January 23, 2025, 01:10:05 PM »
5 Axis I have not touched -  I'm only assuming how it will work, based on what I know from the basic setups.  Regarding this:

-CAM SW needs to change to tool "3"
-PP passes this Change to tool 3 command to the G code as T3 M6 ( Remember your spindle stop as part of the PP - M05)
-When Mach4 reads the T3, the selectedTool becomes "3"
-The M6 macro uses the currentTool (mc.mcToolGetCurrent) and the new selectedTool (mc.mcToolGetSelected) to direct the tool changer


-Before the current tool is removed, the tool is measured, and this value is saved somewhere temporarily.    I dont see the need  to measure to tool afterwards - Is this a requirement for 5Axis?  Or just to make sure it is within spec? Not Broken?   I would much rather measure it before I start cutting ...

-Current tool is dropped - Offsets cleared -

-Selected tool is grabbed
 
-New tool is measured using tool setter, difference between old and new tool lengths is applied somehow.    - This is not correct -   Theory yes, practically no.   
The correct way to think is -  The Length offsets are clear - G49.   And the new tool offset is applied G43 H3.  You don't calculate differences.  This is done for you.  You only need to concern yourself with the length of each tool.

-Tool offset is changed, or Z height is modified to accommodate new tool..    I would advice to only use tool offsets - It removes the thinking and makes the process simple. 

I will take a moment and try to explain G43 and G49 a bit better - Just for future readers also.

Remember there are Machine Coordinates and Work System Coordinates -   G53 Machine -  G54 Work Coordiante System (WCS) as an example. 

Assume you have no tool loaded in the spindle, and you do a Z probe to get the top of the material.  The G54 Z position is set to 0 But the G53 position will be whatever to actually value of the machine is from HOME position.  Lets assume it is -100mm for this examples. 

Now - You load a tool into the Spindle - The tool length is 50mm.   IF you don't apply any offset, the tool will cut 50mm too deep.   When you apply to offset, the  G53 value will move up -50mm and the bottom of the tool will become Z0 on your G54 WCS.   

Once you've done the job and G49 is called - Offsets Cleared -  then suddenly the bottom of the spindle will be G54 Z0 again.  So on and So on.    When you load the next tool, the whole process repeats itself. 

The amazing thing about tool offsets is, the apply to probing also.  I can probe with a tool offset applied.  And if I remove the tool, and clear to offset - The spindle will once again be the Z0 G54 position.   

Re: ATC Build With Macros - Use it if you like
« Reply #15 on: January 24, 2025, 08:48:01 AM »
5 Axis I have not touched -  I'm only assuming how it will work, based on what I know from the basic setups.  Regarding this:

-CAM SW needs to change to tool "3"
-PP passes this Change to tool 3 command to the G code as T3 M6 ( Remember your spindle stop as part of the PP - M05)
-When Mach4 reads the T3, the selectedTool becomes "3"
-The M6 macro uses the currentTool (mc.mcToolGetCurrent) and the new selectedTool (mc.mcToolGetSelected) to direct the tool changer


-Before the current tool is removed, the tool is measured, and this value is saved somewhere temporarily.    I dont see the need  to measure to tool afterwards - Is this a requirement for 5Axis?  Or just to make sure it is within spec? Not Broken?   I would much rather measure it before I start cutting ... Not a 5 axis requirement to my knowledge, This flow originally came from manual tool changing I think when the script I was looking at didn't use offsets but instead calculated the difference.  Using offsets and maintaining an absolute reference is a much better approach.

-Current tool is dropped - Offsets cleared -

-Selected tool is grabbed
 
-New tool is measured using tool setter, difference between old and new tool lengths is applied somehow.    - This is not correct -   Theory yes, practically no.   
The correct way to think is -  The Length offsets are clear - G49.   And the new tool offset is applied G43 H3.  You don't calculate differences.  This is done for you.  You only need to concern yourself with the length of each tool.

Excellent.  This is a better way to think about it  I work in the semiconductor industry and the precision needed there is only possible through many many corrections to original absolute machine readbacks.  This fits better with my way of thinking :)

-Tool offset is changed, or Z height is modified to accommodate new tool..    I would advice to only use tool offsets - It removes the thinking and makes the process simple. 

I will take a moment and try to explain G43 and G49 a bit better - Just for future readers also.

Remember there are Machine Coordinates and Work System Coordinates -   G53 Machine -  G54 Work Coordiante System (WCS) as an example. 

Assume you have no tool loaded in the spindle, and you do a Z probe to get the top of the material.  The G54 Z position is set to 0 But the G53 position will be whatever to actually value of the machine is from HOME position.  Lets assume it is -100mm for this examples. 

Now - You load a tool into the Spindle - The tool length is 50mm.   IF you don't apply any offset, the tool will cut 50mm too deep.   When you apply to offset, the  G53 value will move up -50mm and the bottom of the tool will become Z0 on your G54 WCS.   

Once you've done the job and G49 is called - Offsets Cleared -  then suddenly the bottom of the spindle will be G54 Z0 again.  So on and So on.    When you load the next tool, the whole process repeats itself. 

The amazing thing about tool offsets is, the apply to probing also.  I can probe with a tool offset applied.  And if I remove the tool, and clear to offset - The spindle will once again be the Z0 G54 position.   

So I currently have upper and lower limit switches on my Z axis (again, lower is only necessary when in 5 axis mode when the spindle is effectively pointing sideways.  I currently use the upper limit switch as the home switch as well.  This puts 0 up at the top and the bed is something like -380mm.  I was considering configuring Mach4 to move the home switch to +380 (or whatever) so that I could more easily work in machine coordinates doing my configurations and jigs and things.  Is there any reason that I shouldn't use the master tool (a stainless stepped shaft I have loaded into a spare tool holder) to set the actual machine Z0 to the tool touching the table?  Purely to make checking my calculations and positions easier, I realize that it probably isn't necessary.

Maybe I have
Re: ATC Build With Macros - Use it if you like
« Reply #16 on: January 24, 2025, 11:48:08 AM »
I read a post once, or a video - I cant remember -  But the general idea is -  For standardization and good practice - Is to keep Home 0.  Always.  Doesn't matter if it is x,y,z.     And the regarding the z Axis,   I also tried it once to have the Bed zero - The problem is, the bed changes over time as you work.  This is not a good setup.  The Top does not where you put the home sensor.  I do think it is better just to keep Machine Coordinates G53 -ZHome 0 (Top) and work down from There into,  - values.  This makes sense when working simply because -  when you probe the material - for me that is - the top - When I see a Z -5 I know how deep I cut into the material.      Basically, It will not matter either way on your workflow, because you dont use G53 when you cut stuff - You work in G54 which is 0,0,0 to your workpiece.

Then regarding the master tool -  I'm open for input but I dont see the need, as this is an extra step for me that adds no value.  Because I can use any tool, which length is known, and offset applied to probe the Z.    I assume this will work the same in 5 axis, if you need to probe the side of material.  I dont know if it works that way.

Re: ATC Build With Macros - Use it if you like
« Reply #17 on: January 25, 2025, 01:28:17 PM »
I taught ChatGPT to understand how to write the lua for Mach 4 and I discovered that the "pocket #" entry in the tool table is actually meant to be the SLOT number of the auto tool changer.  We have re-implemented a feature already existing in Mach... here is what it said:

Re: ATC Build With Macros - Use it if you like
« Reply #18 on: January 25, 2025, 01:29:27 PM »
The **"Pocket #" (Pocket Number)** in the **Mach4 Tool Table** refers to the **physical slot** or **location** in the machine's **tool changer** where the tool is stored. This is commonly used for machines equipped with an **Automatic Tool Changer (ATC)** or a **tool carousel**.

---

### **How "Pocket #" Works**
1. **Tool Number vs. Pocket Number:**
   - **Tool Number**: A logical number assigned to each tool, which represents its identification in the tool table. For example, Tool #1 might be a 10mm end mill, and Tool #2 might be a 5mm drill.
   - **Pocket Number**: The physical location in the ATC or tool magazine where the tool is stored. For instance:
     - Tool #1 might be physically stored in Pocket #5.
     - Tool #2 might be physically stored in Pocket #3.

   This distinction is necessary for machines that decouple the logical tool numbering from the physical storage locations.

2. **Why Pocket Numbers Are Important:**
   - They allow the machine to know **where to find the tool** during an `M6` tool change.
   - The machine can swap tools efficiently by mapping the **logical tool number** to the correct **physical pocket**.

3. **ATC Workflow:**
   - When the machine executes a tool change (e.g., `T1 M6`):
     1. It looks up the **Pocket #** associated with Tool #1 in the tool table.
     2. It retrieves the tool from that pocket in the tool changer.
     3. The tool is loaded into the spindle.

---

### **Example Tool Table**
| **Tool #** | **Description**   | **Diameter** | **Pocket #** |
|------------|-------------------|--------------|--------------|
| 1          | 10mm End Mill     | 10.0         | 5            |
| 2          | 5mm Drill         | 5.0          | 3            |
| 3          | 6mm Ball Nose     | 6.0          | 1            |

- **Scenario:**
   - When `T1 M6` is executed, the machine looks for **Tool #1** and retrieves it from **Pocket #5**.
   - When `T2 M6` is executed, it retrieves **Tool #2** from **Pocket #3**.

---

### **Pocket Numbers on Manual Machines**
For machines **without an ATC**:
- The "Pocket #" might not be relevant, as the operator manually loads the tools. However, some operators use the Pocket # field to define storage locations (e.g., tool racks or cabinets).

---

### **Configuring Pocket Numbers**
In Mach4, the Pocket # field can be edited in the **Tool Table**:
1. Open the Tool Table via the Mach4 menu or screen.
2. Find the "Pocket #" column for each tool.
3. Enter the correct pocket number corresponding to your machine's ATC.

---

### **Key Points:**
- **Pocket # is essential** for machines with an ATC to ensure proper tool management.
- If your machine doesn't have an ATC, the Pocket # can be left blank or used for operator notes.

Let me know if you'd like help configuring your tool table or understanding tool changer workflows!
Re: ATC Build With Macros - Use it if you like
« Reply #19 on: January 25, 2025, 01:30:49 PM »
Now I'm curious to see how to use the built-in functionality!  I'll investigate and report back :)