Skip to content
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d096f9a
Smooth Linear Advance with extruder synchronisation
dbuezas Feb 24, 2025
d5bbf43
keep shaper private parts private
dbuezas Feb 24, 2025
2641451
tom's feedback
dbuezas Feb 25, 2025
1934d3b
fix ambiguous assignment
dbuezas Feb 25, 2025
0c82bd6
Undo unnecessary variable reordering
dbuezas Feb 26, 2025
52e439d
indentation
dbuezas Feb 26, 2025
08de18f
undo empty line removal
dbuezas Feb 26, 2025
1161ac2
rename Planner::lookahead with get_future_block
dbuezas Feb 26, 2025
f8b7da5
move vars to Stepper
dbuezas Feb 26, 2025
1ba3806
Fix off by one bug in get_future_block
dbuezas Feb 26, 2025
ba2aa17
Fix after moving vars to Stepper::
dbuezas Feb 26, 2025
9bf6325
Comment cruise_time var
dbuezas Feb 26, 2025
ac4439d
xy_to_e_step_ratio => e_step_ratio
dbuezas Feb 26, 2025
3375cf5
Smoothen total extrusion instead of only LA term (more silent extruder)
dbuezas Feb 26, 2025
da55973
Fix missing semi colon
dbuezas Feb 26, 2025
0718cc1
fix last_set_direction
dbuezas Feb 26, 2025
cf177d2
Remove accidentally default def of LIN_ADVANCE
dbuezas Feb 26, 2025
f8c0b87
Fix S_CURVE_ACCELERATION only macro
dbuezas Feb 26, 2025
18870c4
Rename isr step countdown var
dbuezas Mar 2, 2025
88245fb
Maxes extruder_advance_tau private and adds accessors
dbuezas Mar 11, 2025
1377c1d
Fixes "la_advance_steps does not exist for SMOOTH_LIN_ADV"
dbuezas Mar 11, 2025
5d10849
Renames target_pressure => target_adv_steps
dbuezas Mar 11, 2025
0da9b4d
Don't smooth planned extrusion since that's not delay compensated
dbuezas Mar 19, 2025
30b89e4
Do lookahead during unretractions
dbuezas Mar 19, 2025
8629643
correct indentation
dbuezas Mar 19, 2025
4485e36
Merge branch 'dbuezas/smooth-linear-advance' of https://github.com/db…
classicrocker883 Apr 9, 2025
7addaf2
update menu item
classicrocker883 Apr 9, 2025
5891806
remove ()
classicrocker883 Apr 9, 2025
6a92b0e
Merge branch '2025-April' of https://github.com/classicrocker883/MRis…
classicrocker883 Apr 10, 2025
659f152
Update - SMOOTH_LIN_ADV
classicrocker883 Apr 10, 2025
c58287e
Merge branch '2025-April' of https://github.com/classicrocker883/MRis…
classicrocker883 Apr 10, 2025
3e286a2
fix settings get_advance_tau
classicrocker883 Apr 10, 2025
4403ca3
update config_adv input_shaping
classicrocker883 Apr 10, 2025
0901437
Update - stepper.cpp
classicrocker883 Apr 10, 2025
31be45b
disable INPUT_SHAPING /revert
classicrocker883 Apr 10, 2025
38868de
added extra advance_TAU variables to settingsdata struct
classicrocker883 Apr 11, 2025
07df7d6
remove field_test (possible EEPROM error fix)
classicrocker883 Apr 11, 2025
e94423d
Update Gcode _report()'s
classicrocker883 Apr 11, 2025
b674c42
Update - dwin.cpp set TAU
classicrocker883 Apr 11, 2025
55ac318
Update - fix EOL
classicrocker883 Apr 12, 2025
775fb24
Update - Gcode _report()'s final
classicrocker883 Apr 12, 2025
6a0fb66
Update - LA TAU LCD
classicrocker883 Apr 13, 2025
e1a83a8
Update dwin.cpp SetPFloatOnClick
classicrocker883 Apr 14, 2025
12518e8
Update - M900
classicrocker883 Apr 15, 2025
2db1744
Merge branch '2025-April' of https://github.com/classicrocker883/MRis…
classicrocker883 Apr 22, 2025
fb417de
Merge branch '2025-June' of https://github.com/classicrocker883/MRisc…
classicrocker883 Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2360,13 +2360,24 @@
#define LIN_ADVANCE
#if ENABLED(LIN_ADVANCE)
#if ENABLED(DISTINCT_E_FACTORS)
#define ADVANCE_K { 0.00 } // (mm) Compression length per 1mm/s extruder speed, per extruder
#define ADVANCE_K { 0.00 } // (mm) Compression length per 1mm/s extruder speed, per extruder
#else
#define ADVANCE_K 0.00 // (mm) Compression length applying to all extruders
#define ADVANCE_K 0.00 // (mm) Compression length applying to all extruders
#endif
//#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L.
//#define LA_DEBUG // Print debug information to serial during operation. Disable for production use.
//#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz.
#define SMOOTH_LIN_ADV // Removes motion acceleration limitation by allowing to gradual ramp up of nozzle pressure
#if ENABLED(SMOOTH_LIN_ADV)
#define ADVANCE_TAU 0.01 // (secs) Smoothing time to reduce extruder acceleration due to linear advance.
// It is also the time ahead the smoother needs to look in the planner
// so the planner needs to have enough blocks loaded.
// for k=0.04 at 10k acceleration and an orbiter 2, it can be as low as 0.0075.
// The lower the better until stepper skipps
// Higher k and higher print accelerations may require larger tau to avoid skipping steps
#define SMOOTH_LIN_ADV_HZ 5000 // How often to update extruder speed
//#define INPUT_SHAPING_E_SYNCH// Synchronize the extruder shaped xy axes (increrses precision)
#endif
//#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L.
//#define LA_DEBUG // Print debug information to serial during operation. Disable for production use.
//#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz.
#endif

/**
Expand Down
19 changes: 19 additions & 0 deletions Marlin/src/gcode/feature/advance/M900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "../../gcode.h"
#include "../../../module/planner.h"
#include "../../../module/stepper.h"

#if ENABLED(ADVANCE_K_EXTRA)
float other_extruder_advance_K[DISTINCT_E];
Expand Down Expand Up @@ -105,6 +106,18 @@ void GcodeSuite::M900() {

#endif

#if ENABLED(SMOOTH_LIN_ADV)
if (parser.seenval('U')) {
const float tau = parser.value_float();
if (WITHIN(tau, 0, .5)) {
planner.synchronize();
Stepper::set_advance_tau(tau);
}
else
echo_value_oor('U');
}
#endif

if (newK != oldK) {
planner.synchronize();
kref = newK;
Expand Down Expand Up @@ -134,6 +147,9 @@ void GcodeSuite::M900() {
EXTRUDER_LOOP() SERIAL_ECHO(C(' '), C('0' + e), C(':'), planner.extruder_advance_K[e]);
SERIAL_EOL();
#endif
#if ENABLED(SMOOTH_LIN_ADV)
SERIAL_ECHOLNPGM("Advance TAU=", Stepper::get_advance_tau());
#endif

#endif
}
Expand All @@ -153,6 +169,9 @@ void GcodeSuite::M900_report(const bool forReplay/*=true*/) {
SERIAL_ECHOLNPGM(" M900 T", e, " K", planner.extruder_advance_K[e]);
}
#endif
#if ENABLED(SMOOTH_LIN_ADV)
SERIAL_ECHOLNPGM(" M900 U", Stepper::get_advance_tau());
#endif
}

#endif // LIN_ADVANCE
18 changes: 18 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,24 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#if ENABLED(DIRECT_STEPPING)
#error "DIRECT_STEPPING is incompatible with LIN_ADVANCE. (Extrusion is controlled externally by the Step Daemon.)"
#endif

#if ENABLED(SMOOTH_LIN_ADV)
#if ENABLED(MIXING_EXTRUDER)
#warning "SMOOTH_LIN_ADV with MIXING_EXTRUDER is not tested."
#endif
#if DISABLED(CPU_32_BIT)
#error "SMOOTH_LIN_ADV requires a 32-bit CPU."
#endif
static_assert(DISTINCT_E == 1, "SMOOTH_LIN_ADV is not compatible with multiple extruders.");
#if ENABLED(S_CURVE_ACCELERATION)
//#warning "SMOOTH_LIN_ADV together with S_CURVE_ACCELERATION is untested."
#endif

#if ENABLED(INPUT_SHAPING_E_SYNCH)
static_assert(ENABLED(INPUT_SHAPING_X), "INPUT_SHAPING_E_SYNCH requires INPUT_SHAPING_X.");
static_assert(ENABLED(INPUT_SHAPING_Y), "INPUT_SHAPING_E_SYNCH requires INPUT_SHAPING_Y.");
#endif
#endif
#endif

/**
Expand Down
22 changes: 19 additions & 3 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ HMI_data_t HMI_data;
#if ENABLED(PROUI_MESH_EDIT)
MeshSet_t meshSet;
#endif
#if ENABLED(SMOOTH_LIN_ADV)
smoothLA_t editable;
#endif

enum SelectItem : uint8_t {
PAGE_PRINT = 0,
Expand Down Expand Up @@ -524,7 +527,7 @@ void DWIN_DrawStatusMessage() {
void Draw_Print_Labels() {
DWINUI::Draw_String( 46, 173, GET_TEXT_F(MSG_INFO_PRINT_TIME));
DWINUI::Draw_String(181, 173, GET_TEXT_F(MSG_REMAINING_TIME));
TERN_(SHOW_INTERACTION_TIME, DWINUI::Draw_String(100, 215, F("Until Filament Change"));)
TERN_(SHOuW_INTERACTION_TIME, DWINUI::Draw_String(100, 215, F("Until Filament Change"));)
}

static uint8_t _percent_done = 100;
Expand Down Expand Up @@ -3094,6 +3097,13 @@ void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Val

#if ALL(PROUI_ITEM_ADVK, LIN_ADVANCE)
void SetLA_K() { SetPFloatOnClick(0, 10, 3); }
#if ENABLED(SMOOTH_LIN_ADV)
void UpdateSmoothLA() {
editable.decimal = Stepper::get_advance_tau();
}
void ApplySmoothLA() { Stepper::set_advance_tau(MenuData.Value); }
void SetSmoothLA() { SetPFloatOnClick(0, 0.5, 1, ApplySmoothLA, UpdateSmoothLA); }
#endif
#endif

#if HAS_X_AXIS
Expand Down Expand Up @@ -3520,7 +3530,7 @@ void Draw_Tune_Menu() {
if (laser_device.is_laser_device()) return LCD_MESSAGE_F("Not available in laser mode");
#endif
checkkey = Menu;
if (SET_MENU(TuneMenu, MSG_TUNE, 23)) {
if (SET_MENU(TuneMenu, MSG_TUNE, 24)) {
BACK_ITEM(Goto_PrintProcess);
#if HAS_LCD_BRIGHTNESS
MENU_ITEM(ICON_Box, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight);
Expand Down Expand Up @@ -3572,6 +3582,9 @@ void Draw_Tune_Menu() {
#endif
#if ALL(PROUI_ITEM_ADVK, LIN_ADVANCE)
EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, SetLA_K, &planner.extruder_advance_K[EXT]);
#if ENABLED(SMOOTH_LIN_ADV)
EDIT_ITEM(ICON_MaxSpeed, MSG_ADVANCE_TAU, onDrawPFloat2Menu, SetSmoothLA, &editable.decimal);
#endif
#endif
#if ENABLED(EDITABLE_DISPLAY_TIMEOUT)
EDIT_ITEM(ICON_RemainTime, MSG_SCREEN_TIMEOUT, onDrawPInt8Menu, SetTimer, &ui.backlight_timeout_minutes);
Expand Down Expand Up @@ -3707,7 +3720,7 @@ void Draw_Tune_Menu() {

void Draw_Motion_Menu() {
checkkey = Menu;
if (SET_MENU(MotionMenu, MSG_MOTION, 9)) {
if (SET_MENU(MotionMenu, MSG_MOTION, 10)) {
BACK_ITEM(Draw_Control_Menu);
MENU_ITEM(ICON_MaxSpeed, MSG_SPEED, onDrawSubMenu, Draw_MaxSpeed_Menu);
MENU_ITEM(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawSubMenu, Draw_MaxAccel_Menu);
Expand All @@ -3730,6 +3743,9 @@ void Draw_Motion_Menu() {
#endif
#if ALL(PROUI_ITEM_ADVK, LIN_ADVANCE)
EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, SetLA_K, &planner.extruder_advance_K[EXT]);
#if ENABLED(SMOOTH_LIN_ADV)
EDIT_ITEM(ICON_MaxSpeed, MSG_ADVANCE_TAU, onDrawPFloat2Menu, SetSmoothLA, &editable.decimal);
#endif
#endif
#if ENABLED(ADAPTIVE_STEP_SMOOTHING_TOGGLE)
EDIT_ITEM(ICON_CloseMotor, MSG_STEP_SMOOTHING, onDrawChkbMenu, SetAdaptiveStepSmoothing, &stepper.adaptive_step_smoothing_enabled);
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/lcd/e3v2/proui/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@

extern char DateTime[16+1];

#if ENABLED(SMOOTH_LIN_ADV)
typedef struct {
float decimal;
} smoothLA_t;

extern smoothLA_t editable;
#endif

enum processID : uint8_t {
// Process ID
MainMenu,
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ namespace LanguageNarrow_en {
LSTR MSG_MAX_BELT_LEN = _UxGT("Max Belt Len");
LSTR MSG_LINEAR_ADVANCE = _UxGT("Linear Advance");
LSTR MSG_ADVANCE_K = _UxGT("Advance K");
LSTR MSG_ADVANCE_TAU = _UxGT("Advance TAU");
LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *");
LSTR MSG_CONTRAST = _UxGT("LCD Contrast");
LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness");
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ void menu_backlash();
EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
#endif
#endif
#if ENABLED(SMOOTH_LIN_ADV)
editable.decimal = Stepper::get_advance_tau();
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ Stepper::set_advance_tau(editable.decimal); });
#endif

#if DISABLED(NO_VOLUMETRICS)
EDIT_ITEM(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
Expand Down Expand Up @@ -727,6 +731,10 @@ void menu_advanced_settings() {
EXTRUDER_LOOP()
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10);
#endif
#if ENABLED(SMOOTH_LIN_ADV)
editable.decimal = Stepper::get_advance_tau();
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ Stepper::set_advance_tau(editable.decimal); });
#endif
#endif

// M540 S - Abort on endstop hit when SD printing
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/lcd/menu/menu_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "menu_item.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/stepper.h"
#include "../../module/temperature.h"
#include "../../MarlinCore.h"

Expand Down Expand Up @@ -221,6 +222,11 @@ void menu_tune() {
#endif
#endif

#if ENABLED(SMOOTH_LIN_ADV)
editable.decimal = Stepper::get_advance_tau();
EDIT_ITEM(float54, MSG_ADVANCE_TAU, &editable.decimal, 0.0f, 0.5f, []{ Stepper::set_advance_tau(editable.decimal); });
#endif

//
// Babystep X:
// Babystep Y:
Expand Down
Loading
Loading