Artisan CNC Tool Change G-Code

Unsatisfied with the cumbersome nature of other people’s tool change workflows, I ventured to fix as much as I could with software. Formally, I’m requesting a list of Gcode commands available in the snapmaker.cps (Marlin) post processor for Fusion 360. Here’s why:

For my current example, I have a program that requires 2 tool changes.
Screenshot 2023-04-19 at 14.16.37

Rather than manually run 3 sets of gcode, when it’s time to change a tool, I’d like Artisan to

  1. pause the program
  2. move the tool head either up or home
  3. run the bit assistant
  4. resume at the correct point in space

Fusion allows you to add particular manual NC steps in-between your paths (red in the picture above). The available steps are a very truncated list of all the G and M-codes available in totem. To further limit options, if one of those manual steps is not supported by the post-processor (snapmaker.cps), it will simply ignore that step when creating the G-code.

My plan of attack was to add a manual stop and a manual prompt before each tool change, and see what happened. Well, the stop worked - it created an M0 (which is technically a pause). However, the Tool Change command was ignored entirely.

Screenshot 2023-04-19 at 14.35.06

//
For context, this example is only a portion of the total program. The full program requires me to reorient the part twice more, each reorientation with its own set of tool changes. In total, with all tool changes and reorientations, I’d have to run 8 separate programs. That’s too much babysitting. So, can @xchrisd or someone similarly well-versed help clarify what gcode commands it would take to add a mid-program tool change?

I am a member like you and no snapmaker staff.
I am not so exerienced with cnc also. Never did a toolchange while in a cnc process, i carved it in multiple gcodes.

I would suggest to request this feature by email to support, you should also request M600 for 3d printing which maybe could your solving command in cnc also (it simply does the same, if its true).

One more have a look at this and maybe you are able to find here further information or a new postprocessor :wink:

Sorry i see you did your way there, so its just for pointing out.

Maybe @Tracy could pick the request of cnc-toolchange up?

Oh sheesh haha, sorry. Thought you were on the Snapmaker team. Thanks for your help regardless.

If I don’t get any response I’ll make it a support ticket, but I want this info to be public, so I was hoping a dev could point me to some resource I haven’t found where they list the codes.

Would also be interested in a solution. In the Artisan there is a menu on the display “Bit Assistant” which should help. But has completely shifted the zero point with me.

So far I make individual NC programs and when changing tools, I remove the tool, command with luban go to workpiece zero point then I move the Z-axis 100mm up, clamp the new tool and zero the Z-axis with the new tool again.

While I do not have an Artisan, I would assume the setup is similar to the 2.0. I’ve written a guide on repeatable origins and bit swapping found here:

However, I HAVE had an idea on a way to semi-automate it, just haven’t gotten around to it. Basically involves custom tool change commands. i.e. where a traditional CNC usually calls a toolchange with say “T1 D1” (tool 1, diameter/height 1) and the machine interprets it to grab tool 1 from the toolchanger and assign the saved length value. The snapmaker would require moving up and out to a safe distance, pausing so you can remove the current tool and soft-load (don’t tighten down the collet nut), then press resume. It would then go back to a designated point (something repeatable like the bed, similar to my guide) and gently come down and push the new bit into position and stop again, letting you tighten the nut and thus, setting the tool at the exact height the other was. Afterwards it would move back up to a safe distance, then continue operation.

The main problem being the snapmaker runs on Marlin instead of a standardized CNC platform, so program pause and option stop (M00 and M01 respectively) are not recognized, and thus ignored. However, they do list M76 and M25 (which according to their documentation is M76 in a trench coat), which are apparently pauses.

I’ll try some playing around and see what I can come up with. If I find a viable solution, I’ll likely write a new guide on it. Sadly, this is still all speculation, as again, I don’t have an Artisan to play with. It could very well not be on Marlin anymore.

1 Like

Ew. Snapmaker’s insistence on dumbing things down hinders power users. :frowning: The pause function always moves the toolhead straight up and turns off the spindle, then resuming ALWAYS turns the spindle back on (even if you put an M5 before the pause) and brings it back down to where it was. So there’s a bit of stupid trickery to make this work.

First off, the tool change code (it’s so stupid… so so stupid…) Everything is commented what the line is for/does.

M3 P0 ; Change spindle speed to 0, since it WILL come back on, basically an M5
G55 ; Workspace 2 for storing our current position.
G92 X0 Y0 Z0 ; Set current position as origin on workspace 2
M76 ; Pause gcode, brings it to the top and waits. PULL BIT HERE, insert new bit into collet LOOSE so it can move around.
M5 ; Safety M5 to make sure the spindle is off after pause.
G0 Z100 ; Safety retract, modify to suit your needs, distance is above the current position.
G53 ; Change to machine coords for bit 'measuring'
G0 X20 Y20 ; Location of your reference point in machine coords, modify for needs.
G0 Z50 ; Move down a safe distance over your point
G0 Z30 F100 ; Slow down to move to final point, this is the height you should have setup your first bit, it will push the new bit to the same height as the old one.
G4 S5 ; Dwell for you to tighten the bit, set at maybe S30 for 30 seconds.
G55 ; Back to work 2
G0 Z100 F9000 ; back to safety distance
M3 P100 ; Spindle back on
G4 S2 ; Dwell for spindle to speed up
G0 X0 Y0 ; Move back to the original position we stopped at in X/Y
G0 Z0 ; Back down
G54 ; Finally back to work coords 1 to continue where we left off.

For this to work, designate a safe area, preferably so you can touch the waste board as a non-changing reference. When inserting your first bit, do it loosely so jogging down pushes it in a little, then tighten the nut. Write down the Machine Coords from the touchscreen, this is the location you’ll need for the G53 section above to make all other bits the same exact length. This does require all your bits to be roughly the same length overall.

This should work no matter if you start it in Luban or the touchscreen, as machine coords do not change, they’re based on the homing switches. The G54 work coords (origin) is never touched in the process.

I’ve done a quick video on the movement associated with this, the entire gcode ran is in the video description. Keep in mind when it goes back up is when you pull your current bit, and loosely put in the new one, and when it goes to the corner is when it’s seating the new one and there’s a 5 second pause to tighten (increase this duration). Then it moves back up, starts the spindle, and goes back to position to finish. It’s just a straight line across the build plate… ignore the fact it’s the laser bed and there’s no tool, this was demonstration only.

EDIT: Please be careful when it comes back down after resuming the pause… :confused: stupid thing. The only other option would be set the location (the G55 block), then move up a safe distance and use a G4 dwell, but this is unsafe as it might begin moving before you get the tool changed. Needs a proper pause/resume.

Also to resume after the M76, you either have to use Luban to resume, or send the command via commandline. I’ve made a .bat for mine with the contents;

@echo on
curl -X POST "http://[IP HERE]:8080/api/v1/connect?token=[TOKEN HERE]"
curl -X GET "http://[IP HERE]:8080/api/v1/status?token=[TOKEN HERE]&167430879684"
curl -X POST "http://[IP HERE]:8080/api/v1/resume_print?token=[TOKEN HERE]"

For more info on using the above code, check my drag/drop guide in the 2.0 forum. Simply running the .bat will make it continue.

EDIT2: Confirmed, if ran from the touchscreen, you get a resume button on the touchscreen, so that’s likely the best way to run it. Again, this is all speculation with the assumption that the Artisan does still use Marlin. :upside_down_face: Try at your own peril.

1 Like

Wow. This is chocked full of helpful information. FYI, I’d read your guide before I posted this - it helped get me as far as I did - thank you. Unfortunately, I will tell you high-level that the pre-requisites for this solution won’t work for me, but certain points might get me there.

First, my bits won’t all be similar length. Second, creating and running extra NCs adds about 5 minutes to the process - managing code that automates tool changes outweighs the time savings for me. Knowing this, I’m looking for a more general solution for a tool change. I’d be satisfied (for now) having gcode that will pause the program and call the bit assistant.

Pause. Artisan does run on Marlin - I haven’t deep dove into that so knowing that M0/1 don’t work is very helpful. However, you said:

However, they do list M76 and M25 (which according to their documentation is M76 in a trench coat), which are apparently pauses.

Where is their documentation? That’s part of my main problem. When I try to insert M76 or M25 into the code using Fusion’s manual NC options (mentioned earlier), the post-processor ignores it. I’ve tried Action, Pass through, and Call program. Ironically, comment does insert whatever I say, but obviously it adds a semi-colon.

Bit assistant. Obviously, the proprietary bit assistant doesn’t have a gcode assigned to it, however, I was hoping to use either Pass through or Call program to add code that would trigger Artisan to run the bit assistant. Now I’m no software engineer, so I have no idea what language or steps need to be taken to get Artisan to run the bit assistant program in the middle of an active program, but it seems like it wouldn’t take much doing.

Their gcode reference can be found here;
https://snapmaker.github.io/Documentation/gcode/G000-G001

You can modify the post-processor in Fusion360 for tool changes, or you could add comments like you’ve been doing, and follow it up with a quick find/replace all in something like Notepad++. Say, make a comment M76, which naturally spits out ; M76, but do a search and replace (Ctrl-H) inputting ; M76 in the find box, and M76 in the replace box, then Alt-A to replace all (or the button). This becomes second nature and stupid fast once you get used to it. :upside_down_face:

However, this doesn’t fix the need to either;
A: Ensure the bits are the same exact length below the spindle; or
B: Modify the Z origin for the new bit length.

The official way of using it (introduced with the 2.0 Rotary module) was to run it after each file finishes.

1 Like

Filing this under “future rabbit holes”