From d9fc4f3a9937cdd366793a67444dbf5d15ecfd2d Mon Sep 17 00:00:00 2001 From: Vovodroid <vovodroid@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:42:28 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Nonlinear=20Extrusion=20polynomi?= =?UTF-8?q?al=20Av^2+Bv+C=20(#27162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/feature/nonlinear/M592.cpp | 6 +++--- Marlin/src/module/stepper.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/gcode/feature/nonlinear/M592.cpp b/Marlin/src/gcode/feature/nonlinear/M592.cpp index b1c4ca4be79..2fc02133ecc 100644 --- a/Marlin/src/gcode/feature/nonlinear/M592.cpp +++ b/Marlin/src/gcode/feature/nonlinear/M592.cpp @@ -35,12 +35,12 @@ void GcodeSuite::M592_report(const bool forReplay/*=true*/) { /** * M592: Get or set nonlinear extrusion parameters - * A<factor> Linear coefficient (default 0.0) - * B<factor> Quadratic coefficient (default 0.0) + * A<factor> Quadratic coefficient (default 0.0) + * B<factor> Linear coefficient (default 0.0) * C<factor> Constant coefficient (default 1.0) * * Adjusts the amount of extrusion based on the instantaneous velocity of extrusion, as a multiplier. - * The amount of extrusion is multiplied by max(C, C + A*v + B*v^2) where v is extruder velocity in mm/s. + * The amount of extrusion is multiplied by max(C, A*v^2 + B*v + C) where v is extruder velocity in mm/s. * Only adjusts forward extrusions, since those are the ones affected by backpressure. */ void GcodeSuite::M592() { diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ba4030f0d62..eed3973afaf 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2234,7 +2234,7 @@ hal_timer_t Stepper::calc_timer_interval(uint32_t step_rate) { #if ENABLED(NONLINEAR_EXTRUSION) void Stepper::calc_nonlinear_e(uint32_t step_rate) { const uint32_t velocity = ne_scale * step_rate; // Scale step_rate first so all intermediate values stay in range of 8.24 fixed point math - int32_t vd = (((int64_t)ne_fix.A * velocity) >> 24) + (((((int64_t)ne_fix.B * velocity) >> 24) * velocity) >> 24); + int32_t vd = (((((int64_t)ne_fix.A * velocity) >> 24) * velocity) >> 24) + (((int64_t)ne_fix.B * velocity) >> 24); NOLESS(vd, 0); advance_dividend.e = (uint64_t(ne_fix.C + vd) * ne_edividend) >> 24;