-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
[FR] Get Linear Advance + S_Curve completed and reliable #22547
Comments
wow, wasn't aware that EXPERIMENTAL_S_CURVE was just a flag for the time being, never checked other occurrences of this flag in the code :-) I'd go with option 2 - having a reasonably accurate print time prediction seems important to many users. On the other hand, redefining accel as effective accel seems a reasonable price to pay... Curious to see what others are thinking... PS: Yes, my Ender 3 V2 is acting up with weird sounds if I play around with K values in LIN_ADVANCE at high accelerations... (S_CURVE commented out) |
The feature is still experimental in the sense that this post represents one of the few confirmations we have that it is behaving okay and not causing strange issues. Any improvements to this feature to make it more robust will be much appreciated. It would be especially useful to put a scope on a variety of 8- and 32-bit boards to observe how XYZ and E behave together and to see the effects of various adjustments. The time I personally have for testing is limited, due to general management of the project, so any help in the area of testing and refinement of these kinds of details is also much appreciated. |
@thinkyhead |
@MarkusThur sure, sound is limited to extruder (Hemera direct drive). Comes from hard retraction moves. More pronounced at higher extruder accels or feed rates, looks like I have to stay below 25mm/s retract speed. NO noise at retraction = OFF. Therefore, I was assuming that IF accelerations in all axes are ramped over S-shaped curves, extruder / filament should 'see' lower effective accels / speeds and run more silently... |
@RipperDrone thank you for your input, this fits to what I am asuming, and will look for in the code. 25mm/s shouldn't be too much, especially as you shoudn't need much retraction on a Herma anyways, and with Lin_Advance the needed retraction of a direct extruder should go to nearly 0. On my bowden the needed retraction reduced from 6.5 to 7.5mm to 1 to 1.5mm, as Lin_Advance already reduces the pressure in the nozzle and relaxes the material in the bowden. On a direct drive the effect should be much higher, bringing the needed retraction close to zero. So I suspect there is something going on, that leeds to multiple direction changes while advancing Linear and then retract, which should not be. I'd like to see your settings (and the one the slicer may do) for Ejerk, and Eacceleration and the K value for linear advance. to exclude that wired settings cause it. Normaly a retract should even be "easier" as the material already got "riffled" by the forward movement and the grip is better than the on "round material" and the "counterforce" is close to zero, as it does not need to push the material through a tight nozzle. If you can, maybe a screen or copy of the printers answer to M503 could help us both. |
@MarkusThur Thank you. Pls find my 503 gcode response as follows: It has to be noted that I tuned down accels and feedrates to suppress the annoying retract noises. Going back to higher values will trigger them again... K=0.04 is very moderate, setting higher K values will ruin the K factor test print (no continuous line on accelerations and decelerations). xyz test cube still has overshoot corner edges, so seems printer needs higher K, however I cannot test since the retract issue spoils the prints when I try... Printer loads and unloads filament smoothly, PTFE tube has no increased friction, gripping spring force set to "normal" in Hemera (flush to surface) but tried min to max as well. Jerk is set to Marlin stds (8,8,.4,5). Tried higher and lower values as well... |
@RipperDrone I looked into it, on first view nothing directly strange. On second view I have some questions to your settings: |
@MarkusThur Very interesting, you might be up something there... let me follow up:
In a nutshell, what you'd recommend trying out is 45mm/s E max feedrate and reduced xyz speeds (down to to which values) to rule out that the screachy-eachy noise has to do with accel settings? :-) |
@RipperDrone Concerning your other motors, if the original steppers were TMC2208 in UART mode, set to 800ms RMS by firmware 800ms should be fine also with the 2209. https://reprapworld.com/customer/service/technical_information/adjusting_stepper_driver_current_on_the_ender3_v2/ And now we come to difference between Cura setting and firmware: So cura tries and maybe even uses 4x the max speed, you limit in Firmware and 2x the accel you did set the firmware limit to => It's unsure, what will be done. I just came to another idea also, I will try to visualize it. In principle I have the feeling, with your settings, the printer never leaves the accel and decel phases. As I am working on a way to easily visualize the movement in general in order to get a better idea on what happens. |
Got a visualisation for trapezoid accelerated movement. (on S_curved movement, I'm still working).
This may help to figure out, what may cause the noise / supresses the noise in your extruder. with your current settings, you need: Am pretty sure that there something wired is going on in combination with linear advance, as we definitely run into limits. |
@MarkusThur Thank you so much for your time you are putting into this - even not being 100% sure yet whether I am facing a general S_Curve accel issue or mismatching parameters. Let's see, here is my follow-up:
|
@RipperDrone What I had is, I generaly use arcWelder in order to reduce G-Code Size and find curves are a bit nicer with it, then if cura decides how to square a circle. But yesterday I printed something with a lot of different curves, leading to slow down due to calcs not fast enough and then I got first time strange noises from the extruder during those slowed down curves. Then I printed same thing without arcWelder post processing, Problem gone. Maybe you can do something similar to increase or decrease CPU load. So whats suggestion:
|
@MarkusThur Exciting - never used ArcWelder but found somewhere that it is not recommended to use it along with LIN_ADVANCE due to some alias / interference effects. CPU load is something to look into, however with my 32bit board and not overly complicated contours I'm not sure this is the direction to chase suspects - wierd noise even happens on a simple xyz cube! Which rather leads me into a direction of incorrect handling of accels / decels in conjunction with extruder feed + particularly extruder retracts. I tried to simplify the model in Windows 10 3D Builder (e.g. from 10k splines to 700 splines for model approximation), but the issue persisted.
Will do some further tryouts at different settings and report back if any new findings materialize :-) |
@RipperDrone So from my suggestions only one stays for you, a tryout with deactivated LIN_ADVANCE as the others you already did. (hope we don't bore all that that are notified on this, but I have the very hope, this will create the right idea.) In order to have same understanding what those options do I summarize, what I understood, they should do: LIN_ADVANCE:Reduces / Increases the nozzlepressure on accelrations / decelerations, as this is not a simple linearity to the movement, because of compression / decompression of material. Therefor it predicts the needed additional movement of the Extruder by the K factor. S_CURVE_ACCELERATION:Does a S_Curved acceleration profile instead of the "simple" trapezoid. This gives a more smooth movement, but is more difficult to calculate and predict. It's "unknown" how exactly the S-Curve is formed, but this is readable from the code. S-curved acceleration is a typical technic to get better movement profiles for all kinds of electrical motors, as the "impossible" dirac impulse on the change of accel, is not only transformed by the characteristics of electronics and mechanics, but by reducing it. This shall and does reduce resonancy and swinging caused by it. There is no "user influencable" factor to influence how the curve is formed at the moment. JUNCTION_DEVIATION:Is a concept how to approach / calculate the cornering speed for different corner angles, especialy corners that are not nearly a straight or a nearly a return. |
@MarkusThur You seem to be as obsessed with optimizing things as I am :-) Tried to set K factor to 0.0 (has been @0.04 only before), and printer got completely silent in retract moves, even at high extruder retract speeds of 40mm/s retract and 45mm/s re-feed. Print speed still @100mm/s x-y. Accels 500, 500, 100. Jerks 10, 10, 0.3, 5. Retract set to .4mm which was optimum acc retract tower test. Results of xyz test cube quite good, need to reduce z offset a bit, first layer needs to be more dense. Main challenge is overshoot at cube edges at higher speeds, this is why I tried to get my head around LIN_ADVANCE. Didn't find an effective way of really un-bulging the edges. Maybe choosing super-low jerk values could be an option, but then printing times become very long. Getting a good combined S-curve mode working along with LIN_ADVANCE would do the trick, I suppose. Any other thoughts? |
Tried another run with halved jerk values, looks exactly same. Taking edge un-bulging to next level will require LIN_ADVANCE (and S-Curve smoothing), I suppose... |
@RipperDrone
What you could check please is, if strange sounds also occur, if you use Linear_advance but do not use S_Curve_Acceleration. Now the calculations to that:
the distance during the decelleration is:
therewith the volumina to be printed is:
this needs a fillament feed of
for the decompression the k value says, you have to substract following from the needed steps:
both values are bigger than the needed extrusion, so it has to come to a "retract" during the break. and a additional feed during the following acceleration e.g. on a 90° corner or a return move like during infill. 5 - 10200 steps are quite many, and much more than the gearbacklash of the extruder, the stepper (with 1/16 microstepping) 3200 steps are a full turn, so it will do aprox 3 full turns backwards, this is a lot of movement. And so I am more close to what exactly I should look at. Most probably, the "retraction" will not be done, where the decel starts and then the needed value will be feeded nor it will retract and coast to the end i asume. Thanks a lot, as I now get a idea where to search. |
@RipperDrone |
@RipperDrone |
@RipperDrone |
@MarkusThur That's a lot of new findings, my sincere admiration for your endurance to chase this noise :-) Seems you are homing in on mechanical gear / gap tolerance settings. I can only state that my Hemera was brand new when the noise started (from Day 1 already), and when I took it apart, I checked that the gears could move freely but were sitting snug without any wiggle. It could actually be some close combing of drive shafts (and filament), and I agree it is stronger when combined with LIN_ADVANCE, but also happens on retract only IF retracts are too big in distance and/or too fast for the given retract distance. I'm still not 100% sure we are talking the exact same noise on our printers... to me the Hemera retract sounds like it is jerking in the retract moves, maybe it's even in the re-feed part of the move where filament can not be molten/softened enough at high feed speeds, so it chokes from trying to push solid material through the nozzle. I tried raising temps by 20K, didn't help, though... |
@MarkusThur found this video - noise is not recorded well and not exactly with the screetchy undertone, but this is exactly what I observe as well. Just a little more screetchy the faster I go :-) Is this exactly what you can reproduce as well? Whereas this is NOT the noise we are focusing on: |
Yes and no... We are definitely not locking for that noise from the second video. That one obviously is jumping gear wheels and a issue of wear or bad assembly of the Extruder. The noise I could produce was a little more obvious and a little more "spring like" but yes exactly that. This shot is from the hemera video of E3d. You see the two shafts, the Igus bearing and the normal bearing on the other shaft. From my view, the hemera must be even more sensible to that issue, as it has two pairs of wheels and two drive shafts that have to align properly and work together while having the chance of being canted or locked. |
@RipperDrone |
@MarkusThur Hemera has a no-wiggle transition fit roller bearing for the shafts, therefore tolerances should be quite precise. Anyway it makes sense that I might be able to slightly adjust the gear meshing tolerance (center distance) by losening and retightening screws under some gear load. Not sure I'm up for this after having disassembled it and put everything back together only 2 weeks ago... for now I found an acceptable balance of low k factor (0.02) and some higher retract speeds / accels so the noise is at least softened somewhat. Print results are good enough, overshoot still occurring, I'l trim jerk (if classic_jerk) or junction deviation (otherwise) a little more and will then try to make my peace with the remaining noise. At least until some new feature involving an S-curved acceleration comes up - sacrificing a little printing time for smoother moves and longer lasting gearing. :-) |
Hold on @thisiskeithb, it's not quite resolved yet. But #24533 brings it a lot closer. It's easy now - by which I mean it is easy to see what needs to be done. But there is some tightly optimised assembler to modify. Will need another PR. |
@tombrazier : I was the one who wrote the Bézier curve code in assembly. I have read that Linear Advance could work with it, if the _eval_bezier_curve() function could also calculate acceleration.
If we need to get acceleration, we should differenciate that formula respect from time:
That is the expression to compute, assuming we want to get acceleration in steps/second^2
This eventually requires 4 extra multiplications, and 2 additions. The other question is the exact acceleration units needed for linear advance computations... |
@ejtagle Your name is familiar to me from exploring your code, which is excellent. I was planning to differentiate the polynomial as you suggest. I am running on an AVR and it has a fair bit of processor capacity still available after some optimisations so I am somewhat hopeful. Anyway, the main thing was that it was hand coded in assembler and I just needed the time to modify that. With one thing and another I haven't got round to it yet. LA needs the same units as the rest of the stepper code, steps and seconds. In this code and the similar deceleration code, the variable Marlin/Marlin/src/module/stepper.cpp Lines 2006 to 2027 in 0d8a695
|
Do you fancy doing the assembler code work? |
I could do it. The main issue here is getting sensible units, because the ASM is using fixed point to compute things. |
I didn't like the cost of the division either which is why I have not explored that option. However it has suddenly just struck me that there doesn't need to be a division. The time interval between calls to |
Fortunately, this just doubles (and doubles), so somewhere in there a shift operation using |
Indeed. It's in I'll finish my work on IS first and then hit this. Hopefully will be quick. |
You are right. There is already a division done in code... Do you want to smile a bit ? ... ;) ... I also was the one that implemented the function get_period_inverse() that calculates 1/d using a fast newton-rapson iteration xD ... I just forgot about that ... If needed, that routine could also be reused, but you are right. Time is the inverse of speed, and also, as @thinkyhead said, ADAPTIVE_STEP_SMOOTHING uses integer factors (yes, I was also the one that did it, the bresenham.txt file explaining the ADAPTIVE_STEP_SMOOTHING is mine) so, the division can be replaced by a way faster multiplication 👍 |
There have been several people on Discord asking whether this work was ever finished and whether...
are now compatible with one another. Is anyone who was involved in this FR able to comment on this please? (As an aside, in the LCD menus and Gcode, you can turn Linear Advance can be adjusted to/from zero and Input Shaping can be turned on and off in each dimension, but AFAIK there is no UI or Gcode to turn on/off or adjust S-Curve, XY Frequency Limit or Adaptive Step Smoothing. Are these things that really should have Advanced Configuration menu entries and Gcodes?) |
For LA & S_CURVE, I never did implement the solution I mentioned in #22547 (comment). The main reason was that with input shaping, S_CURVE is now far less relevant. Also LA & S_CURVE can coexist and it is still better to have LA than not have it when using S_CURVE even though it is less than theoretically perfect. Other considerations were that I have also added a lot of optimisations to the stepper code which needed to settle and that I just haven't had the time. But mainly, lacking the motivation because of the existence of IS, I don't think I will ever get round to it. IS will work with any of the other items on the list (that is the ZV one I implemented - I don't really know about the FT_MOTION implementation). ASS is also compatible with everything, I think. As far as I can remember it always has been but I might have forgotten something. I don't know XY frequency limit well but I think it just adjusts print speed, so should be independent of everything else and work with everything else. i.e. I think the only limitation is LA & S_CURVE but am open to correction. And rather than use S_CURVE, I'd just recommend IS now. (Which is sad because S_CURVE is really lovely code.) |
@tombrazier Thanks for such a prompt response. If I may, can I just check that I have understood this ok. Your recommendations are:
|
Note also, the combination of IS with S_CURVE will work but is probably unnecessary. Maybe, just maybe, there's an edge case where there are multiple resonant frequencies and S_CURVE performs better than ZV input shaping. But even in such a case the key limitation of S_CURVE is that it does not affect cornering discontinuities which is where ringing and layer shifting primarily originate. S_CURVE is only applied to the acceleration segments of the trapezoidal speed profiles. IS is applied to both. |
@tombrazier Sorry - still confused by your most recent point 1. Is the use of "IS" intentional or a typo i.e. did you mean "forget S_CURVE and use LA instead"? Ultimately I (and probably most everyone else) just want a version of firmware that gives the best results. |
IS is input shaping. |
I still see solid value in S-Curve, even with IS. When IS compiled in, I can enable / disable as needed depending on project accuracy requirements. When I have it off, I want S-Curve active. On a home users machine, just relying on IS is acceptable but its not a viable solution from an professional / engineering standpoint. Adaptive Step Smoothing if my memory is correct drastically increases the stepper ISR rate, so it is called even more frequently than steps could possibly be sent there, in order to ensure planned moves are started ASAP. As far as I know there has never been an incompatibility issue with it. It just complicates the math slightly for some of the execution count code discussed above because it means the rate isnt fixed and needs a calc. |
@InsanityAutomation So I should just enable everything? Is there a menu or Gcode switch to turn on/off S-Curve? (I have posted a PR for Marlin to allow you to compile firmware with Input Shaping included but turned off (by specifying frequencies of zero.) |
You can already compile IS in by default by enabling & setting |
I am compiling Marlin for several hundred combinations of variants of a particular model. For the model I have (and those with the same physical shape and extruder (there are size variants and extruder variants) I can calibrate IS frequencies and Zetas, but for other variants where I cannot calibrate because I don't have a physical machine I want to enable IS but turn it off - and I don't want to include a SHAPING MIN FREQ if I have no idea what that should be. |
You'd set it to a value like |
I was under the impression that the lower the min. freq. the greater the RAM usage. |
Yes, that's how it works. Marlin needs to know how much ram to allocate to IS buffers at compile time and that is done through |
Hmmm. I think you are right - in the absence of any actual frequencies, you need to guess a frequency. Since this is for an AVR board, there is a minimum frequency supported by the board anyway, so I need to work out what that is and use it. |
since the usual frequency for IS is between 40 and 50Hz and the algorithm centers on a set frequency, a minimum frequency of 30Hz is very likely to be more than sufficient. |
I am having trouble determining the Y frequency on my bed-flinger. Obviously the bed has significant mass, so I would imagine that the resonant frequency would be quite low, however determining what this is using either the MarlinFW.org tests or the th3dstudio.com tests is proving difficult. The IS values as best as I can determine from both these sets of tests are:
Also, the results on a calibration cube are showing almost exactly the same ringing in both directions with and without IS on (but I really need to print a few more experiments on this to check it). |
If the actual frequency at runtime ends up lower than I also have an AVR bedslinger and shaping works really well. When RAM is a limitation, I think the best way to pick |
These frequencies look reasonable for a bedslinger. Zeta of 0.5 for Y looks looks a bit high. The best way to measure the frequencies in Marlin is with the single layer pattern at https://marlinfw.org/tools/input_shaping/freq-calibr.html. I suggest you do this, take a photo of it and ask for help interpreting it in #support-chat on the Marlin Discord server. |
I don't think that my problem is interpreting them. The explanation on the MarlinFW page is clear, and the prints come out looking similar in general terms. The problem is that the Y line doesn't actually show much vibration (because of the mass of the bed I think) - I tried editing the gcode, reversing the zig-zags to keep the zig length the same but half the width and so keep the frequencies the same but more exaggerated movement, but this didn't help. And most of the Y zeta pattern except for the 0.5 line was so broken up it was difficult to determine anything. As soon as I get time I will redo these tests and ask on Discord as you suggest. The th3dstudio ringing tower printed well, and so I took the frequencies (as best I could) off that. I will share that on Discord too. |
Is your feature request related to a problem? Please describe.
This feature request, or better first Request for discussion, is related with the issue described in #14728 [BUG] Linear advance incompatible with S-Curve acceleration
If I see it right this issue is not solved, except by the sanity check that warns / throws a error if you enable
LIN_ADVANCE
and S_CURVE_ACCELERATION without marking you explicitly want it by activatingEXPERIMENTAL_SCURVE
at the same time. WhereEXPERIMENTAL_SCURVE
does not activate any special s-curve feature, just only marks that you definitely want it.I use https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S, which relies on Marlin 2.0.5.4 on a Anycubic Mega S.
There Linear_Advance and S_Curve are activated by default and work very well. The described problems are not seen.
Problem observed is (that obviously) the time prediction is a mess, as triangular movement is exspected and S-Curve Movements are obviously slower.
But Linear_advance with a K factor of 0.51 works well with printing speed of 50 to 70 mm/s, as well as printing acceleration of 3200 mm/s^2 is possible without interfering with print or causing strange "sound" of the extruder. Starting with a print acceleration of 3600 mm/s^2 the print gets a little "dirty" as the break is to hard and causes vibration / resonance, but does not cause issues on the extruder.
Travel acceleration even up to 4500 mm/s^2 is possible, but 4000 mm/s^2 travels more nicely and vibration / resonance on brake is absorbed without hampering a print at travel speed of 120 mm/s. Faster travels are possible, but may end in step losses of the bed and / or imprecise positioning at end-position.
Are you looking for hardware support?
NO
Nevertheless, related with statement above is following hardware:
Anycubic Mega S with:
Trigorilla 0.0.2 board, using a ATMEGA2560
TMC2208_standalone Steppers
So obviously S_Curve + Lin_Advance is possible on a AVR Controller, or was possible till 2.0.5.4
Describe the feature you want
What I want to do / the feature to be requested is as follows.
Look into the issue, especially what may changed between there and now in
S_CURVE
and / orLINEAR_ADVANCE
Discuss potential solutions (independent if it works together or not, there is a issue in time prediction of the
S_CURVE
and therewith the point whereLIN_ADVANCE
has to start doing it's work)Implement the solution
Additional context
From a first feeling, the main issue is the longer and "hard" to predict time an
S_CURVE
accelerated movement will need.The S-curve accelerated movement takes a longer time, as the maximum acceleration of the
S_CURVE
is the same as the one of a "triangular" movement. In worst case, the S_Curve is not even able to reach max. speed and does not reach maximum acceleration, similar to the "normal" triangular movement, which at some point is not able to reach travel speed, before braking has to start. But this point is obvious earlier for S_Curved movements.But for any S_Curve accelerated movement, there is a "corresponding" triangular movement, that has the "same" timing,
e.g. a triangular acceleration from 0 to 50 mm/s with a acceleration of 2500 ,mm/s^2 obviously needs 0.02s to reach the max speed and will travel 0.5mm during that time. (exact half of what it would have been at full speed, or an unaccelerated movement with 25mm/s). An S_Curve accelerated movement with a
max_acceleration
of 2500 mm/s^2 will need a little longer due to the lower accel at the beginning and ending of the acceleration phase,For ease of explaination I use a Z_Curve with following parameter,
form 0 to 12.5 mm/s use 1250 mm/s^2 (accel/2)
from 12.5 to 37.5 mm/s use 2500mm/s^2 (accel)
from 37.5 to 50 mm/s use 1250 mm/s^2 (accel/2)
This way we will need 0.3s to reach travel speed. And the moving distance will be:
This exactly equals an unaccelerated movement with 25mm/s for 0.03 seconds. so this also shall equal a movement with a linear acceleration of:
So the idea is, to either
or
Advantage of solution one is, the set max_accel is not exceeded, disadvantage is, time prediction for the total print still stays a mess.
Advantage of solution two is time prediction of the print does not need to know if it is S_Curved or not, disadvantage is the max Accel is exceeded by the "form factor" of the S_Curve.
Solution two imposes, that the max_accel of printers, that already use S_Curve, would have to reduce their max_accel value, as it now would represents the "equivalent" acceleration instead of the real acceleration.
Both solutions could be implemented in a first approach, using the
EXPERIMENTAL_SCURVE
flag, which would give the flag a more "useful" meaning.I am happy to hear your opinions on it.
The text was updated successfully, but these errors were encountered: