If you're using flow to correct for an incorrect source diameter, which
is probably the main usage when using the LCD, then LA shouldn't be
adjusted.
It's still unclear what the effect of M221 in gcode should be regarding
overall extrusion width. If M221 means "thicker lines", then LA should
also be adjusted accordingly.
This stems from the fact that the source diameter/length needs to be
known in order to determine a compression factor which is independent of
the extrusion width, but the FW only ever sees one value currently (the
extrusion length) which combines both.
This makes it impossible for the FW to adjust for one OR the other
scenario, depending on what you expect for M221 to mean.
The e/D ratio should be calculated using the extrusion length.
As such, purify the e_D_ratio from the current extruder multiplier in
order to account correctly for flow adjustments.
PR #2591 made LA compression always account for retractions instead of
discarding the current compression steps. While this fixed overextrusion
in short segments followed by wipes, it uncovered another issue in how
the compression steps are spread during the trapezoid calculations
leading to gaps in segments followed by retractions (as highlighted by
/some/ prints in #2693).
LA1.5 always computes the required target compression steps for a
segment at nominal speed. Because of how the extra steps are allocated
using multiples of the accelerating frequency, if the segment is
truncated before cruising is reached, an additional cycle of steps can
be inserted before deceleration starts. Deceleration is also not
guaranteed to be symmetric where up to _two_ cycles can be skipped
depending on the stepping cycle, leading to a situation where a
symmetric acceleration/deceleration block will lead up to a cycle of
accumulated compression.
While forcing an the extra step during deceleration is possible by
tweaking the error term (eISR_Err), this doesn't guarantee balance in
all cases. The underlying issue is that the function is aiming a
compression which cannot be reached (nominal speed), and not at the
effective max speed reached in the trapezoid, thus moving the average
result higher over time.
We fix this by calculating the effective maximum speed (and compression)
reached during the trapezoid, which stops compression on the required
cycle irregardless of the error term, balancing the result.
This is the first unoptimized POC: this is not for production: a lot of
calculations are redundand and could work directly in steps/s^2.
* Combine repeated calls into functions with much less parameters -> 2KB
down.
* Save some bytes by removing unnecessary 1-character strings: "x" -> 'x'
used in SERIAL_xxx printing macros.
This is also saves some CPU cycles
* Fix compilation for MK25S and MK3
* Copy surrounding indentation
* Fix compilation for a rare HW setup
* rename mesh_planXX_buffer_line back to mesh_plan_buffer_line
* Remove active_extruder from remaining plan_buffer_line_destinationXYZE
calls and one more fix of indentation
Allow the LA 1.5 MAX value to be configured in Configuration_adv.h.
Define a customizable LA10<>15 detection threshold in function of the
above limit.
Clamp the result of of the LA10->15 return value to always
respect the new LA_K_MAX.
Handle uniformly compression & decompression at any stage of the
trapezoid.
Compared to before, this now enables LA compression also in the cruising
step (handling the converse of a chained wipe), as well as decompression
during acceleration.
Both of these can happen as a result of jerk moves, but are incredibly
rare. This is mostly needed to allow rapid decompression directly at the
acceleration step during travels between a retraction&deretraction.
We also check for the pressure level in a single place, reducing code
size as well as disabling LA earlier when not needed for the rest of the
block.
Perform the check one step earlier, avoiding 32bit overflow for very low
compression factors.
Fixes#2566 (although for K15 to have effect the conversion probably
needs to be adjusted on the low end)
LA assumes all the nozzle pressure is released at the end of each
extrusion, which makes calculating the required pressure advance during
travels and retracts not normally necessary.
This is not always true in our planner, since the E axis is explicitly
ignored when not in use, but also due to E-jerk allowing a non-linear
jump in speed. And since the compression factor is currently tied by XYZ
axes and not independently calculated, this can result in a wrong
estimation of final pressure in several conditions.
To avoid overburdening the planner, change the underlying assumptions
about backpressure:
1) Pressure is no longer lost when LA is disabled: if a retract is
followed by an unretract of the same length, the pressure will be likely
maintained entirely. This also holds true during travels, as long as the
retract length can overcome all the backpressure (which is the case in
all but the most noodly materials)
2) Pressure is released as soon as possible during travels: we now
enable LA also during travels, but under the sole condition of undoing
excess pressure.
We do that by checking for backpressure at the start of any segment
without an acceleration phase that doesn't have any E-steps (a result
which can happen due to the above). If pressure is not nominal, we run
the extruder in reverse at maximum jerk as long as the segment allows
us, since proper acceleration would be prohibitive at this stage. As the
pressure difference resulting by the above is still _very_ low, any wipe
or short travel will be able to equalize the nozzle pressure *before*
extrusion is resumed, avoiding ooze.
When calculating the advance tick interval, be sure to check for integer
overflow. Very low step rates can result in values exceeding uint16_t
causing premature LA tick delivery.
An overflow resulting in zero would also block in an infinite loop
within advance_spread().
Even though such rates are worthless in terms of compensation and often
result in 0 extra ticks as well, do not disable LA for the block (as
doing so would reset the count for short segments) and do not check for
zero in multiple paces either.
Saturate the interval instead, delaying any further tick to the next
block.
To maintain an accurate step count (which is required for correct
position recovery), any call to plan_set_position&co needs to be done
synchronously and from a halted state.
However, G92 E* is currently special-cased to skip the sync (likely to
avoid the associated performance cost), causing an incorrect E step
count and position to be set. This breaks absolute position recovery,
miscalculation of the LA factor and possibly other weird issues.
We rewrite the handling of G92 to always sync but still special-case the
frequent "G92 E0" for performance by using a free bit in the block flags.
To avoid a sync, we relay the request for reset first to the planner
which clears its internal state and then relays the request to the final
stepper isr.
Since the global feedrate can be similarly modified for moves ahead of
time, save the original feedrate in the planner as we do for
gcode_target.
This avoids having to undo feedmultiply (and machine limits!) from
"nominal_speed" as previously done.
Thanks @leptun
When starting to replay existing USB/SD commands from a recovery state,
an immediate relative move needs to compensate for a previously
interrupted move. This is almost the norm for the E axis.
Instead of saving the relative status of the move (which needs to
account for the world2machine conversion and is not always available on
a chunked move split by MBL) save directly the calculated target
position for the move in the original plan, which is easy to replay.
While handling moves in a recursive plan, such a filament check,
ensure restore_print_from_ram_and_continue unwinds the stack by
aborting early from any call that waits on the planner.
This currently only handles G1 moves, but hard-coded behavior that can
trigger recursive behavior (such as filament change) will probably have
to be checked too.
Do not store the block e_D ratio, store directly the computed
compression factor so that we can recompute the advance steps
quickly and update them in sync with the acceleration rates.
When recovering from a pause, the nozzle is often primed while
being lowered. If LA is triggered under such a move, the pressure
advance will be wasted.
Timing functions (millis, micros and delay) replaced in whole source, defined in Marlin.h.
This commit enables original implementation (SYSTEM_TIMER_2 undefined)
Verified with passed complete wizard process.