[FR] Get Linear Advance + S_Curve completed and reliable #22547
Description
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 activating EXPERIMENTAL_SCURVE
at the same time. Where EXPERIMENTAL_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:
distance after each Phase of the Z:
s(0.01) = (0.5*1250*0.01*0.01+0+0)mm = 0,0625mm
s(0.02) = (0.5*2500*0.01*0.01 + 12.5*0.01 + 0.0625)mm = 0.3125mm
s(0.03) = (0.5*1250*0.01*0.01 + 37.5*0.01 + 0.3125)mm = 0,75mm
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:
(50mm/s)/0.03s = 1666.66mm/s²
s(0.03) = (0.5*1666.66*0.03*0.03)mm = 0.75mm
So the idea is, to either
- calculate the equivalent acceleration of the S_Curve and use it in Linear_advance
or - to calculate a S_Curve acceleration that is equivalent to the triangular acceleration imposed by the desired acceleration.
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.