Feature request: M302 support

Hi. I think it’ll be useful to have M302: Allow cold extrudes support. It will be used for filament load and unload to not need to preheat the filament, but still watching for too low temperature during normal printing.

Rn you could just set the min extrude temp to something like 10°, restart, do whatever you need and then set it back to your original temp

Setting the minimum extrude temp during print is impossible, but that will help these load / unload macros

I have implemented M302 in my fork of klipper.
You can check it out at: https://github.com/Zeanon/klipper/tree/m302_final
Please tell me if there are any bugs since I copied it from my heavily modified version of klipper and I’m not sure whether I forgot something

1 Like

Hi. Thanks for your time designing it! I’ll try it after this weekend and tell you about it

No Problem, let me know how it goes or if there are any bugs.
I also added a doc, would be cool if you could tell me if it was understandable(I’m not really good at writing doc XD)

Hi. I found the first issue - it works for negative extrusion, but not positive:
image

[gcode_macro UNLOAD_FILAMENT]
gcode:
    # G1 E-738 F3600
    COLD_EXTRUDE HEATER=extruder ENABLE=1
    G1 E-620 F3600
    COLD_EXTRUDE HEATER=extruder ENABLE=0


[gcode_macro LOAD_FILAMENT]
gcode:
    # G1 E738 F2400
    COLD_EXTRUDE HEATER=extruder ENABLE=1
    M118 cold extrusion enabled
    G1 E600 F3600
    COLD_EXTRUDE HEATER=extruder ENABLE=0

If it’s intended however, I think it should work the same with extrusions as well as retractions, because M302’s purpose is to load and unload filament (both directions)

I fixed it, I forgot a return when cleaning up the code, just get the newest version(but from this branch: https://github.com/Zeanon/klipper/tree/m302_final [I created another branch to do a proper PR])

ok, it’s fixed :). I’ll test it over the week and see if it causes any other issues, thanks :smiley:

Hi. I spotted that the same issue happens from time to time. I pressed on the LOAD_FILAMENT macro, first time it told that extruder is too cold, second time worked. Maybe there’s some issue with the M302 implementation?

The only explanation I have is that it needs a small amount of time to register.
Klipper has an internal variable called can_extrude which gets updated every time the temperature_callback function of a heater is called.
What I essentially did was update that from self.can_extrude = self.smoothed_temp >= self.min_extrude_temp to self.can_extrude = (self.smoothed_temp >= self.min_extrude_temp or self.cold_extrude)
(which is the most sensible way imo as it does not break any safeguards and is the least invasive way to do it)
so of course as long as temperature_callback is not called, the can_extrude variable will still be false.

EDIT: everything I wrote before is not important, I am still going to leave it there for anyone wondering what I did, but I just realized, I can just update can_extrude when setting cold_extrude
Don’t mind me, I was dumb

2 Likes

Please, I have the same problem with chocolate printing so I need temperature 36 degree on nozzle. I try M302 gcode not work(( Can you help? What need to change ?

M302 is not implemented in Klipper, I opened a PR for it but it was dismissed
You can use force move though
Or manually add the code from my PR: