A typical line of (depositing) G-code seems to set a maximum speed (F), a new position to move to (X, Y, Z) and a new extrusion distance (giving a filament distance for the move). The F is common for the line of code, and I understand gives a maximum for the XYZE combined speed.

My question is: "How is the extrusion rate synchronised to the movement distance and speed?"

The G-code doesn't seem to have enough information to deal with this, but I've tried looking at a Marlin configuration file and don't see anything obvious there.

To take a really basic example: A 30 mm long single filament, layer height 0.2 mm and width 0.4 mm. A basic slicer will assume 0.2x0.4x30 mm³ total volume, but for each mm of travel you want 0.2x0.4x1 mm³ to be extruded. How is it ensured that this happens regardless of travel speed, without say more being extruded in the first half of travel than the second or vice versa?

It feels like this is dealt with somewhere in the firmware but I don't know where to look. A 'worked' example for a desktop printer or as much detail as you dare would be absolutely perfect. If it helps, I am generally using either an ANet A8 or Ultimaker 3 with the CURA slicer using Marlin-based firmware.


1 Answer 1


I'm not sure what you mean by "XYZE combined speed", but I wonder if it's the same misconception as in Details of Marlin's feedrate calculation. The feedrate is a regular 3-dimensional velocity in XYZ space which is the maximum rate the printer will attempt to achieve, subject to individual axis feedrate limits (including E) and acceleration profiles.

In any case, the simple answer your question of how the E-axis motion is synchronized with motion in space is no different from how motion along the X-axis is synchronized with motion along the Y-axis. If X and Y motion were just allowed to take place independently up to the desired speed, with no constraint that they happen in step with one another, then the path the print head traveled would not be a straight line but (ideally) the junction of one horizontal or vertical line with one diagonal one or (with acceleration profiles applied) some approximation of that by curves. But of course the X and Y motions do take place in sync with one another. Each spatial coordinate during the move is a function of time computed by the "planner" logic in the printer firmware based (essentially) on the ratio of the magnitude of individual components of the move to the overall length of the move and speed.

In traditional firmware prior to Linear Advance, the E axis is synchronized exactly the same, according to the ratio of the move completed to the whole and the total amount to be extruded. With Linear Advance, that's adjusted by an offset proportional to the current baseline (before applying LA) extrusion speed, to compensate for the filament being compressible and/or its travel path (e.g. a bowden tube) being elastic.

  • $\begingroup$ Thank you, this is a really helpful answer. To your first point; Yes, I was indeed making the same mistake with the feedrate calculation, so that is very helpful to have corrected. Regarding the remainder, that all makes good sense. Can I physically see the code of the 'planner' logic in the firmware? I've had a look through but can't see anything that really does what you have described above. Am I also right in thinking that the G-code only overwrites the firmware values if a value is declared? eg. if the LA value (k?) is 0.22 in the firmware, but not defined in the G-code, it's 0.22? $\endgroup$
    – Sam
    Commented Dec 7, 2020 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .