Gcode: Where is M6 - Tool change?

I’m pulling my hair out, what is left of it. There are some great posts in here about dealing with tool changes, or splitting the gcode into multiple files to accomodate different tools. I’m sorry if I just can’t find the right thread, but each post I read refers to the M6 command, like this one:

I’m on the most recent firmware, in the ‘tool-change’ field of my controller, I have the new code to raise the bit, change the bit, probe for z, and resume…

However,

I’m using Carbide Create Pro, trying to do Advanced VCarves, and in all the gcode I export, it does not use M6, a tool change is written like this: with M0 ;T302 as the tool change prompt, but nowhere in the code is M6 written, and so the ‘tool-change’ code is never run. Like this:

X0.1258
Z0.5000
(Advanced…)
M0 ;T302
S20000
G0X0.0478Y0.0367
G1Z-0.0500F12.0
X0.1869Y0.6574F45.0

I know the T302 is just the tool number, but I don’t know how to change the code so the firmware will recognize to run a different set of commands.

I’ve exported (Post Processor) from Carbide Create as Basic and as GRBL, I can’t find any difference, and both use T rather than M6.

I’m I just missing the point completely? Any help on how to adjust the code or the ‘tool-change’ option in the settings?

Many thanks

Hey Tyson,

from what I know there will no effect by a T command unless a M6 command is encountered.

However in Carbide3D → Software FAQList of supported gcodes, it says:

M6 — Tool change — this is implemented in Carbide Motion to facilitate the Nomad tool length sensor for changing tools

where it says:

Carbide Motion is only available for the Nomad and Shapeoko CNC machines

Maybe it is not supported?

Thanks!

Could be that it is not supported… any chance you (or anyone) knows if there is a code snippet I could swap out? The tool change - T command is easy to find, could it be exchanged with a comparable M6 code?

Hey Tyson,

if you manage to insert a M6 command into your g-code program, then the code you previously entered into the ‘tool-change’ field in the General Configuration Tab of the Onefinity Controller will be executed.

Regarding what to insert there, I cited some information here the other day.

I don’t have any experience with the Carbide 3D products, but they have a forum. Maybe you ask there if there is a way to activate M6 commands in the g-code output?

Thanks @Aiph5u

Ya, I’ll head over there shortly, I found the code snippets here first, so thought I’d start here. I didn’t mean to call you out directly by quoting your earlier post, but it was a good example, so thanks for that.

I did wander over to the Carbide Create forums, but thankfully a bit of trial and error showed that it’s a simple code swap. In code like I shared above, replace:

M0 ;T302

with

M6 T302

(302 is just the tool number, so it will vary based on the bit you’ve specified) So ya, swap the M0 for M6 and remove the semi-colon. I’m guessing this is obvious for someone who knows gcode.

As referenced, I think it’s also helpful to add one line to the default tool-changer macro to raise the router higher, as explained in this thread:

G0Z100

Hey Tyson,

yes this was already clear, but you did not find an option in the Carbide Create program on how to enable M6 being inserted by the program?

No luck or responses over in those forums, and once I posted my found solution, the thread was closed by an admin.

Hey Tyson,

Aw.

I wouldn’t consider having to edit every g-code file manually really a solution. Maybe you should not have posted your “solution”. Now the question if there is a way to enable M6 commands being inserted into the g-code output by Carbide Create remains unanswered.

1 Like

Hi,
Mac user here running Carbide Create Pro. I too have struggled with handling GCode files for Advanced VCarves. I know there was a Website shared that would separate the files. I don’t have Web access in my shop, so wrote a quick Python script to split an AVC file:

= = = = = =

import sys
print sys.argv[1]
origFile = sys.argv[1]

fd = open(origFile, “r”)
lines = fd.readlines();
fd.close()

clearingName = origFile[0:-3] + “_125_clearing.nc”
f1 = open(clearingName, “w”)
vcarveName = origFile[0:-3] + “_60_vbit.nc”
f2 = open(vcarveName, “w”)

activeFile = “both”
for line in lines:
if line[0:4] == “M0 ;”:
if activeFile == “both”:
activeFile = “one”
elif activeFile == “one”:
f1.write(“M05\n”)
f1.write(“M02\n”)
f1.close()
activeFile = “two”
if activeFile == “both”:
f1.write(line)
f2.write(line)
if activeFile == “one”:
f1.write (line)
if activeFile == “two”:
f2.write(line)

f2.close()

= = = = = =

Named it avc_split.py – put a little script (called avc) in my GCode directory to save some typing:

python avc_split.py $1

Just pass the combined AVC toolpath file … it will split it into two files for the clearing and VCarve portions. Since I typically use a 1/8" clearing bit and 60 degree V bit, I put those in the file names. Obviously, you can modify the script for your situation.

Dave

Sorry … didn’t realize the tabs would get eliminated. Have substituted blanks for tabs to properly show the indentation:

import sys
print sys.argv[1]
origFile = sys.argv[1]

fd = open(origFile, “r”)
lines = fd.readlines();
fd.close()

clearingName = origFile[0:-3] + “_125_clearing.nc”
f1 = open(clearingName, “w”)
vcarveName = origFile[0:-3] + “_60_vbit.nc”
f2 = open(vcarveName, “w”)

activeFile = “both”
for line in lines:
if line[0:4] == “M0 ;”:
if activeFile == “both”:
activeFile = “one”
elif activeFile == “one”:
f1.write(“M05\n”)
f1.write(“M02\n”)
f1.close()
activeFile = “two”
if activeFile == “both”:
f1.write(line)
f2.write(line)
if activeFile == “one”:
f1.write (line)
if activeFile == “two”:
f2.write(line)

f2.close()

Hey Dave,

this discourse.org forum uses Markdown markup language.

Since when writing python, reproduction of whitespace indentation is mandatory, you might be interested in this:

import sys
print sys.argv[1]
origFile = sys.argv[1]

fd = open(origFile, "r")
lines = fd.readlines();
fd.close()

clearingName = origFile[0:-3] + "_125_clearing.nc"
f1 = open(clearingName, "w")
vcarveName = origFile[0:-3] + "_60_vbit.nc"
f2 = open(vcarveName, "w")

activeFile = "both"
for line in lines:
        if line[0:4] == "M0 ;":
        if activeFile == "both":
            activeFile = "one"
        elif activeFile == "one":
            f1.write("M05\n")
            f1.write("M02\n")
            f1.close()
            activeFile = "two"
    if activeFile == "both":
        f1.write(line)
        f2.write(line)
    if activeFile == "one":
        f1.write (line)
    if activeFile == "two":
        f2.write(line)

f2.close()

@Aiph5u – Thanks for the heads up!