Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear Advance Integration #75

Closed
Matts-Hub opened this issue Apr 15, 2017 · 139 comments
Closed

Linear Advance Integration #75

Matts-Hub opened this issue Apr 15, 2017 · 139 comments

Comments

@Matts-Hub
Copy link

I've noticed that the firmware still refers to the old version of the advance algorithm in Marlin, and is not able to be configured through M905 like it is now in stock Marlin fw. Refer to http://marlinfw.org/docs/features/lin_advance.html. A new LIN_ADVANCE feature has been introduced which has been shown to drastically improve print quality in some areas.
It would be great if this could be integrated in the next update

@PavelSindler
Copy link
Contributor

Thank you for this information.

@bubnikv
Copy link
Collaborator

bubnikv commented Apr 21, 2017 via email

@Matts-Hub
Copy link
Author

@bubnikv Yeah I've seen evidence to show that it definitely does work - and really well too! There was a discussion of it at this post on the facebook group https://www.facebook.com/groups/Prusai3users/permalink/732860686898415/. The user posted pictures taken from another group of prints done on a tevo tarantula (bowden extrusion). If you have a look, you can see the prints are perfect.

There have been suggestions that pressure control isn't relevant for direct drive systems or that it wouldn't make a difference. But the pressure control doesn't only account for spring action in the feeding system before it reaches the nozzle, but also for the actual pressure build-up in the nozzle before extrusion begins. Hence it would be applicable for all extrusion systems. Also the testing that was done for the original documentation I posted in the link of my original post, was all on a direct drive printer.

I also posted some pictures in the comments of that post showing the bulging corners that I was experiencing - something that can and would be fixed through the use of pressure control

@theFPVgeek
Copy link

theFPVgeek commented Apr 21, 2017

Would love to see this enabled as well. I must reiterate @Quintox303 's statement that it is beneficial to direct setups as well not just bowden. Additionally while "slicers have options to control the nozzle pressure in some ways. Common names are: Pressure advance, Coast at end, extra restart length after retract. Disable them all! The firmware will do a much better job than the best slicer can do, and they would influence themselves in a bad way. It is also strongly recommended to disable further features like wipe while retract.

@fiveangle
Copy link

I have 1st hand experience that it makes a huge difference in allowing print speeds that are otherwise unattainable without it. I am considering switching to Marlin 1.1 when it releases to gain this functionality on my MK2, even though it would mean losing all of the wonderful benefits of the PR stream.

On a bone stock Printrbot Simple Metal with Heated Bed 1403 with Linear Adv enabled and tuned for PLA I was able to attain identical quality at true 70mm/s that I had to drop to 30mm/s to attain without it. Any model with lots of sharp corners benefits greatly by not requiring glacial-like speeds to keep excellent print quality. The big benefit I see for the PR i3 is the ability to print the more complex but strong Cubic infill at probably double the speed as what we can now, with zero degradation in print quality and strength.

If you print at 20mm/s it doesn't gain you anything, but printing models in an hour at 80mm/s for "Fast" rates with better quality than a 2.5hr print without it really improved the satisfaction level of my Printrbot for prototyping phase of model design. Nobody cares about speed for final rendition, but that's perhaps only around 15% of the prints we do, right ?

It would be oh so grand if PR ported this feature to the i3 stream with Release Notes claiming it "Experimental" and have the "K" factor set to zero by default, which would not change behavior from current, but those of us who understand how to use the feature would gain a 2 to 4-fold factor improvement in "Fast" print speed. Once in the stream, your team could begin kicking the tires of how to best incorporate it. I could envision the already fast "Fast" Slic3rPR profile print time being cut in half (no, I'm not kidding... although you may have to drop the LH down to 3, since 3.5 is pushing the physical limits of the 0.4mm nozzle).

With the L.A. feature, it would really help bridge the gap for the PR i3 between a great consumer printer, and a great prosumer printer.

@fiveangle
Copy link

fiveangle commented Apr 21, 2017

I forgot to mention: top-layer is dramatically improved even at normal speeds.

Regardless, below are two models printed with and without at 120mm/s (no slow-down enabled in slicer) with 800mm/s^2 acceleration values on PBSM1403. Notice the uncontrolled bulging of the fingers around the ring without L.A. enabled:

Standard:
img_5429

With Linear Advance:
img_5430

(Original model by wstein: http://www.thingiverse.com/thing:598964)

Here's demo of a print at 100mm/s and the 2EW-thickness thin blades came out absolutely perfect:
https://www.youtube.com/watch?v=dkVFFfI7aMY

(Original model by Dalpek: http://www.thingiverse.com/thing:705095)

With PR controlling the slicer as well with Slic3rPR, you could incorporate Linear Advance feature to change the K value based on the filament profile and print profile to automatically generate the best result. This would be an aboslute game changer for the PRi3. Move over Ultimaker ! :)

@GurliGebis
Copy link

Looks like there is a PR for this awaiting :)
#93

@psavva
Copy link

psavva commented May 31, 2017

@Sebastianv650 is the developer for LIN_ADVANCE
Awesome prints with it enabled.

@bubnikv
Copy link
Collaborator

bubnikv commented May 31, 2017

I was looking into the pressure advance theory and implementations since I joined Prusa Research the last spring. I certainly see a value in it and I was toying with the idea of porting the Sailfish pressure advance to Marlin, but due to a lack of time it never materialized. I checked the implementation by @Sebastianv650 this Monday and I find it very clever and cleanly integrated. I especially like the idea how the E events are interleaved with the XY events sharing the same interrupt.

@Sebastianv650
Copy link

Thinks @psavva for informing me about the discussion here :)
I had a quick look at the postings happened before. Regarding the topic direct drive vs bowden, I would even say LIN_ADVANCE is better suited for direct drive systems than for bowden. This is due to the fact how Marlin (and I guess most of it's forks) handle the extruder speed / jerk. While it's possible to get smooth (=no speed jumps) movements out of 3 axis, this is not true for a 4th axis (the extruder) except you allow a full stop at each corner. Think about extrusions at different width inside one outer perimeter. Each speed jump will be amplified by LIN_ADVANCE. On a direct drive system, the needed K values are "low" so the extruder will likely be able to follow the movements. On a bowden system with a "high" K value the extruder might skip steps. Therefore, LIN_ADVANCE might not be useable on every printer and every filament out there.
Beside that, on a bowden system there are friction effects due to buckling inside the tube, and I have no idea how it might be able to compensate them.
Note that I don't own a bowden printer, so I have only reports of other users and physical knowledge as a base for the text above. I use a geared direct drive printer with PLA only (except some special prints).

@Swiftnesses
Copy link

+1, can't wait for this!

@Sebastianv650
Copy link

I'm currently working on the porting to the Prusa i3 MK2 Firmware. Up to now I don't have an i3, so all my coding is untested and I can only check if it "looks good" and compiles. But that should change in the near future :)

I will keep you updated if there are news and of course provide a link to my Github Fork as soon as I think it is ready for beta-tests.
Nevertheless please be patient, it's not only porting. First I have to get, build, calibrate and get familiar with the new i3, after that the first LIN_ADVANCE code tests will start. If I start directly with my modified FW, I will never know if something happens due to a bug introduced by my changes to the FW or if it's a fault of calibration or a build error.

@Matts-Hub
Copy link
Author

Sounds great! I'll be happy to test it as soon as a beta is ready

@bubnikv
Copy link
Collaborator

bubnikv commented Jun 16, 2017

We at Prusa Reserach are excited as well :-)

@GurliGebis
Copy link

@Sebastianv650 Could you take a look at the work done here, if that would be of any use to you? #99
Currently, it seems like it won't boot with the changes in there (I have only separated it out from the other pull request, that included other changes).

@Sebastianv650
Copy link

Oh, I wasn't aware there is already a PR! But if it's not working, it's maybe a good idea anyway to start with my own thing.

On a first look, I would state the following:

  • Stepper.h defines Ex_DIR_WRITE and related methods only up to 3 extruders. In stepper.cpp, you allow also the call of E3, which will not exist.
  • If this PR leads to a failed startup (no display), it's most likely due to a problem with ISRs. This PR does two steps at once (if not more): My concept of allowing specific ISRs inside some others and LIN_ADVANCE itself. Both manipulate the ISR behaviour, that's why my first implementation does not contain the first one (allowing interrupted ISRs).
  • Inside stepper.cpp, you are changing setting of Timer0. I Don't know whats the meaning of this. LIN_ADVANCE is using only Timer1 as the default stepper ISR is using it also:
#ifdef LIN_ADVANCE
  #if defined(TCCR0A) && defined(WGM01)
    TCCR0A &= ~(1<<WGM01);
    TCCR0A &= ~(1<<WGM00);
  #endif
  e_steps[0] = 0;
  e_steps[1] = 0;
  e_steps[2] = 0;
  TIMSK0 |= (1<<OCIE0A);
#endif //LIN_ADVANCE

Maybe this helps if you want to try to fix it.

My version of LIN_ADVANCE for Prusa is a slightly stripped down version. Bubnikv asked for a simple code to ensure usability, and I think that's possible as this FW doesn't has to support every possible printer configuration. Therefore I removed all the extruder related arrays from my variables. On an i3 (even with multi color) there will be never the case where 2 or more extruders operate in paralel for printing. Therefore we will always have a single active one.
As far as I got the multicolor thing up to now - might be wrong - it will always use "the same" stepper, only switching the real stepper over the expander board. Another reason for eleminating arrays. On the other side, when it comes to multi color version of the FW I think we have to add some lines of code to tell LIN_ADVANCE to reset all values on a color (=stepper) change. We will always start with "0 pressure", but that's something for a later time.

A more important decission has to be made how K will be provided to the printer for Prusa FW. My original implementation wasn't storing K into EEPROM, just because it's not a fixed printer value but related to the filament type, which can change.
If the user mainly, but not solely, uses one material kind and switches to another after a longer time there is a high chance he will forget to change or calibrate K. K should be something like the nozzle temperature, you have to select it on every print start and especialy also when you change material during a print (again thinking about multi color/material).
Therefore one option would be to add a specific K to the material preheat settings. Two points are against this:

  • The user can't change this settings except by flashing a new FW.
  • This settings are not called when the slicer issues a filament / material change.

As a solution, I would recommend to implement an option to store K values filament based inside the slicer. This could be done by a filament change gcode script or (even better) automaticaly by Prusa Slic3r edition. This way, K would be set over M900 on every print start and filament change, in the same way as the slicer has to set the nozzle temperature at the same time point.

@GurliGebis
Copy link

@Sebastianv650 The PR I have is a cleanup of another PR, that contained some other stuff as well, that did not make sense to merge in at the same time.

Looking at your feedback, it is clear that there are several other issues with it, so I'm all for going with your work, especially since you know alot more about both the firmware and LIN_ADVANCE :)

I'll keep an eye open for your code, and give it a try when it is ready (and I find out how to recover from a bad firmware flash - not going to experiment with that without having a backup plan)

@fiveangle
Copy link

@Sebastionv650 I never understood why baseline Marlin includes a non-zero K value. Was there a reason it was chosen ? I of course set it to zero at compile then use gcode based on filament (or default "0") for the bulk of filaments that I haven't tested. I don't know how anyone would use it otherwise.

@Sebastianv650
Copy link

@GurliGebis OK then let's keep the existing PR as a reference.
What do you mean with a bad firmware flash? As far as I know it's nearly impossible to damage the Bootloader because the firmware will not write into this memory area. Therefore even if you flash a completely broken FW version, just load the original one in Arduino and flash again. I also managed it one time to flash a stock Marlin (without my configuration) to my printer with the result that the printer was completely unusable ;)

@fiveangle you are right, especialy if we assume the Slicer should set the K value with the start-gcode script a default 0 would be much better. I will propose this as a default for the Prusa version.
The reason behind the non-zero default value was to give users a feeling for a possible valid range of a K value. Without any hint, it would be hard to find out if you should start the search during calibration around values 0-10 or 100 or even 10000. But this realy should go into the description inside the comments!

@GurliGebis
Copy link

@Sebastianv650 If you flash the wrong hex file, the bootloader will be gone, and AFAIK the you have to use the ICSP header to reflash the bootloader back into the atmega chip :)

@Sebastianv650
Copy link

A small update for the interested ones:
I got my i3MK2 kit this week and built it yesterday. After little calibration, I got my first test cubes this morning :)
After tracking down an ungly copy & paste error in my LIN_ADVANCE i3 test FW, it's now basicaly "working". Working means all axis are moving and it just printed a quick K testcube. More testing to be done now!

@nrepian
Copy link

nrepian commented Jun 25, 2017

Nice work @Sebastianv650 :). Have you got any photos you could share with it enabled vs default? I'd be interested to see how it looks on the MK2S.

@Sebastianv650
Copy link

I took two test peaces and made a short presentation. In reality it's even more impressive, but the pictures should do it:

First LIN_ADVANCE test result.pdf

@thess
Copy link

thess commented Jun 25, 2017

@Sebastianv650 - This is super! It would be nice if others could try it. At the moment, the firmware in your repo compiles OK, but the extruder is in-operable. Could you push your current version so I can give it a go? TIA

@Sebastianv650
Copy link

I know my Git is broken at the moment. But please give me one or two more days for testing and code cleanup and completion. I want to have a quite solid thing I can give to all of you that want to test it before the PR, not a alpha-draft which only generates dissatisfaction and error reports.
I also want to find the perfect K for testers, but 50 seems to be quite good as a first shot.

@bubnikv
Copy link
Collaborator

bubnikv commented Jun 25, 2017 via email

@nrepian
Copy link

nrepian commented Jun 25, 2017

Really nice results - very noticeable improvement. I'm looking forward to giving this a try :).

@Swiftnesses
Copy link

Great improvement, although minor to my eye... That said, it's an advancement towards perfection! :)

@fiveangle
Copy link

fiveangle commented Jun 25, 2017

This looks great, thanks! We are looking forward to test it on our print
farm :-)

@bubnikv - you may find the parts don't meet your specs due to all the fine tuning you've put into tweaking your farm for production. You've surely tweaked inputs to perfection in order to compensate for the limitations without LIN_ADVANCE in order to get the desired output. I found the increased dimentionsal accuracy with fast prints using LIN_ADVANCE caused me to have to go back and tighten up dimensions that mate to square-cornered parts, decrease hole size for self-tapped thread inserts, etc.

So be sure to test actual assembly of the parts before shipping to MK2S users ;)

But after recalibrating your process, I suspect this feature will increase your farm output at least 50% at better quality.

ps- so excited at the possibility to soon have this in the standard Prusa FW so I don't have to give up all the other Prusa-specific features :)

@GurliGebis
Copy link

@Sebastianv650 not EEPROM problem, but memory (RAM) problem I think.
All the perimeter loops are missing, but only if the perimeter is small (like the small "dots" on top of the model)
As soon as I get these printed, I'll go back to the LIN_ADVANCE firmware and see if I can reproduce the problem, with pictures, gcode and everything :)

@GurliGebis
Copy link

PR #133 just got merged 🥇

@cbarreto61
Copy link

@robrps I am glad to hear that it helps you print faster. I am intrigued because on my machine I print always at 50mm/s, but still I suppose is not as fast as yours since I have the speed reduction for infil, perimeters and so on. I wonder if you have tried faster speeds?

@3d-gussner
Copy link
Collaborator

1st Thanks for the great job @Sebastianv650 and the rest of you testing it!!!

Do you think anyone could share the Slic3r PE config.ini or Slic3r_config_bundle.ini?
If you are using Octoprint don't forget to delete the API key from the shared files.

@Sebastianv650
Copy link

Nice to see it got merged :)

My Slic3r profiles are quite away from the default ones as I don't like some of their default values, therefore I think it's not a good start point for people that are used to the default ones. It's also always a question of quality one want's to have in the prints.
Let's see what happens to the default profiles, maybe they create a fast profile for use with LIN_ADVANCE?

Now I have an i3 and a TAZ 5 with LIN_ADVANCE. Both print fine, but I like to have one tool per job.. I think the i3 has to become multi material as soon as the lead time for orders goes down or my 3mm filament is low enough to be replaced by 1.75mm one 😃
A multi-material direct drive would be my choice, but that would be a medium-big project beside upgrading to the multi material update..

@triplepoint
Copy link

Congrats on getting this landed. Was there ever any follow up on the missing perimeter loops issue @GurliGebis reported? I'm concerned this was merged to master with a potential bug unresolved.

@Sebastianv650
Copy link

@triplepoint I will have a look into the perimeter issue when GurliGebis can do some tests. But I don't expect an error in the main meaning as LIN_ADVANCE is running in Marlin the same way for a longer time. Maybe he hit some mechanical limits with PETG that can be improved or avoided with some other settings.
Up to now I'm quite relaxed as LIN_ADVANCE isn't handling small circles different from a line, infill or other printed segments. So if it's dedicated to perimeters and small circles and it has worked before, I think about other things maybe first than a software bug that should be reproducable (LIN_ADVANCE isn't using pointers or fancy arrays that might cause RAM corruptions).

@GurliGebis
Copy link

@triplepoint, @Sebastianv650 I think it might be a RAM issue, which I'll be able to confirm later on :)
I'm pretty sure I won't be able to reproduce the problem.

@GurliGebis
Copy link

GurliGebis commented Aug 3, 2017

@Sebastianv650 I just had the problem with stock firmware, so it is not linear advance related. I'll try a power cycle once it is done cooling down, to see if that helps (my guess is that it will)

EDIT: Turning off the power, waiting a few minutes and turning it back on fixes the problem.
So it seems like it is some kind of memory corruption issue, when it has been running for too long, inside an enclosure.

@fiveangle
Copy link

https://www.youtube.com/watch?v=PtXtIivRRKQ :)

@Sebastianv650
Copy link

Is your electronics inside the enclosure? Maybe it's overheating?

@GurliGebis
Copy link

Yep, the cables for the motors are too short for me to move it outside the enclosure.
That is also what I'm thinking :)

@ceryen
Copy link

ceryen commented Sep 9, 2017

Does K=0 exactly equal the old behavior or does K=0 only approximate the old behavior?

I ask because Cura and Simplify3D (with dynamic single extrusion) may potentially produce gcode that is incompatible with linear advance. So if we wanted to use those slicers, would setting K=0 avoid the incompatibility or is that not sufficient to avoid the incompatibility?

If setting K=0 does not avoid the incompatibility, can we consider making linear advance a toggleable option?

@bubnikv
Copy link
Collaborator

bubnikv commented Sep 11, 2017

Slic3r generates a gap fill with varying extrusion width for years.

@ceryen
Copy link

ceryen commented Sep 11, 2017

Sorry, I had seen a comment on the Marlin issue tracker indicating that Simplify3D's dynamic extrusion width could be a problem, but I'll defer to your knowledge.

What about the code comment that Cura may produce incompatible Gcode, is that not an issue either?

@bubnikv
Copy link
Collaborator

bubnikv commented Sep 11, 2017 via email

@Sebastianv650
Copy link

@ceryen K0 will work with any slicers gcode, that's for sure. If the current Simplify3D creates issues, I can't tell as I don't use it. Cura was producing wired gcode that was incompatible with LIN_ADVANCE, but as fare as I know it was the only one.

@fiveangle
Copy link

No one has come forward with any evidence that gcode generated by S3D is incompatible with L.A. Until that happens, it's all just F.U.D.

@IsmaelPR1977
Copy link

IsmaelPR1977 commented Sep 13, 2017 via email

@Sebastianv650
Copy link

For information, some people over at MarlinFirmware/Marlin#8079 wrote a script to use the Test zigzag-pattern with variable K values, temperatures and so on. Could be very useful :)

PavelSindler pushed a commit to PavelSindler/Prusa-Firmware that referenced this issue Dec 2, 2017
Print fan speed: measuring pulse width
@GurliGebis
Copy link

Wouldn't it be safe to close this issue now? It has been added to the firmware a while ago, and have had some time to get tested.

@Matts-Hub
Copy link
Author

Absolutely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests