Skip to content

Commit

Permalink
🚸 Nonlinear Extrusion polynomial Av^2+Bv+C (MarlinFirmware#27162)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovodroid authored Jun 10, 2024
1 parent daeffbc commit d9fc4f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/gcode/feature/nonlinear/M592.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d9fc4f3

Please sign in to comment.