Matthew Harrison - Oct 02 2017
In early April 2017, a member of the Prusa i3 Facebook group posted about a feature of Marlin firmware that they had come across named linear advance. Documentation for the algorithm can be found here.
In a nutshell, LIN_ADVANCE enables a pressure control feature which sets the pressure inside the nozzle to the needed one according to the print speed. This way, bleeding edges and rough solid infill can be nearly eliminated.
When your 3D printer extrudes plastic, you'll notice that it takes a little while after you've started extruding for the plastic to actually come out of the nozzle. It also doesn't stop flowing out of the nozzle right after it stops extruding - some still oozes out. This is due to the pressure build up inside the nozzle when the plastic is pushed in. Even though it's melted, it still takes some force to push it all through a tiny 0.4mm hole.
The force needed to move the filament through the nozzle depends on the speed you're trying to push it through. If you push it fast (printing fast), the filament will first be compressed before the pressure inside the nozzle is high enough to extrude the required amount of material.
The documentation also mentions that when the linear advance is properly calibrated, your retraction distance should be able to be reduced to almost zero. This works because by using linear advance, the firmware is able to reduce the pressure inside the nozzle when it reaches the end of an extrusion such that it doesn't keep oozing out. The benefits of linear advance extend far beyond this though. You'll be able to see in the results section how big of an impact it really has.
After some research, I found that this linear advance feature had not yet been integrated in Prusa firmware. I added a feature request for it on the Prusa github here and after a few months it was developed and added to the firmware.
Before you begin, please ensure that you have calibrated your extruder. You need to be feeding the correct amount of filament for these calibrations to give reliable results.
It should be noted that there are two versions of linear advance - 1.0 and 1.5. Version 1.5 has a number of significant improvements over its predecessor, including:
- Reduced computational load, which results in this version running faster
- No more rattling extruder motors caused by the pressure adjustment moves
- All extruder moves now respect the jerk limits of the printer so that no steps are skipped
- K is now a meaningful value, with the unit [mm of filament compression needed per 1mm/s extrusion speed]. This means that while old K values from version 1.0 might be between 30 - 130, new K values for version 1.5 will be more like 0 - 2.0.
This guide will only be covering version 1.5. If you do still happen to be using version 1.0 I'd encourage you to update. If that's not possible, you can still follow the steps below, keeping in mind that you'll need to use different K values.
Its important for you to know that your printer firmware has linear advance enabled, and also which version you're running before you proceed. If you have a Prusa printer, any official firmware after version 3.9.0 uses linear advance version 1.5.
For any other brand, you will most likely have to flash custom Marlin firmware to the motherboard to enable linear advance. To the best of my knowledge, brands like Creality don't ship printers with linear advance enabled in the firmware.
Once you've got that sorted, it's time to move on to getting it calibrated for your machine and your filaments.
There's only one thing that you'll need to calibrate for the linear advance algorithm, and that is the K factor. This is a measure of how much the printer should compensate for the springy nature of the filament (how it compresses and builds up pressure before actually extruding).
A higher K factor means that the filament is more springy, and therefore the printer will compensate for it more. A lower K factor means that the extrusion behaviour is more linear, like the other axes on the printer. A K factor of zero means that there is no compensation at all.
The K factor is heavily dependent on the type of filament that you're printing with, as plastics flow differently when melted and compressed. It's also dependent on the kind of extruder set up your printer has, and also what temperature the filament is being extruded at. In order to find the perfect K factor for your filament, you'll need to do a test print that uses different K values in different areas and choose where it visually looks best.
Thanks to the great Marlin docs, we can do this test print very easily. Head over to the K-Factor Calibration Pattern generator. Once you're there, input all your printer specific details under the Printer and Print Bed sections. You can leave the Speed settings as they are by default. Under the Pattern section, you will need to select which version of linear advance your printer uses - 1.0 or 1.5. This is very important as the K values vary significantly depending on the version.
As the tooltip says, Select version 1.0 for Marlin 1.1.8 and earlier. Select 1.5 for Marlin 1.1.9 / 2.0 and up. On Prusa machines, any official firmware after 3.9.0 uses linear advance version 1.5. If you're not sure which version your printer is running, please check! This is very important.
Next you will need to input the starting and ending K values, and also the increment of how much each test line will increase the K value by. Below are some ballpark values for direct drive extruders - bowden extruders will almost certainly need larger K values.
Linear advance 1.0
Start: 0, End: 100, K-factor Stepping: 10
Linear advance 1.5
Start: 0, End: 0.5, K-factor Stepping: 0.05
Unless you know that you need to adjust any of the Advanced settings, leave that all as-is and then click the button to generate g-code, and then the button to download as file.
This file will print a zig zag pattern, with each horizontal line using a different K value. The first line is K=0, and each following line increments K by 10. The horizontal lines consist of three segments - it starts slow (20mm/s) for 2cm, then goes fast (70mm/s) for 3cm, then slow again for the last 2cm. This is shown in the diagram below:
With no linear advance (K=0), this would create a thin section of the line where the printer speeds up, and a thicker section of the line where the printer slows down. If the K factor is set too high, then the opposite of this will occur. The line will be thick where the printer speeds up, and thin where the printer slows down. This shows it is over compensating. What we are aiming for is a line of uniform thickness all the way through, as the thin and thick sections represent under and over extrusion.
Once you have printed the K factor test gcode file, observe the lines that are left on the print bed. This is what mine looked like:
The picture isn't the best quality, but you can definitely see that the first and last lines have thick and thin areas of under and over extrusion.
Find the line that looks the most consistent and uniform in thickness. In my case, the line for K=40 looks perfect, so that's what I'll set my K value as. If two lines look equally uniform to you, then you can choose the value in between. For example if K=40 and K=50 are both equal, then set your K value to 45.
To set the value, it's as simple as including the command
M900 K## in your starting gcode, where ## is your K value. The location of the command within the starting gcode isn't important at all. Slic3r PE's new filament specific starting gcode setting is perfect for this, because it allows you to set different K values for different filaments (which you should definitely be doing by the way).
If you download the new drivers from Prusa Research, they will include modified slic3r profiles with higher speeds and some default K values for different materials. I still recommend that you calibrate the K factor for your own filaments, as the values included by Prusa are on the conservative side.
So what difference does any of this make? Well, here's a list of some differences that you'll notice when using linear advance:
- Lower retraction distance necessary
- No coasting needed
- Seams not as visible
- Sharper corners resulting in greater dimensional accuracy
- No over extrusion at the edges of solid infill
- Much faster print speeds are possible with no negative effect on quality
Feel free to crank up your print speeds much more than you usually would. You'll be amazed how the print quality still stays exactly the same. I'm having great results at around 120mm/s, and I could probably go even higher.
As I hinted at above, you should disable coast, combing, extra restart distance or any other feature like that which is designed to aid with pressure control. You'll also be able to greatly reduce your retraction distance, but that is of course dependent on other things like print temperatures and filament type.
I hope you've found this guide helpful! If you have any problems, please let me know in the comments.