Linear Advance

In early April, 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 the Prusa branch of Marlin 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.

Set up

Before you begin, please ensure that you have calibrated your extruder. You need to be feeding the exact right amount of filament for this to work correctly.

Although the linear advance feature has been implemented into Prusa firmware, it was added after the most recent official release. This means that there’s no readily available .hex file for you to flash onto your printer with linear advance on it – until now! As a temporary solution until the next release by Prusa, I’ve uploaded below all the different variants of the firmware, pulled from github.com/prusa3d/Prusa-Firmware as of 1/10/2017. All you need to do is download the zip file below and flash the appropriate file to your printer using the Prusa Firmware Updater program.

Linear Advance Firmware (Updated 4/10/2017)

Now you have the capability to use linear advance on your printer!

Calibration

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 (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. 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 looks best. Fortunately, Sebastianv650 on the github thread linked above has created a gcode file that makes this extremely easy. You can download it here: K Factor Test

Please note that this gcode uses PLA temperatures and will need to be changed for other material types.

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:

K Line Test Diagram

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:

K Line Print

 

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).

One small note

During development, it was found that some slicers would produce gcode with small areas of very thin extrusion width randomly. With regular printing this isn’t an issue, because the fluid nature of molten filament evens out any tiny differences. However, it does cause some issues with the linear advance algorithm and throws it off.

Slic3r does not have this issue, but it appears that Cura does, and it is unknown if other slicers like Simplify 3D do. In order to stop this from throwing off the linear advance algorithm, you can send a command to the printer telling it the layer height, filament diameter, and extrusion width of that particular print.

Do this with the command M900 W#.## H#.## D#.## where W is the extrusion width, H is the layer height, and D is the filament diameter. So for a 0.3mm layer height print with an extrusion with of 0.45mm using 1.75mm filament, the command would read M900 W0.45 H0.3 D1.75. Enter this into your starting gcode, in addition to the M900 K## command.

Do not do this if using variable layer height or variable extrusion width (as Slic3r does). If you do then it will lead to incorrect nozzle pressures during the print.

Results

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 wipe or coast 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, wipe, 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.

 

35 thoughts on “Linear Advance

  1. Hi Matt, you say you have to do extruder calibration before doing this. Doesn’t flashing the new firmware overwrite this setting anyway and I have to put my value back in after flashing ?

    Like

  2. Finally got around to flashing this. What you finding is a good retraction distance? Printing a small part right now and set retraction to like .2 and its leaving a bunch of wisps between the travel points.

    Like

  3. I tried this on my recent Creality CR10 but the printer doesn’t seem to respond to setting the K values. Is there something that needs to be set to turn the feature on? Is there a way to tell if my firmware even supports it?

    Like

      1. Thanks, I’m new to this, your guide was very helpful! Turns out the firmware is only 1.0 even though the printer is only a month old, do you know what version of Marlin is required? If I upgrade to 1.1 the feature should then be there, is that right?

        Like

    1. The current “nightly” Marlin has a good set of CR-10 configs. Linear Advance isn’t enabled, but it could be. Most CR-10 machines have no bootloader on the board, so you may need to flash a bootloader before you’ll be able to upgrade your firmware. Note that this may void your warrantee.

      Like

      1. so is the nightly better for the CR10 in some way than the 1.15 version? (which I notice has a CR10 config included). I haven’t flashed it yet.

        Like

      1. Thanks.
        I was unsure wether it meant that the whole feature can’t be used with variable or only that small part of it 🙂
        I’ll have to try this on my own printer 😉 Like E-step cal, and PID-tuning did offer good quality improvement I think that this will as well, or at least just give me the opportunity to go with a higher speed 😉
        Now the question is, do I just select the higher print speed in Slic3r and call it a day, or is there some other way to configure it to deaccelerate enough in the corners?

        Like

  4. Nice write up Matt and LA is really neat. Very happy to know this issue that plagues the original prusa printer is completely solvable as it’s something that i immediately noticed upon receiving my mk2 both on the printed parts and in my first test print and it really bugs me. Do you know how other firmware types get around this issue because I’ve never seen it be a problem on the many other 3d printers I’ve used before.

    Cheers!

    Liked by 1 person

    1. Thanks Martin! I think it’s particularly an issue with the prusa because of the high moving mass on both axes. Some printers just move the print head rather than the bed which I think would help. I’m glad you’re happy with the guide

      Like

      1. “I think it’s particularly an issue with the prusa because of the high moving mass on both axes. Some printers just move the print head rather than the bed which I think would help.”

        – Hmm, but I thought the issue is purely due to extrusion pressure. The before and after photo’s I’ve seen seem to suggest so.

        Like

      2. I think it’s a combination of slight overshoot and extrusion pressure, and maybe the linear advance helps to compensate for that in part too. I don’t think it’s all isolated

        Liked by 1 person

  5. Very interesting …I never really goes deep into this new linear advance concept… Perhaps it’s time to test but now I own a MMU, I think there is no availbale firmware isn’t it ?

    Like

    1. I’ve included the MMU firmware in the compiled firmware zip file, so feel free to try it out! You’ll be one of the first to test it. You may need a k value that is significantly higher than usual, let me know how it goes

      Like

      1. I have a prusa style bowden setup, and when I ran the test, K90 seemed the best but still could use improvement. I am adding a K of 110. Is this normal?

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s