Notifications
Clear all

Auto retraction question  

  RSS
gb160
(@gb160)
Reputable Member
Auto retraction question

Hi, I'm interested about the auto retraction feature thats implemented on the core one, I think it's used after filament has been loaded, and also at the end of every print.

How would I go about figuring out exactly what goes on when this happens? 
I'm interested in reproducing the exact steps via gcode.
I presume I would need to look somewhere in the Core one firmware files to see exactly what goes on, but have no idea where to start looking.
If anyone can offer any help or insight it would be greatly appreciated.

Thanks.

 

Posted : 13/10/2025 12:01 pm
hyiger
(@hyiger)
Prominent Member
RE:

 

Posted by: @gb160

Hi, I'm interested about the auto retraction feature thats implemented on the core one, I think it's used after filament has been loaded, and also at the end of every print.

How would I go about figuring out exactly what goes on when this happens? 
I'm interested in reproducing the exact steps via gcode.
I presume I would need to look somewhere in the Core one firmware files to see exactly what goes on, but have no idea where to start looking.
If anyone can offer any help or insight it would be greatly appreciated.

Thanks.

 

I believe that is the M600 g-code (filament change) which would be here: M600.cpp

This post was modified 4 weeks ago by hyiger
Posted : 13/10/2025 3:13 pm
hyiger
(@hyiger)
Prominent Member
RE: Auto retraction question

For some odd reason, it looks like Prusa doesn't merge branches back into master. This might be more accurate (i.e. up-to-date): https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/v6.4.0-RC/lib/Marlin/Marlin/src/gcode/feature/pause/M600.cpp

Posted : 13/10/2025 3:37 pm
gb160
(@gb160)
Reputable Member
Topic starter answered:
RE: Auto retraction question

 

Posted by: @hyiger

For some odd reason, it looks like Prusa doesn't merge branches back into master. This might be more accurate (i.e. up-to-date): https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/v6.4.0-RC/lib/Marlin/Marlin/src/gcode/feature/pause/M600.cpp

Thanks buddy, I'm not 100% sure this is what I'm looking for, but it's a start.
Ideally I need to look at what commands are getting executed when a print ends...the printhead moves to park position then the important bit I'm interested in...it purges a tiny bit of filament then a very slow retraction (you hear the retraction going on and the filament gets fed back out of the printer)

My understanding is this is to relieve any pressure built up in the nozzle, and it is very effective in stopping any filament oozing out of the nozzle. This is the exact behaviour I want to reproduce in Gcode.
I need to reproduce this mid-print, (don't ask 😂), but my attempts so far have failed. 

Any idea where I would find that ? 

Posted : 14/10/2025 7:04 am
Steve
(@steve-5)
Estimable Member
RE: Auto retraction question

@gb160,

The operations sequence to which you are referring is the "ramming" to form the filament tip followed by a retraction to pull the filament out of the hotend to prevent ooze.  This sequence can be replicated in g-code by sending move commands to the extruder motor.  For reference, here is the link to the Buddy firmware g-code which may be helpful in designing the custom code; buddy-firmware-specific-g-code-commands

Regards, 

Steve

Posted : 14/10/2025 1:05 pm
1 people liked
hyiger
(@hyiger)
Prominent Member
RE:

 

Posted by: @gb160

 

Thanks buddy, I'm not 100% sure this is what I'm looking for, but it's a start.
Ideally I need to look at what commands are getting executed when a print ends...the printhead moves to park position then the important bit I'm interested in...it purges a tiny bit of filament then a very slow retraction (you hear the retraction going on and the filament gets fed back out of the printer)

My understanding is this is to relieve any pressure built up in the nozzle, and it is very effective in stopping any filament oozing out of the nozzle. This is the exact behaviour I want to reproduce in Gcode.
I need to reproduce this mid-print, (don't ask 😂), but my attempts so far have failed. 

Any idea where I would find that ? 

 

OK, I think I know what you are after. I've been poking around in the firmware code and found this: FILAMENT_RUNOUT_RAMMING_SEQUENCE  So as @Steve pointed out you can send this to the extruder.

I guess something like this in the "Before Layer Change G-code"

; Ram filament before layer change in middle of print
{if layer_z > max_layer_z / 2}
G1 E7 F1500
G1 E-50 F2700
G1 E-5 F50
G1 E-50 F1500
{endif}
This post was modified 4 weeks ago 2 times by hyiger
Posted : 15/10/2025 1:29 am
1 people liked
gb160
(@gb160)
Reputable Member
Topic starter answered:
RE: Auto retraction question

 

Posted by: @hyiger

 

Posted by: @gb160

 

Thanks buddy, I'm not 100% sure this is what I'm looking for, but it's a start.
Ideally I need to look at what commands are getting executed when a print ends...the printhead moves to park position then the important bit I'm interested in...it purges a tiny bit of filament then a very slow retraction (you hear the retraction going on and the filament gets fed back out of the printer)

My understanding is this is to relieve any pressure built up in the nozzle, and it is very effective in stopping any filament oozing out of the nozzle. This is the exact behaviour I want to reproduce in Gcode.
I need to reproduce this mid-print, (don't ask 😂), but my attempts so far have failed. 

Any idea where I would find that ? 

 

OK, I think I know what you are after. I've been poking around in the firmware code and found this: FILAMENT_RUNOUT_RAMMING_SEQUENCE  So as @Steve pointed out you can send this to the extruder.

I guess something like this in the "Before Layer Change G-code"

; Ram filament before layer change in middle of print
{if layer_z > max_layer_z / 2}
G1 E7 F1500
G1 E-50 F2700
G1 E-5 F50
G1 E-50 F1500
{endif}

Man you're a star ! Thanks for this.
Im gonna give this a try later.

I won't be needing it on layer change, hopefully just need to use it once.
Long story short I need to basically stop printing altogether for a short period of time (while other stuff is going on) , and oozing with certain filaments has meant I have to babysit the printer during this process. 
I've got it very close with a simple extrude then a slow retraction, hopefully this approach will solve the problem once and for all.

Posted : 15/10/2025 7:38 am
gb160
(@gb160)
Reputable Member
Topic starter answered:
RE: Auto retraction question

On these numbers ,  i think the approach is right, but I cant see those numbers being right for what I want.
eg, unless im interpreting these numbers wrong, thats retracting 105mm of filament being retracted. Surely thats going to back the filament completely out of the extruder? ie, to change the filament.

I'd love to know exactly what speed/lengths Prusa uses for this 'ramming' just at the end of a print... They back it out enough to stop the oozing, but obviously nowhere near the amount thats used for filament change.

This is definitely the right path though. Thanks for your assistance mate ( and @steve-5 )

Posted : 15/10/2025 10:41 am
hyiger
(@hyiger)
Prominent Member
RE: Auto retraction question

 

Posted by: @gb160

On these numbers ,  i think the approach is right, but I cant see those numbers being right for what I want.
eg, unless im interpreting these numbers wrong, thats retracting 105mm of filament being retracted. Surely thats going to back the filament completely out of the extruder? ie, to change the filament.

I'd love to know exactly what speed/lengths Prusa uses for this 'ramming' just at the end of a print... They back it out enough to stop the oozing, but obviously nowhere near the amount thats used for filament change.

This is definitely the right path though. Thanks for your assistance mate ( and @steve-5 )

 

Ah, yep. Makes sense what you are saying. So probably now I'm thinking just M601 which is "pause print" and then dissect what it's doing behind the scenes. This is turning into a fun  puzzle. 

Posted : 16/10/2025 4:47 am
1 people liked
gb160
(@gb160)
Reputable Member
Topic starter answered:
RE:

 

Posted by: @hyiger

 

Posted by: @gb160

On these numbers ,  i think the approach is right, but I cant see those numbers being right for what I want.
eg, unless im interpreting these numbers wrong, thats retracting 105mm of filament being retracted. Surely thats going to back the filament completely out of the extruder? ie, to change the filament.

I'd love to know exactly what speed/lengths Prusa uses for this 'ramming' just at the end of a print... They back it out enough to stop the oozing, but obviously nowhere near the amount thats used for filament change.

This is definitely the right path though. Thanks for your assistance mate ( and @steve-5 )

 

Ah, yep. Makes sense what you are saying. So probably now I'm thinking just M601 which is "pause print" and then dissect what it's doing behind the scenes. This is turning into a fun  puzzle. 

My thought entirely, until finding out that pause print doesn't trigger the retraction 😂 ...its part of why I can't just use pause print generally, it's just an oozing mess with PETG.
The two occasions I know it's being used are :

1: When loading a new filament, after it purges the user has to confirm the colour is correct, after confirming it definitely does the sequence.

2: When a print ends. The head moves to the park position and the sequence occurs then...I've checked the custom end G code and there's nothing there that stands out....so it must be handled in firmware.

Im close now, really close, I use a fast, long extrusion, about 15-20mm, then a very slow, long retraction, about 30mm....then just before resuming printing I de-retract that 30mm.
Oozing is now almost non existent, and printing resumes really cleanly. Nothing to clean up, no initial under extrusion when resuming.
I'd still like to know what Prusa is using value wise. the sounds the printer makes aren't quite the same when I use my sequence... It must be in the firmware somewhere.

I tried tracing backwards from the source code, when the sequence is being done by Prusa the message  'Auto-retracting filament' appears on the display...so I searched for that string on Github in the firmware repo, yet it returns no results...wth ?...the plot thickens 😂

 

Posted : 16/10/2025 7:05 am
gb160
(@gb160)
Reputable Member
Topic starter answered:
RE: Auto retraction question

 

Posted by: @miroslav-h4

The above code is nonsense, it will cause the filament to be ejected from the feed wheels. The correct command sequence is located one item higher in the source code. I added the comments. I hope you can handle the conversion to gcode sequences yourself.

 #define FILAMENT_UNLOAD_RAMMING_SEQUENCE \
        { \
            { 8, 995 }, \     Extrudes 8 mm of filament from the nozzle
            { -43, 6000 }, \  These 3 instructions will pulling the filament 55 mm at a decreasing rate
            { -8, 3000 }, \           ""
            { -4, 1800 }, \           ""
            { 20, 600 }, \     These 2 instructions will move the filament 20 mm forward
            { -20, 470 }, \    and backward in the cold part of the nextruder to make the tip come out.
            { 55, 1740 }, \    These 2 instructions will momentarily insert the end 
            { -55, 6000 }, \   of the filament into the hot part of the nozzle. (Tip Tamping.)
            { 20, 340 }, \     This is followed by cooling of the tip again in the cold part of the nextruder.
            { -20, 210 }, \           ""
            { -50, 2000 }, \   Final pulling of the filament to the upper edge of the nextruder tube,
				with the filament still held by the feed wheels. 
        }

Yes I can convert to gcode buddy....thanks for your assistance. 👍

Posted : 16/10/2025 9:58 am
1 people liked
Share: