So I've been working on a project related to Slic3r this semester for a 700 level Computer Science Ph.D. course I'm in. Essentially what this means is I've been forced to dive into a few parts of Slic3r in order to gain a deeper understanding of how exactly it works and generates GCode. GCode, if you aren't familiar, is the binary code that drives all of the axes in your printer. Your printer has four axes: X, Y, Z (bed), and E (extruder). Any slicer is responsible for every single step that occurs in this GCode, and this GCode is ultimately what brings your digital model into the real world. The process of converting an STL to GCode is incredibly complex (I refrain from saying "complicated," because "complex" implies it is hard, but not needlessly difficult). For the sake of this discussion we will be skipping the whole process of decoding an STL and switch straight to how Slic3r does the math responsible for making your printer work.
What is a Slicer?
As mentioned above, it's a program that takes an STL as input and generates GCode as output. More specifically, though, a slicer really has two responsibilities: toolpath generation and extrusion calculation. A toolpath is the path the hotend follows on any one layer to create your object.
What factors affect the toolpath?
The toolpath is affected by several factors, including: i) your model, ii) the nozzle diameter on your machine, and iii) the extrusion width settings you specify in Slic3r. We'll ignore the first factor and work with just a cube. Below, I have taken a screenshot the toolpath--it is the perimeters and infill that make up your object. In other words, the GCode preview in Repetier Host. In this example, I am using a 0.6 nozzle with a 0.78 extrusion width (I made it thick for the sake of illustration):
Now, toolpath generation can be considered the first phase of slicing your object. Before anything else can really happen, the slicer needs to know where it is going, and how far it is going for any given part of the model. This phase MUST occur first, because the toolpath is critical in doing the math for the next phase, which above I called extrusion calculation.
How extrusion calculation works
Bear in mind that I am still diving into the depths of the Slic3r source code. It is a massive project, with thousands of line of code and high levels of what we call indirection in Computer Science. Tracking down where the magic actually happens is difficult, but I've finally begun to find out where the math for all of this is taking place. Fantastic news, though: the Slic3r manual page on flow mathematics is still relatively up to date! For that reason, this section of the discussion is a significant paraphrase of what they discuss there.
To successfully write a slicer that actually works, you're going to need to know how much material to tell your E axis (extruder) to move at all times. At first, this seems like a pretty daunting task--after all, a lot of real world factors can influence whether or not your calculations are actually correct! When writing a slicer, assuming you want wide adoption, it needs to work well on a variety of machines and have a lot of room for fudge factors. So using factors such as nozzle geometries or filament properties simply isn't acceptable. Instead, we turn to a theoretical model of extrusion.
Slic3r's theoretical extrusion model
As mentioned above, extrusion calculations are not quite linear. In that sense, I mean they are not one-dimensional, which is technically an abuse of the word linear. Regardless...
Instead, extrusion calculations are done on a volumetric basis. This means a geometric mathematical model is involved in doing the calculations. Sounds scary, but it isn't. Slic3r uses a model of rounded rectangles to make its calculations. A picture will help:
(source: Flow Math documentation from Slic3r)
In this model, the variables are defined as follows:
h = layer height (mm)
w = extrusion width (mm)
To reiterate the equation in the picture, the area of this cross section is the summation of the areas of the two circles and the rectangle:
A = rectangle + circle
= (w - h/2 - h/2)*h + pi*(h/2)^2
= (w - h)*h + (h^2/4)*pi
= wh - h^2 + (h^2/4)*pi
I expanded this out just to demonstrate that we are currently working with the units of mm^2. Of course, that makes this a 2-dimensional approximation, so we extend it along the third dimension by multiplying by the length of filament we want on the bed (from the model), to obtain:
V = L*A
= L*(wh - h^2 + (h^2/4)*pi)
= Lwh - Lh^2 + L*pi*(h^2/4)
Again, I expanded this out just to demonstrate the units: we are now working with mm^3, which is a volume. (Note that pi is unitless because it is a ratio of mm to mm).
But how does Slic3r use this volume? That's where the filament diameter comes into play. If we assume filament is perfectly round, then we can approximate the volume of a given piece of filament as a cylinder, with the radius equal to half the filament diameter:
Rfil = Dfil/2 (Dfil being the diameter of filament)
Vfil = Rfil^2*pi*Len, where Len is the length of filament we need.
Now this answers precisely WHY it is ABSOLUTELY CRUCIAL that, when your the slicer calls for one millimeter of filament, YOUR EXTRUDER NEEDS TO PROVIDE ONE MILLIMETER. If your extruder is not correctly calibrated, all of the math the Slic3r developers worked so hard on breaks down, and there is no predicting the behavior of your machine, or the accuracy of your model!
But then, it all goes horribly wrong...
So we have this very simple geometric model which allows us to turn a requested amount of extruded filament into a volume, and we can use this volume to go back and forth between lengths of filament and extruded length, and ensure the plastic is laid down correctly and doesn't bump too much with the toolpath we generated earlier. But here's the rub: these are all theoretical approximations, and the real world frequently spits in the face of theory. There are a few factors which make this model inadequate as it stands:
1. Squish: As we (well, the Press is different I guess) adjust the Z-stop limit with a screw, and level the bed using our eyes, sheets of paper, or more advanced tools like feeler and dial gauges, a layer height of 0.3mm is not actually 0.3mm, because the bed doesn't move down from a position directly squished on the nozzle. So, the model is already inaccurate because the 'h' variable we described above is not exactly correct (it is off by a constant value, always).
2. Die swell: My understanding of this is not perfect. I have not read any books on polymer extrusion and do not understand internal geometries of nozzles. Regardless, it does exist, and it messes up the calculations above. The general rule of thumb I've always heard is 120% of nozzle diameter, but it really depends. For the e3d, I've actually seen it is a tad larger. Now, the 'w' variable in our model above is all messed up too!
Is this model useless? Nope. Not in the slightest. We can rebuild him, we have the fudge factors.
Fudge factors of extrusion calculation
This long post all leads up to what the extrusion multiplier is, and why it is so important that you dial it in correctly. In the internals of Slic3r, any extrusion calculation not related to bridging (more on that later) goes through ONE function. This function has four inputs:
1. Extrusion width
2. Layer height
3. Length you wish to extrude (this comes from the model you're printing)
4. Extrusion multiplier
Before this function returns the volume of filament to be extruded for any one section, it multiplies the result of the theoretical model by the extrusion multiplier. This internal fudging of the model allows us to ensure that the theoretical calculations actually align with what happens in the real world. Slic3r is liberal in its estimates, and it often over-extrudes if you don't set this value correctly, particularly with ABS. Bad things happen when you over extrude: the plastic bumps into itself, the bed shakes, you experience poor adhesion, and worst of all, your parts look bad and don't fit. It's O.K. that the model isn't perfect, though, because we can perform calibrations to ensure it is correct.
BUT... you can calibrate incorrectly!
In the Slic3r manual, they make the mistake of telling you to fudge the extruder steps per mm to make your wall thicknesses come out to the appropriate nozzle diameter. This actually isn't what they mean, and I have to question who actually wrote that (an open source equivalent of an intern, I guess). If you do this, several bad things happen:
1. The theoretical model is once again, broken. Your extruder is not pulling in the amount of plastic requested by the slicer, but you have fudged it in such a way that it works. That's fine, except....
2. You mess up retraction calculations. When you ask for, say, 1.5 mm of raw filament retraction, that's not what you get anymore. You will either under-retract or over-retract, and get strings/blobs or holes, respectively. Additionally,
3. You mess up bridging. I have so far left bridging out of the discussion, so let's talk about it now.
Bridging is different in Slic3r
All of the stuff I mentioned above is null and void entirely when it comes to bridging. The reason is, bridging is extrusion over free air. The model above doesn't work because there is no 'h' variable to consider. Instead, Slic3r uses a different model, which, if you look at all of the issue tracking on GitHub, seems to have been mostly determined through experimentation rather than theoretical means. In fact, bridging has its own extrusion multiplier entirely. This is called the bridge flow ratio, and it is under the Advanced pane of the Print settings tab in slic3r. A lot of folks think they have trouble with bridging because they don't have a fan, but... Slic3r makes approximations that once again need to be corrected. Slic3r assumes free air extrusions are equal to the nozzle diameter, and this is almost never true due to die swell. Remember the 120% rule mentioned above. Therefore, your bridge typically fails because one extrusion of the bridge bumps into another extrusion, and without a fan, the bridge is still molten, so when other filament bumps into it, this leads to sagging. You will have a lot of luck with bridging if you adjust the bridge flow ratio to control how much plastic is extruded.
So, what is the takeaway from all this?
The takeaway is that you should calibrate your extruder's steps per mm as perfectly as you can. On the Solidoodle 2, 3, and 4, this has been 105. I don't know about the press. This value will be the same for ANY filament, ALWAYS. If it isn't, your drive gear is slipping, or some other gremlin is going on. After you calibrate this, you should calibrate your wall thicknesses correctly using a cube, and adjust the extrusion multiplier appropriately.
Before you calibrate with a cube, measure your filament carefully. Remember how I said the filament diameter plays a critical role in how much filament Slic3r requests? If you don't have this as close to your actual filament diameter as possible, you will never get your extrusion dialed in perfectly.
To correctly calibrate with a cube, set all extrusion widths to 120% of your nozzle diameter (0.48 for a 0.4 nozzle, 0.42 for a 0.35 nozzle, and 0.72 for a 0.6 nozzle), request 1 perimeter, 2-3 bottom solid layers and no top layer. Measure the thickness of all 4 walls with as few layers in the calipers as you can manage. I prefer to discard the largest, and then take the average of the other 3. The thing is, this is somewhat of an art, because you may not get it perfectly. You have to experiment. You might find you're still over-extruding, so back off the extrusion multiplier some more. If you see gaps, you are under-extruding, so bump it up. It takes time to get this right, but it is worth the effort. After you calibrate, you can use whatever extrusion widths you want, assuming they are reasonable. I switch this up all the time depending on the print, so it's up to you.
If you do these things, your prints will look fantastic, and they will fit quite well. If you don't believe me, try it. I promise you will get good results.