MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.17k stars 19.21k forks source link

Problems with Linear Advance #5222

Closed landodragon141 closed 7 years ago

landodragon141 commented 7 years ago

So I have this problem when I try to use Linear Advance on my printer. The extruder motor starts stuttering and skipping and sometimes it runs backwards instead of forwards at random (no I'm not talking about retraction :P). I tried turning down the acceleration on the E from the default 10,000 to 3,000. It's a direct drive bowden MK10 esq. My calculated value for K is 160 which shouldn't be that high. I'm also only printing at 40mm/s max. Thanks in advance. EDIT: It was previously working for me before Sebastianv650 moved the code around.

Sebastianv650 commented 7 years ago

Do you know which version was working for you? The last changes i did have not modified the extruder isr, so I have no idea why it should now run backward. Please upload you configuration file, i will see if i can find some values that may confuse the math in the advance code.

landodragon141 commented 7 years ago

There you go. I'll try and capture a video tonight as well. Configuration.txt

landodragon141 commented 7 years ago

I think it was a while back maybe a month. I only just realized that I had been running with it commented out and now it's highly opinionated.

Kaibob2 commented 7 years ago

I also tested lin_advance some weeks (maybe months) ago and had it almost working. Then there were other stuff to fix and i commented it for many RCBugFix versions. Then, a version from end of October (i don't know which one exactly) made massive retraction moves as soon as i switched from K=0 to K=1.

Now i'm with RCBugFix as of 8.11.2016 and the last few tests where chastening too. I can higher K to around 200 (55cm Bowden) and the massive movements are gone, but it is far from working reliable. The reason why i didn't open a thread yet, was because i need more testing to be more specific. So, i know, this post is not really helpful. Sorry.

landodragon141 commented 7 years ago

No I think it is helpful because it's likely you are having a similar problem as me.

Sebastianv650 commented 7 years ago

If it does huge moves with k=1 and smaller ones with k=200,something had to go totally crazy. Maybe a variable is overflowing.. I will have a detailed look at it tomorrow

Sebastianv650 commented 7 years ago

One thing I notice in your config is that you are using a completely different range of esteps/mm than I do. I have 801 steps/mm, you have 95. So my next question is, @Kaibob2 what's your estep value?

I hope we find some similarity between your printers, that would mean we have one specific bug.

Edit:

block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * (de_float / mm_D_float) * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[Z_AXIS] * 256.0);

Maybe I introduced a silly copy & paste error in the PR? Why the hell I wrote Z_AXIS in the calculation? I have to rethink into this..

Kaibob2 commented 7 years ago

This were different versions! The "older" one behaved like: Printing a cube with K=0 Send M905 K1 On the next acceleration the extruder massively overextruded then retracted maybe 50mm or more with high speed (probably 150mm/s which is the limit I've set). I always killed immediately because this behaviour would have damage the hotend when primed a this speed

The recent version is almost working but the retract amount is more then the following prime so each beginning of a loop is massively underextruded. It's hard to describe. I will take some pictures next time.

With the version I tested many month ago everything was fine, but i had to use a K of around 250 which made the extruder rise the white flag. I cancelled experimenting with it because i didn't expected to get it working due to the long bowden.

My estep value is 99 steps/mm, so quite close to landodragon141 and i think quite common for MK8 style extruders.

Kaibob2 commented 7 years ago

Why the hell I wrote Z_AXIS in the calculation?

This explains a lot. Nevermind, nobodys perfect. I think this whole lin_advance thing is a great development and i would really appreciate if it would work reliable one day. Keep irt going. Good luck 👍

Sebastianv650 commented 7 years ago

Please go into planner.cpp and change the Z_AXIS in the line I pasted above (around line 1267) to E_AXIS and report how your printer behaves now. In doubt, ignore the formulas for K and try to find K by try and error. Maybe it's that easy..

Kaibob2 commented 7 years ago

I did a REALLY quick test and changed Z to E in planner.cpp. It's not realy that much different as far as i can remember. The below pictures are with K=50,100,150,200,300 and 400 from bottom to top. This is all i can do for now. It's Schlafenszeit :) 20161115_222159_1479244966981_resized 20161115_222151_1479244970249_resized

Btw.: Before you ask. The printer itself is perfeclty calibrated and produces perfect prints with lin_advance disabled img_3116 img_2983_1

Sebastianv650 commented 7 years ago

It should be a big difference for @landodragon141 at least, because he has over 4000 steps/mm for Z but under 100/mm for E. K=1* 4000 will lead to a rocking like crazy extruder, while K=say 75* 100 may be a real value.

But as you said, time for bed. Gute Nacht zusammen ;)

landodragon141 commented 7 years ago

Well considering my value for K was 160.... 160*~4000 0.o This explains so much! Thanks for looking into this I'm almost off work so I'll head home and give it a whirl.

Edit: Just cause numbers are fun. 4076x160=652,160; 95x160=15,200.

thinkyhead commented 7 years ago

@Sebastianv650 Could this be also related to the concern that K was possibly 10x its former values for some users? (As I recall, 47 versus 4.7)

Sebastianv650 commented 7 years ago

@thinkyhead I had not much time to think about it. But if the issues here can be solved with this change, it's definitiv possible. I will think about it today and see what the next feedback is.

Kaibob2 commented 7 years ago

I have 1601 Z-steps/mm. I will calibrate K with a bigger testcube this evening. The 4 cubes from above were printed with: 70mm/s print speed for everything (I suppose this is too fast for K=250) No retracts, coasting, wiping or other extrusion related settings switched on PLA @ 210°C

@Sebastianv650 Would you recommend leaving a small retract (<1mm) enabled? I normally have 3mm retract when not using lin_advance

Sebastianv650 commented 7 years ago

You can use your normal retract settings without an impact to LIN_ADVANCE. Retract and prime moves are handled without the influence of the advance calculation.

landodragon141 commented 7 years ago

When I saw your test print above I was going to ask if you had retraction enabled. One of the advantages to Lin_Advance is that it reduces the need for retraction and theoretically it might be possible to for retraction to become obsolete in the future with more processing power and a more refined algorithm. Also I'm sorry I didn't have a chance to test out the fix last night so I'll have to get to it later today.

Kaibob2 commented 7 years ago

I had this in mind from the lin_advance documentation

Some 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. I also strongly recommend to disable further features like wipe while retract. You can try to enable it again after you have calibrated your K factor (see next step), but I guess you don’t need it anymore. After you have a calibrated, working pressure advance feature, you may want to recheck your retraction distance. You will find out that you can cut it down to nearly 0. This is caused by the pressure control, it reduces the nozzle pressure at the and of a line to about zero. For example, I was using 1 mm retract length for PLA, with enabled LIN_ADVANCE I’m now using 0.5 mm.

I will test later with everything disabled only retract as usual but reduce to "only retract when crossing open spaces" Until now i retracted at every end of a line, because during travel moves the nozzle lost filament due to oozing and pressure left from the last extrusion. This filament got lost by glueing to the infill or whatever. When the next line started there was underextrusion. I hope this new combination will work...

landodragon141 commented 7 years ago

May the force... flow... pressure be with you! 😄

Sebastianv650 commented 7 years ago

I created PR #5230, it should bring back the K values needed into reasonable ranges. Up to now, I guess this should solve the problems rised since the last big patch.

Sebastianv650 commented 7 years ago

One of the advantages to Lin_Advance is that it reduces the need for retraction and theoretically it might be possible to for retraction to become obsolete in the future with more processing power and a more refined algorithm.

That's no question of processing power, it would be possible to do something like that. In Sailfish, they tried it with JKN, but as far as I know it's always disabled. In theory, you only have to bring the nozzle pressure to 0 at the end of a move where we usualy stop at some jerk speed. So the needed retract length equals the absolute amount of advance steps at this point (k* jerk_stop_speed). But I see no advantage between doing a realy small fixed retract compared to a calculated small retract..

Kaibob2 commented 7 years ago

Okay, like promised here is what i got. 600mm Bowden, MK8 Extruder k3d-v10-2 Two calibration cubes 30x30mm with a X distance of 110mm. unbenannt

First attempt: PLA@210°, Print speed 70mm/s, Outer perimeter 28mm/s, 2mm retraction only when crossing open space, all wipe and coast and whatever disabled Started with K=0. Went up to K=300 in steps of 50. The best value was around 90, what is crazy, because the formula says around 250 for me. From K=130 upwards the inner perimeter after travelling to the other cube becomes underextruded. At K=300 the first 50mm (30mm front and 20mm side) are underextruded. 20161116_204726_1479325665342_resized Quite nice, only at the top right the infill is a little weak.

Second attempt: PLA@210°, Print speed 70mm/s, Outer perimeter 28mm/s, NO retraction all wipe and coast and whatever disabled. Started with K=90 but, long story short, this doesn't work at all! When travelling to the other cube around 5mm filament oozes out of the nozzle. This stops at a K>270 but this high value makes almost the whole inner layer underextrude. 20161116_204635_1479325668210_resized

There is also a very nice effect on the holes which i mentioned some time ago here #4766 This over or underextrusion after leaving the hole is minimized. 20161116_210611_1479326799914_resized 20161116_210559_1479326802977_resized

To summarise:

Maybe @Sebastianv650 can say something about this and give a hint.

landodragon141 commented 7 years ago

That's very interesting. I'll try and replicate that tonight. Do you want to send me that model? That way we can compare apples to apples. I'm right at the cusp of replacing my crappy M5 threaded rod with an integrated M8 Leadscrew stepper. (the integrated motor/screw is sitting on my workbench waiting to be installed).

Kaibob2 commented 7 years ago

Using the same model is a good idea: Cube 30x30x10 holes.zip

I also started with TR8x1.5, but the pitch sucked because you cannot use every layer height you want. At least not 0.05, 0.1 and 0.2, which i use mostly. This is why i switched to TR10x2.

Kaibob2 commented 7 years ago

I feel like i have to give some more info about what my intention is to get lin_advance working. Once my printer was well calibrated with cubes i turned to use more complex objects to do the fine sdjustments. This gecko from thingiverse turned out to be useful. Gecko.zip I usually scale it to 120% and set an Z-Offset of -0,1mm (dropping it into the printbed)

Meanwhile i get really good quality prints, but the price is a huuuge amount of retracts because S3D has to be set to retract at every end of a loop. This leads to no oozing from the nozzle and a clean print when traveling. ohne ohne1 ohne2

To get rid of the retracts i have to enable the "only retract when crossing open spaces". This makes S3D to only retract after a loop when there is a travel move to be done over an open area. mit1 mit2

So far so good, the problem then is, that if the head travels over a "not open" area the nozzle oozes and loses filament when dragging over infill or outlines which is missing when starting the next loop (underextrusion!).

The option to "Avoid crossing outline for travel movements" is nice, but makes it even worse. With this option DISABLED you get this travel 1 Without retracting after each loop this leads to a hedgehog gecko beacuse the oozed out filament sticks to the outline where the nozzle touches its destination.

With "Avoid crossing outline for travel movements" ENABLED you get this travel 2 This makes the hedgehog spikes almost no problem anymore , but now there is another one travel 3 As you can see, S3D plans the "avoid crossing outline" path over the outer perimeter. That means if i don't retract after the previous loop the oozing will create dots of filament along the travel path over the outer perimeter. If the real outer perimeter is printed after that you don't get a clean line as there is too much material everytime the nozzle hits a dot.

Here comes lin_advance into account. If i have no overpressure in the nozzle after ending a loop there will be no oozing and i can enable the "Only retract when crossing open spaces" and "avoid crossing outline" without getting the dots when travelling. Like i explained above the problem now is, that if i set K=250 the oozing stops but the next line starts with massive underextrusion.

thinkyhead commented 7 years ago

With the patch now merged, is it working better @Kaibob2 ?

Kaibob2 commented 7 years ago

Lin_advance works properly with the fix (Z->E-steps)!

@thinkyhead The crazy extruder moves are gone, but the issue i'm facing is the described above.

Sebastianv650 commented 7 years ago

A lot of posts since my last free time slot. If I forget to answer one question in this post, feel free to raise the hand.

@Kaibob2 while LIN_ADVANCE should help you with the retraction problems, it will not completely eleminate it. Even if the pressure control math works perfectly and we add 1mm retract of the end of the move for safety, there is still molten filament inside the hot end. And nothing will hold it back, over time it will ooze out of the nozzle. Like if you take a glas of honey and turn it up side down. Gravity is a ugly thing sometimes ;)

The best value was around 90, what is crazy, because the formula says around 250 for me.

This proves my formula isn't working. I can live with that, then I have to remove it from the config file again. In fact I know it can only be a rough estimation, as it's not taking into account that the needed force to extrude the filament at a specific flow rate differs sometimes. For example if you have another nozzle diameter than I have, or you are printing at a different temperature.

But at first, I think you should do a step backward: You are trying to calibrate K by watching the effect to retraction and oozing. There is a relationship, but I bet it's not a real way to find a perfect K value. I strongly recommend to follow the calibration procedure from the documentation. Print a flat 25x25mm cube at 70mm/s (also for top solid infill an every other line type except for 1st layer). Use a filament color that gives a good contrast and be sure not to bend it when removing it from the print bed. Then, using a scanner or a strong magnifier and a metal ruler, inspect the edges (rounded inwards or bleeding), the perimeters (gaps between them?) and the solid top infill (rough at perimeter line junctions, gaps when approaching the perimeter turn points?).

Here are two example pictures (with a very bad color in terms of contrast). k95 In this picture, you can see K is (a little bit) too low. Edges are bleeding and the infill could be a little bit cleaner at the turn points.

k150 In this picture, K is definity too high. Edges are rounded inwards, there are gaps between the perimeters around the edges in the acceleration/deceleration phase and there are even big gaps at the infill turn points.

When you got a K value that satisfies you, the next step would be to do retraction tests again. First I would try to maximise the retract speed as much as possible (prime speed should be lower if possible). If you found the maximum your extruder can safely handle, do the tests you already described above to find a minimum retraction length. It's only my opinion, but I would stay within reasonable distances between the calibration cubes for the retraction length tests. 11cm are rare in real models, and as described before you will never have 0 oozing if your travel length is high enough. Therefore, I would go with a distance of about 7cm.

landodragon141 commented 7 years ago

@Kaibob2 I just switched from a T5 x 0.8 to a T8 x 8 (2 pitch x 4 starts). Wow I should've done that awhile ago. @Sebastianv650 The fix worked, but I only had time to do a single print. I did the Belt gear for the Voron Extruder. It turned out really nicely. I really wanted to get that Z-axis fixed before I did any further testing because I knew it was a source of issues. I'm not convinced that I have the perfect K value but I'll run through the values tonight and take some good pictures. Occasionally my extruder (i think it was my extruder) was making a click at the end of a line. It didn't seem to effect anything that I could see.

I'll have to put a brown bag over my printer it's pretty ugly lol!

VanessaE commented 7 years ago

One thing I'm seeing across all of my prints is slight under-extrusion at the starts of some lines, especially after retract, much like what @Kaibob2 is seeing, though in the object I'm using (CtrlV's v3 test object), the nozzle isn't crossing over large areas of infill as in his case, or even taking all that much time to complete the travel (300 mm/sec, and this object is only about 100 mm wide).

Anyway, I made a clean clone, applied #5230 onto RCBugFix (this was before @thinkyhead merged it), added my settings, and ran a bunch of tests.

With the formula @Sebastianv650 gave there, based on E=760, Z=4000, and an initial K value of 75, I get a correction of K=395. The result of that setting is okay for most of the part, but here's what the trouble area looks like:

p1170012

(no, it's not printing too hot. :stuck_out_tongue: That's just the lighting, and those are ~1mm verticals.)

Sebastianv650 commented 7 years ago

Interesting miniature print, but not realy something where i can make a statement about advance or k value. At least I would need a print without LIN_ADVANCE to compare. Do you have a detail picture of a under extruded line start?

Kaibob2 commented 7 years ago

@landodragon141 TR8x8 has 2mm pitch too?! Cool, didn't know that. @Sebastianv650 I will start from scratch and print the cubes you suggested. Maybe next weekend i find some time to do so. Regarding retraction speed i just lowered it from 150mm/s to around 40mm/s as the high speed didn't have no effect at all. My theory was, that the hard part of the filament get's separated from the soft part in the nozzle and because of expansion the nozzle oozes. Anyway, i had retraction speed 150mm/s and retraction distance 5mm. Now i have retraction speed 40mm/s and retraction distance 2mm and it's not oozing even if i travel over the complete printbed diagonally. @VanessaE What are your settings for retract etc.? How long are your bowdens? I've read it before in another thread but forgot :)

Sebastianv650 commented 7 years ago

@Kaibob2 wow, that's a great example related to "everything is relative"! When I wrote max retract speed, I was thinking about going from a usual default value like 25mm/s to 40mm/s. With my 801steps/mm, 40mm/s is also the maximum speed at which Marlin can drive my estepper. I never thought about 150mm/s :-D

But yes, I also made the experience that a too fast retract can make the result worse again.

VanessaE commented 7 years ago

The bowden is a bit over 50 cm length, retract is 5.5 mm at 25 mm/sec (too much faster and the motor will stall).

Sorry, I didn't think to take a photo of an under-extruded line-start, but it's not severe - just the first 10-15mm or so of total length (i.e. solid infill winding back and forth for a few turns), then it catches up.

thinkyhead commented 7 years ago

Should LIN_ADVANCE and retract be used together? It seems to me that if using "advance" then retraction is redundant.

VanessaE commented 7 years ago

@Sebastianv650 here's an example of the under-extrusion, snapped mid-print. In this case, K=260 just to make sure it was clearly visible. The movement through the part is roughly clockwise around the two holes at the right (well, there's three, but one is out of frame), with the underextruded part next to them being about half-way through that section, then a retract is performed, and the part left of the "V3" is done.

p1170022

@thinkyhead I would have to venture a guess that no matter how good the advance algorithm gets, you'll still be fighting the tendency of the filament to "bubble" its way out of the nozzle (I guess heat expansion, if there's nowhere else for the melted filament to expand into).

Sebastianv650 commented 7 years ago

@VanessaE that's a clear sign of a too high k, especialy when it gets better with a lower k value.

I would have to venture a guess that no matter how good the advance algorithm gets, you'll still be fighting the tendency of the filament to "bubble" its way out of the nozzle (I guess heat expansion, if there's nowhere else for the melted filament to expand into).

True. But I wouldn't call heat expansion for it, especialy not for oozing during travel with retract. Usualy, during a retract the solid part of the filament is a little bit lifted from the fluid in the hot end. So it would be much easier for a heat expansion to move upwards instead of squeezing through the tiny nozzle. Also there shouln't be much expansion during travel move: The molten filament is already molten, so no big further expansion. It should be simple gravity as described above with the glas of honey, combined with not 100% released pressure from extrusion before in the molten filament in the area of the nozzle tip (pressure may not be released uniform inside the melt).

Sebastianv650 commented 7 years ago

@thinkyhead see this one regarding retract and LIN_ADVANCE.

Kaibob2 commented 7 years ago

@Sebastianv650

"everything is relative"!

This made me struggle quite a long time when i built the printer. Because of beeing absolutely new to this i took advises from several posts from different sources. Everybody statet "as fast as possible" For me this was 160 mm/s so i took 150 and wondered why retract didn't work reliable.

I wouldn't call heat expansion for it

This is exactly what i'm experiencing now. When i retract, travel and prime the print comes out almost perfect. Everytime there wasn't a retract (prime) before starting a new line it looks like in @VanessaE s' picture because the drooping causes the nozzle to become "empty". It would just be great to limit retraction moves, because in fact i only need them to have the new line start with the same amount of molten filament and pressure like the last one. (I must admit that this is much easier in theory than while actually printing)

brainscan commented 7 years ago

Is there any way to have the extruder keep retracting very slowly while moving to the next line? It's just a thought but I wonder if it would help stop ooze between points.

thinkyhead commented 7 years ago

to have the extruder keep retracting very slowly

I believe some slicers may utilize this technique. May be worth checking the latest Cura and Slic3r.

VanessaE commented 7 years ago

Slic3r does not, to my knowledge, have such a feature.

Sebastianv650 commented 7 years ago

A slow, continous retraction will not prevent oozing. That would only work if the filament would be air-tight to the hot end entry. What might be a slight improvement: Retract while the travel move is already starting so your nozzle isn't standing still until the retract is done. But that's not possible as long as each move is forced to be synchrone along each axis. And it will lead to further special cases on the next line start (prime). Then Marlin would have to check if the travel move was long enough so the retract move is also done. If not, Marlin is only alowed to prime the already retracted length and every further retraction has to be canceled. I don't thing we will be happy with that..

landodragon141 commented 7 years ago

I ran some tests last night on some cubes. However I didn't calibrate my Z axis since I changed it (facepalm). I'll calibrate that and print some more cubes tonight. Other than user error this appears to be working much better.

Kaibob2 commented 7 years ago

What might be a slight improvement: Retract while the travel move is already starting so your nozzle isn't standing still until the retract is done.

This is what "Perform retraction during wipe movement" in Simplify3D does.

Sebastianv650 commented 7 years ago

No, not realy. Wipe usualy perfoms a backward move along the print move done before. And the reatraction acceleration is usualy much higher than a print acceleration that is also used for a wipe move. My idea was to have a full-speed retract while starting the normal move to the next printed line. Basicaly, that means we would start two independent actions executed in paralel. But thats "science fiction" up to now.

Kaibob2 commented 7 years ago

@Sebastianv650 You are absolutely right. Dammit. I misread the hover text the whole time. It says retract So "Wipe nozzle" has to be enabled too to make this function work. Thanks for kicking me in this direction.

VanessaE commented 7 years ago

I've continued my testing, and just don't understand what's going on. Even at a print temperature of 200, retract of 6.0 mm, and K=650, I can't get rid of the ooze in that trouble spot (the vertical wall with hole), though increasing K and decreasing temperature did help a little.

I gave it a try with K=650, 200 degrees, but (FW) retract and (Slic3r's) Z-lift disabled. There was enough stringing to knit a sweater. That would seem to suggest to me that K is still far too low, but I think the frequent rattling is causing the extruder to lose too many steps (or rather, is perhaps the result of it).

VanessaE commented 7 years ago

Once that no-retract print finished, I took a good close look at it. Surfaces, shapes, corners, that sort of thing are far HIGHER quality with retract disabled, but of course stringing everywhere. That would seem to reinforce the notion that LIN_ADVANCE is causing the extruder to lose steps.