G-code wait for extrude command to finish

I have following G-code to prime the nozzle before start of the print.

G28 ; home all axes
G0 Z5 F5000 ; lift nozzle
G0 X30; move to X30
G28 Y; home Y
M420 S1; turn on bed leveling
M109 S220; wait for hotend temperature
G1 E20 F1800; extrude filament 20mm


The idea is to extrude a strand of filament outside of the bed and then start the print. The strand catches on the bed a tears off. So the ooze does not mess up the first layer.

The problem is that the G1 E20 F1800 does not wait for the move to finish and the controller goes to next move immediately. This means the nozzle is going to start the first layer, while spewing filament along the way.

Is there a way to wait for the move to finish?

I have tried M400 which seems not to help. I'm using Marlin Firmware.

• Try to add a small rise e.g. of Z to the last command. I use similar script printing "big dot" on the side, while going up at the same time. (And then prints the initial line with the seperate command.) This works well for me. Btw. Marlin docs says for G0-G1: "These commands yield control back to the command parser as soon as the move is queued, but they may delay the command parser while awaiting a slot in the queue." ...whatever it means. – octopus8 Apr 3 at 8:56
• Are you sure the move didn't finish? Attempting to extrude that much at that speed will not actually do so unless you have a really powerful hotend. Instead it'll build up the max pressure the extruder can give prior to slipping and continue to ooze for a long time after the move. This is not a workable way to prime. – R.. GitHub STOP HELPING ICE Apr 3 at 11:33
• @R..GitHubSTOPHELPINGICE I was about to write an answer in this line, please post an answer. Note the a retraction prior to move may help, alongside slower extrusion. Please post an answer! – 0scar Apr 3 at 21:57
• OK, will do that. – R.. GitHub STOP HELPING ICE Apr 3 at 22:50

1 Answer

Are you sure the move didn't finish? That would be very unusual, not the way 3D printer firmware normally operates. A new G0/G1 move command does not execute until the previous one finishes, whether it's extrude-only, travel-only, or a print move (mix of extrusion and travel).

What's probably happening for you is that the amount of material you're trying to extrude cannot melt and pass through the extruder at the speed you requested. At 1800 mm/min, assuming 1.75 mm diameter filament, you're requesting over 72 mm³ of material (nearly a whole cubic centimeter!) of material to be extruded per second. According to some back-of-the-envelope calculations I just did, It would take more than 300 Watts to continuously raise PLA from room temperature to extrusion temperature at that rate, which is not happening without an extreme hotend and power supply.

So, what you're getting is pressure building up between the extruder gear and the hotend (until it starts slipping), causing the material to continue to ooze for some time after the E-axis move finishes, until all the pressure subsides. If your goal is to prime the nozzle for printing, this is not how to do it. It will just end up oozing material all over the start of your print.

You can somewhat fix this by just reducing the feedrate in your command, but that's still not necessarily going to give you great results. The right way to prime is to extrude at nearly the maximum rate your hotend can handle, then retract and wipe before traveling to where the print will begin.

• Excellent answer. OP should figure out their max extrusion rate for a given temperature/material. For me, with 1.75 mm PLA, my maximum extrusion rate before skipping steps is about 11.25 mm/s at 250 °C. – Rykara Apr 3 at 23:17
• @Rykara: Even 11.25 sounds very high, like it would need a volcano or something. The 250 °C temp should help if you're not trying to sustain that rate continuously, but that's still over 40 mm³/s which is double what I see frequently cited as the max "normal" printers can handle which is still significantly more than they can handle well, without skipping. – R.. GitHub STOP HELPING ICE Apr 3 at 23:21
• @R..GitHubSTOPHELPINGICE Thank you! That's totally the problem I have. I found the start code online, so I was not really questioning it. But your explanation makes perfect sense, and it is exactly what is happening! Thank you. – jnovacho Apr 4 at 8:10
• Correction to my previous comment: 11.25 mm/s is 27 mm³/s which is high but not as high as I was estimating. It may be on the very high end of what's plausible with a "normal" printer/hotend and very high temp setting like 250°C. Note: a useful rule of thumb shortcut to remember is that you can multiply by 2.4 to get from mm/s (at 1.75 mm diameter) to mm³/s. – R.. GitHub STOP HELPING ICE Apr 4 at 16:30