Want to add a simple Filament load and unload macro

I have a cr10 v1 that I have recently installed Klipper on. I used Mainsail to install Klipper and the example printer.cfg file from the github and all is good. I am getting really nice results with imporved speeds. I am assuming that Mainsail installs a very ‘basic’ Klipper install. I would like to add a Filament Load and Filament Unload macro to my mainsail dashboard screen.

My question is how do I do this? Can I just copy/paste any example Filament load/unload macro I find online into my printer.cfg file? Thanks for any help.

Any filament load macro should almost work, but you may need to tweak some of the values to suit your particular printer. It’s really worth learning some basic g-codes so that you can understand what the macro is doing, and then if you understand it, you can tweak it. Thankfully, g-codes are really easy, they are straightforward and unambiguous, As an example, here is the filament_load macro I use:

[gcode_macro FILAMENT_LOAD]
gcode:
 M83                   # Put the extruder into relative mode
 G92 E0.0              # Reset the extruder so that it thinks it is at position zero
 G1 E120 F350          # Move the extruder forward 120mm at a speed of 350mm/minute
 G92 E0.0              # Reset the extruder again
 M82                   # Put the extruder back into absolute mode.

A simple unload macro would just move the extruder in the opposite direction by using

G1 E-120 F350

Which would move the extruder in reverse for 120mm.

You may need to tweak this though. For example, if you have a bowden tube setup, you would likely need to move the extruder a much greater distance, say 500mm instead of 120mm. Also, a speed of 350mm/minute is really slow, so you may want to bump that up a bit.

Anyway, my point is that it is worth your time to learn a few g-codes. There are plenty of good references online, but if you want to find out what a particular g-code does, just google “Marlin M82” for example. And of course, if you are unsure, just post here.

Hope this helps

I was wondering if there is a way to add a temp check and if the temp isn’t high enough, it automatically raises the temp and once it reaches the correct temp, it continues with the filament load or unload? If anyone could make that happen, that would be awesome. I found a macro that would check but just give an error if the temp wasn’t high enough. Would be nice to have it actually raise the temp.

1 Like

Actually I just came across jschuh’s klipper macro and their unload and load filament macro does exactly what I was looking for. Plus many other useful macros.
https://github.com/jschuh/klipper-macros

Thanks for the link, I’m gonna spend some time going through all of that