When we 3d print things, we load an stl or 3mf file into our slicer and we choose some
settings based on what we've used before or what we understand or maybe just a preset,
and we click slice, and we then export to gcode one way or another.
My overall aim on this channel, or at least one of my aims other than hitting 1 million
subs and becoming literally THE 3d printing channel...hey I've worked it out, it could
happen, give me 100 years or so. Where was I. Oh yes, aim. My aim is to help you, and
I guess also me, become better at joining the dots between all the parameters in the
slicer and what literally gets extruded out the other end as molten goop.
So with as few as possible further ado's...well just one actually. This is part of something
bigger, the reason I am looking into this is because I have to use it for something
I'm working on which I kind of was going to just make a video about but it's grown into
a bigger thing so I thought, why not capitalise on that and explain this stuff. What that
means in practice is I'm somewhat learning as I explain, and what that means in practice
is...gasp....I might get things WRONG! Seriously though check the description for
addenda and add stuff to the comments and I'll pin corrections or whatever.
So. Extrusion math.
It's literally everything to an FDM printer, all one of these machines does is move in
three directions and extrude molten goo, so when you talk about extrusion math, from a
pedantic point of view, you are talking about all the math. I don't really want to write
a book on this, at least not for the moment, so I'll have to narrow it down a bit. I want
to talk about the relationships between the parameters you supply for width, height, nozzle
size, line length, and the differences between the infill and the perimeters, and how that
gets made into gcode statements. And importantly I want to talk about the two
most popular slicers, cura and prusaslicer, and I want to talk about the differences between
how they do extrusion math, because for two very similar programs they have some pretty
divergent maths going on.
First up I want to show you some g-code. Gcode is astoundingly simple, but because it's just
a vast solid block of data it looks a lot more intimidating than it really is. If you
ignore most of the parameter commands, for example those that change attributes of the
printer like this hotend temperature command here, once you pare it down, for 3d printers
you usually just end up with a lot, and I do mean a lot, of G1 commands.
G1 means move while extrude, and the parameters this command accepts are straightforward too,
you can supply X, Y and Z coordinates, and an Extruder position. The X Y and Z are the
same coordinates as you are used to, and the Extruder is just an incremental value that
relates to millimetres of filament at the rollers of the extruder, if it's calibrated
properly. There are some intricacies here like absolute or relative modes but that's
beyond the scope of this chapter. All we need to know is that every move that extrudes filament
is just a move from wherever the nozzle is right now, to a given X,Y,Z coordinate, while
extruding E amount of filament.
There is one more parameter with the G1 command which is the feed rate. Essentially this equates
to "speed", but with the understanding that it affects extrusion too so faster G1 moves
will cause faster extrusion.
It's time to break out the play doh. The fundamental aim of a slicer is to convert a solid object
into horizontal slices each made up of individual lines of extruded filament, obviously, but
the balance between the parameters you supply and the amount of filament supplied to the
nozzle in those gcode commands, is a calculation the slicer can't afford to get wrong. At all.
The slicer must know exactly how much filament to extrude for each G1 gcode command. If you
just look at the gcode it can seem a bit random, but of course it isn't. It's really hard to
understate how important this is. Too much and you get overextrusion because more material
has been pushed out of the nozzle than can fit in the line or space it occupies. Too
little, and you get a thin line or worse, intermittent lines, both of which are referred
to as underextrusion.
All good so far - so we know that the amount of material extruded is literally one parameter,
how does that relate to line width and line height? Because we don't specify flow rate
in our slicer settings, we give height and width, how does that work then?
And a related question - what does nozzle size have to do with this?
Tackling the first question..first, this is the point where the real world hits the maths
and doesn't....entirely meet. There are essentially two scenarios, at least that's the simple
explanation, when extruding filament.
Scenario one is when you are extruding a line, say, a perimeter or a single line, with no
adjacent lines already present. Back to the play doh, and we can see give or take what
will happen. The nozzle isn't a single point, if you look close up at a nozzle you can see
there's a fairly large surface around the opening of the nozzle and while I'd never
really thought about it before, this must somewhat be intentional. It acts as a constraint
for the top surface of the extruded material, with of course the bed or lower layer acting
as a constraint for the bottom surface. With no side constraints the extruded material
will naturally form this shape.
The height we specified in the slicer is, therefore, assuming we're extruding enough
material to be constrained like this, it's just the height of the nozzle above the existing
lower structure or the bed. The height is pretty reliable so long as the printer is
working correctly. The width, however, it's a dependent variable in this case. dependent
on...I suppose...the viscosity of the molten PLA, the line height, and...well...the short
answer is, it forms this shape and so the width in this scenario is just a guess.
When you're extruding with lines either side then you can see that the width parameter
is easier to enforce, as each consecutive line can be spaced by the movement of the
nozzle, or to put it another way, it's going to fit in there because it's the only squishy
thing so it doesn't get much choice.
The second question is easier to answer than the first, if you can remember what the question
was even. Nozzle size has almost nothing to do with the extruded line. Think about it.
The gcode is specifying that, to give an example, a travel move of 20mm needs 5mm of filament,
ALL of which will be pushed through the nozzle. How much filament is extruded is constant,
regardless of the size of the nozzle opening - it's got nowhere else to go. This is why
you may have noticed that you can print gcode for a larger nozzle size and the odds are
it won't go terribly.
That's not to say nozzle size is irrelevant. I'll show you this play doh scenario here,
you can see this is pretty edge case for play doh, and this would be analogous to say, a
0.1mm layer height with a 0.6mm nozzle I guess. It can be done, and it would work, but it's
a better idea from an accuracy and finish perspective to use a nozzle appropriate to
your line height, and for that matter width. I'll put some recommended values on screen
along with a link below to explain why this doesn't just mean you should use a 0.8mm nozzle
for everything. https://blog.prusaprinters.org/everything-about-nozzles-with-a-different-diameter_8344/ Of course the page linked does also point
out that the nozzle size affects horizontal detail too, which makes sense, when you're
drawing horizontal details with a large nozzle it's just like if you had a fat marker pen
and compared to a fineliner, you won't get good details,
but a side effect of this too is increased stringing which...I do plan to dive further
into nozzle size choice in a future episode, which will be good so look out for it, although
I did already do a bit of this with TPU in my video linked above now.
So far we've avoided any math, if we carry on it's going to look intentional so it's
about time for me to throw some equations in your general direction.
Did you know that cura calculates extrusion volume completely differently to prusaslicer?
Me neither. I found this out by accident while I was looking into why layer height affects
bed levelling, which was the can of worms that got me into this video in the first place.
More on that later, but if you want the single sentence version, layer height CAN affect
bed levelling, but as things stand, you CAN level your bed to work well with all layer
heights in the range your nozzle uses. But...more on that later.
Exactly HOW the slicer works out THIS BIT HERE is fascinating or terrifying depending
how much you like equations.
I'm going to zoom in on this so we can see what it looks like. Do you see it's basically
like computer ribbon cable or a box of frozen crab sticks. It's halfway between fused and
cylinders, but it's not flat.
In theory it would be a solid flat plate and if you're obsessive over your first layer
you can just about make that happen but that's...well...let's discuss that.
Cura, well. Cura seems to ignore all this. Perhaps it's the best way, since in all my
tests so far for the aforementioned video about line height I've not managed to prove
that it affects the results at least on the first layer. To be clear, cura's equation
for extrusion amount for single lines and infill is fundamentally the same.
Height, times width, times length, equals volume. Sound familiar? It's basically a rectangle.
Cura sees all extrusion as rectangles, at least so far as I understand it. I haven't
dug through the code, oddly I'm not really inclined to, but there's enough documentation
out there to more than slightly indicate that this is how cura works. To quote the official
documentation, The amount of material curaEngine commands the nozzle to extrude is equal to
the volume of a box with the same length, width and depth as the line. I mean I imagine
like most things there are exceptions to this but that's what they've put in the documents,
and importantly - the reason I know this in the first place is because I saw it in the
gcode during my previous video on bed calibration.
Prusaslicer, you may or may not know, was forked from slic3r in 2018 or whatever, I
don't do details but that's the general gist of what happened, so prusaslicer's core logic
and I'm sure a lot more is from slic3r.
The equivalent flow math in prusaslicer is surprisingly more complicated, not so much
surprising that it is more complicated I guess, but definitely surprising that it might not
actually make a real world difference, but I guess that remains to be seen. Subscribe
if you want to find out...
I'll link to the relevant pages in the description again but the general overview is that prusaslicer
sees extruded lines as the real shape that they are, and treats them as a rectangle,
with two small circles one at each end. The area is therefore calculated as the area of
those two parts added together, which I think is pretty clever, and the volume is that cross
sectional area times the length of the extrusion.
When you put two lines next to each other, prusaslicer also recognizes that this isn't
a perfect join, see our images from earlier, and it has an equation for that which is obtained
by subtracting the calculated cross sections from a larger rectangle but pushing them together,
and it's a lot easier to see visually than mathematically so I suggest going no further
than the images on this one. What's important to read in the documentation however is that
prusaslicer acknowledges that the subsequent lines extruded next to existing lines is never
likely to be perfect, which points the finger squarely at cura's math does it not?
As I hinted at already, I haven't been able yet to see a practical difference between
the output of the two slicers with respect to this difference in logic, which honestly
is surprising...but may be explained by one of myriad parameters that each slicer has.
To single out one piece of logic like this and try to compare is an interesting experiment
but likely to fail just simply because there's no way to really have a control print sample.
Of course we also have the global extrusion flow settings in both slicers too, with prusaslicer
I believe defaulting to a multiplier of 0.95 while cura runs at 100%.
I don't want to make this video too long so that's all I wanted to cover of the theory
at this point, but I do want to consider what this means for us in practice, and how can
we use this to influence our decisions as 3d printers rather than slicer software engineers?
Well, honestly I think that understanding how this stuff works under the hood allows
you to make much more informed decisions about which layer height or width to use, or whether
to swap nozzles, and how it will affect your output. It also allows you to rationalize
some weird arguments and myths out there, like how a nozzle that's worn flat would affect
your print, given what we've just covered, all I can think is that it's more likely to
work better so long as the hole in the centre is the same size, you have a larger constraining
surface so bring on the super wide extrusions!
Something I want to leave you to think about is vase mode. I want to cover this in the
future but you ought to now have enough info to be able to work out how you can improve
the strength of items printed in vase mode dramatically in the same print time and at
the same speed, with just changing one single setting. This is what I mean here, when you
know the theory, you can work out how to exploit it for better results.
I hope this video was of some use, it is harder for me to make videos like this because of
the burden of research, checking, probably still being wrong, and so on, but if you do
find it useful then let me know and I'll try to make more theory based content in future.
Thank you for watching.