[FR] Input Shaping - Marlin 2.1.2 #402

Closed
opened 2022-12-21 13:04:26 -06:00 by St-Aris · 8 comments
St-Aris commented 2022-12-21 13:04:26 -06:00 (Migrated from github.com)

Description

Marlin 2.1.2 has a new Klipper like input shaping feature:

https://marlinfw.org/docs/gcode/M593.html

Any chance on working on a port of this - looks soooo interesting. Perhaps in the next major release - i'm sure it will be getting a fair bit of tweaking.

Feature Workflow

(https://marlinfw.org/docs/gcode/M593.html)

Additional Information

<!-- ------ PLEASE USE THIS TEMPLATE! -------- Have you read all Wiki articles in cluding the FAQ? https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/wiki Do you want to ask a question? Are you looking for support? Please don't post here. Instead please use one of the support links at https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/issues/new/choose --> ### Description Marlin 2.1.2 has a new Klipper like input shaping feature: https://marlinfw.org/docs/gcode/M593.html Any chance on working on a port of this - looks soooo interesting. Perhaps in the next major release - i'm sure it will be getting a fair bit of tweaking. ### Feature Workflow <!-- Please describe the feature's behavior, user interaction, etc. --> (https://marlinfw.org/docs/gcode/M593.html) #### Additional Information * Provide pictures or links that demonstrate a similar feature or concept. https://marlinfw.org/docs/gcode/M593.html
stklcode commented 2022-12-22 02:58:05 -06:00 (Migrated from github.com)

With the fix #405 is merged into master, the full 2.1.2 upstream sources are available.

The (experimental) feature can be enabled adding something like this to the configuration:

/**
 * Input Shaping -- EXPERIMENTAL
 *
 * Zero Vibration (ZV) Input Shaping for X and/or Y movements.
 *
 * This option uses a lot of SRAM for the step buffer. The buffer size is
 * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT,
 * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can
 * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE.
 * The higher the frequency and the lower the feedrate, the smaller the buffer.
 * If the buffer is too small at runtime, input shaping will have reduced
 * effectiveness during high speed movements.
 *
 * Tune with M593 D<factor> F<frequency>:
 *
 *  D<factor>    Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes.
 *  F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes.
 *  T[map]       Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet)
 *  X<1>         Set the given parameters only for the X axis.
 *  Y<1>         Set the given parameters only for the Y axis.
 */
//#define INPUT_SHAPING_X
//#define INPUT_SHAPING_Y
#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y)
  #if ENABLED(INPUT_SHAPING_X)
    #define SHAPING_FREQ_X  40          // (Hz) The default dominant resonant frequency on the X axis.
    #define SHAPING_ZETA_X  0.15f       // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping).
  #endif
  #if ENABLED(INPUT_SHAPING_Y)
    #define SHAPING_FREQ_Y  40          // (Hz) The default dominant resonant frequency on the Y axis.
    #define SHAPING_ZETA_Y  0.15f       // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping).
  #endif
  //#define SHAPING_MIN_FREQ  20        // By default the minimum of the shaping frequencies. Override to affect SRAM usage.
  //#define SHAPING_MAX_STEPRATE 10000  // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage.
  //#define SHAPING_MENU                // Add a menu to the LCD to set shaping parameters.
#endif

I don't have any idea which parameter values might be appropriate for our printers, so somebody has to figure them out...

With the fix #405 is merged into [master](https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/tree/master), the full 2.1.2 upstream sources are available. The (experimental) feature can be enabled adding something like this to the configuration: ```c /** * Input Shaping -- EXPERIMENTAL * * Zero Vibration (ZV) Input Shaping for X and/or Y movements. * * This option uses a lot of SRAM for the step buffer. The buffer size is * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT, * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE. * The higher the frequency and the lower the feedrate, the smaller the buffer. * If the buffer is too small at runtime, input shaping will have reduced * effectiveness during high speed movements. * * Tune with M593 D<factor> F<frequency>: * * D<factor> Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. * F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) * X<1> Set the given parameters only for the X axis. * Y<1> Set the given parameters only for the Y axis. */ //#define INPUT_SHAPING_X //#define INPUT_SHAPING_Y #if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) #if ENABLED(INPUT_SHAPING_X) #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). #endif #if ENABLED(INPUT_SHAPING_Y) #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). #endif //#define SHAPING_MIN_FREQ 20 // By default the minimum of the shaping frequencies. Override to affect SRAM usage. //#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage. //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. #endif ``` I don't have any idea which parameter values might be appropriate for our printers, so somebody has to figure them out...
St-Aris commented 2023-01-01 07:22:45 -06:00 (Migrated from github.com)

Can anyone confirm if this is enabled in the latest beta hext file?

Can anyone confirm if this is enabled in the latest beta hext file?
dtylerb commented 2023-01-27 22:23:48 -06:00 (Migrated from github.com)

With the fix #405 is merged into master, the full 2.1.2 upstream sources are available.

The (experimental) feature can be enabled adding something like this to the configuration:

/**
 * Input Shaping -- EXPERIMENTAL
 *
 * Zero Vibration (ZV) Input Shaping for X and/or Y movements.
 *
 * This option uses a lot of SRAM for the step buffer. The buffer size is
 * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT,
 * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can
 * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE.
 * The higher the frequency and the lower the feedrate, the smaller the buffer.
 * If the buffer is too small at runtime, input shaping will have reduced
 * effectiveness during high speed movements.
 *
 * Tune with M593 D<factor> F<frequency>:
 *
 *  D<factor>    Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes.
 *  F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes.
 *  T[map]       Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet)
 *  X<1>         Set the given parameters only for the X axis.
 *  Y<1>         Set the given parameters only for the Y axis.
 */
//#define INPUT_SHAPING_X
//#define INPUT_SHAPING_Y
#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y)
  #if ENABLED(INPUT_SHAPING_X)
    #define SHAPING_FREQ_X  40          // (Hz) The default dominant resonant frequency on the X axis.
    #define SHAPING_ZETA_X  0.15f       // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping).
  #endif
  #if ENABLED(INPUT_SHAPING_Y)
    #define SHAPING_FREQ_Y  40          // (Hz) The default dominant resonant frequency on the Y axis.
    #define SHAPING_ZETA_Y  0.15f       // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping).
  #endif
  //#define SHAPING_MIN_FREQ  20        // By default the minimum of the shaping frequencies. Override to affect SRAM usage.
  //#define SHAPING_MAX_STEPRATE 10000  // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage.
  //#define SHAPING_MENU                // Add a menu to the LCD to set shaping parameters.
#endif

I don't have any idea which parameter values might be appropriate for our printers, so somebody has to figure them out...

I downloaded the latest Knutwurst firmware (1.5.0 beta 3) thinking it would have input shaping because it is listed in the changelog on marlinfw.org as being part of version 2.1.2, and the changelog for the knutwurst firmware says that as of version 1.5.0 beta 3 the codebase has been updated to Marlin 2.1.2. Unfortunately I found that the section on input shaping was missing from configuration_adv.h. I then ran across this post and pasted the section above in to my configuration_adv.h, but was unable to compile due to some errors. I then downloaded the stock Marlin 2.1.2 so that I could see exactly where in the file it belongs (in case that makes a difference) and copied and pasted it from the stock Marlin configuration_adv.h in to exactly the same spot, but it made no difference. Oh, and of course in all cases I uncommented the lines for #define INPUT_SHAPING_X and Y. Obviously there's more to it than that. Here are the errors:

Compiling .pio\build\MEGA_S_TMC\src\src\feature\bedlevel\bedlevel.cpp.o
In file included from Marlin\src\MarlinCore.cpp:47:0:
Marlin\src\module/stepper.h:348:56: in constexpr expansion of 'max_isr_rate<>()'
Marlin\src\module/stepper.h:348:75: error: array subscript value '4' is outside the bounds of array type 'const feedRate_t [4] {aka const float [4]}'
constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate);
^
Marlin\src\module/stepper.h:370:55: error: size of array 'times' is not an integral constant-expression
static shaping_time_t times[shaping_echoes];
^
Marlin\src\module/stepper.h:371:59: error: size of array 'echo_axes' is not an integral constant-expression
static shaping_echo_axis_t echo_axes[shaping_echoes];
^
Compiling .pio\build\MEGA_S_TMC\src\src\feature\bedlevel\hilbert_curve.cpp.o
*** [.pio\build\MEGA_S_TMC\src\src\MarlinCore.cpp.o] Error 1
In file included from Marlin\src\feature\babystep.cpp:31:0:
Marlin\src\feature../module/stepper.h:348:56: in constexpr expansion of 'max_isr_rate<>()'
Marlin\src\feature../module/stepper.h:348:75: error: array subscript value '4' is outside the bounds of array type 'const feedRate_t [4] {aka const float [4]}'
constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate);
^
Marlin\src\feature../module/stepper.h:370:55: error: size of array 'times' is not an integral constant-expression
static shaping_time_t times[shaping_echoes];
^
Marlin\src\feature../module/stepper.h:371:59: error: size of array 'echo_axes' is not an integral constant-expression
static shaping_echo_axis_t echo_axes[shaping_echoes];
^
*** [.pio\build\MEGA_S_TMC\src\src\feature\babystep.cpp.o] Error 1
====================================================================================== [FAILED] Took 10.86 seconds ======================================================================================

> With the fix #405 is merged into [master](https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/tree/master), the full 2.1.2 upstream sources are available. > > The (experimental) feature can be enabled adding something like this to the configuration: > > ```c > /** > * Input Shaping -- EXPERIMENTAL > * > * Zero Vibration (ZV) Input Shaping for X and/or Y movements. > * > * This option uses a lot of SRAM for the step buffer. The buffer size is > * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT, > * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can > * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE. > * The higher the frequency and the lower the feedrate, the smaller the buffer. > * If the buffer is too small at runtime, input shaping will have reduced > * effectiveness during high speed movements. > * > * Tune with M593 D<factor> F<frequency>: > * > * D<factor> Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. > * F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. > * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) > * X<1> Set the given parameters only for the X axis. > * Y<1> Set the given parameters only for the Y axis. > */ > //#define INPUT_SHAPING_X > //#define INPUT_SHAPING_Y > #if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) > #if ENABLED(INPUT_SHAPING_X) > #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. > #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). > #endif > #if ENABLED(INPUT_SHAPING_Y) > #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. > #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). > #endif > //#define SHAPING_MIN_FREQ 20 // By default the minimum of the shaping frequencies. Override to affect SRAM usage. > //#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage. > //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. > #endif > ``` > > I don't have any idea which parameter values might be appropriate for our printers, so somebody has to figure them out... I downloaded the latest Knutwurst firmware (1.5.0 beta 3) thinking it would have input shaping because it is listed in the changelog on marlinfw.org as being part of version 2.1.2, and the changelog for the knutwurst firmware says that as of version 1.5.0 beta 3 the codebase has been updated to Marlin 2.1.2. Unfortunately I found that the section on input shaping was missing from configuration_adv.h. I then ran across this post and pasted the section above in to my configuration_adv.h, but was unable to compile due to some errors. I then downloaded the stock Marlin 2.1.2 so that I could see exactly where in the file it belongs (in case that makes a difference) and copied and pasted it from the stock Marlin configuration_adv.h in to exactly the same spot, but it made no difference. Oh, and of course in all cases I uncommented the lines for #define INPUT_SHAPING_X and Y. Obviously there's more to it than that. Here are the errors: Compiling .pio\build\MEGA_S_TMC\src\src\feature\bedlevel\bedlevel.cpp.o In file included from Marlin\src\MarlinCore.cpp:47:0: Marlin\src\module/stepper.h:348:56: in constexpr expansion of 'max_isr_rate<>()' Marlin\src\module/stepper.h:348:75: error: array subscript value '4' is outside the bounds of array type 'const feedRate_t [4] {aka const float [4]}' constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate); ^ Marlin\src\module/stepper.h:370:55: error: size of array 'times' is not an integral constant-expression static shaping_time_t times[shaping_echoes]; ^ Marlin\src\module/stepper.h:371:59: error: size of array 'echo_axes' is not an integral constant-expression static shaping_echo_axis_t echo_axes[shaping_echoes]; ^ Compiling .pio\build\MEGA_S_TMC\src\src\feature\bedlevel\hilbert_curve.cpp.o *** [.pio\build\MEGA_S_TMC\src\src\MarlinCore.cpp.o] Error 1 In file included from Marlin\src\feature\babystep.cpp:31:0: Marlin\src\feature\../module/stepper.h:348:56: in constexpr expansion of 'max_isr_rate<>()' Marlin\src\feature\../module/stepper.h:348:75: error: array subscript value '4' is outside the bounds of array type 'const feedRate_t [4] {aka const float [4]}' constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate); ^ Marlin\src\feature\../module/stepper.h:370:55: error: size of array 'times' is not an integral constant-expression static shaping_time_t times[shaping_echoes]; ^ Marlin\src\feature\../module/stepper.h:371:59: error: size of array 'echo_axes' is not an integral constant-expression static shaping_echo_axis_t echo_axes[shaping_echoes]; ^ *** [.pio\build\MEGA_S_TMC\src\src\feature\babystep.cpp.o] Error 1 ====================================================================================== [FAILED] Took 10.86 seconds ======================================================================================
stklcode commented 2023-01-28 02:04:03 -06:00 (Migrated from github.com)

Obviously there's more to it than that.

At the very least you have to comment out the source exclusion from the platformio.ini:

fb281baa27/platformio.ini (L249)

I.e. make this line
# -<src/gcode/feature/input_shaping>

> Obviously there's more to it than that. At the very least you have to comment out the source exclusion from the _platformio.ini_: https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/blob/fb281baa27bfba2a668a9bb63a1c7a1b2643f8a6/platformio.ini#L249 I.e. make this line `# -<src/gcode/feature/input_shaping>`
St-Aris commented 2023-01-28 03:30:45 -06:00 (Migrated from github.com)

Could we get a beta image with this enabled? Do the original early trigorilla boards have enough ram to handle it?

Could we get a beta image with this enabled? Do the original early trigorilla boards have enough ram to handle it?
dtylerb commented 2023-01-28 10:32:04 -06:00 (Migrated from github.com)

Obviously there's more to it than that.

At the very least you have to comment out the source exclusion from the platformio.ini:

fb281baa27/platformio.ini (L249)

I.e. make this line # -<src/gcode/feature/input_shaping>

Well, that didn't fix it. I haven't done any serious coding in many years and when I did it wasn't using Visual Studio/platform.io, so it may be a simple issue but I have limited ability to troubleshoot. Anyhow, if it's not a simple thing to tell me how to get it enabled, I just wanted those who do have the ability to know that it's either not working or there aren't clear instructions that work (or at least not that I've been able to find). I'm still getting the same errors.

I appreciate the help so far.

> > Obviously there's more to it than that. > > At the very least you have to comment out the source exclusion from the _platformio.ini_: > > https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/blob/fb281baa27bfba2a668a9bb63a1c7a1b2643f8a6/platformio.ini#L249 > > I.e. make this line `# -<src/gcode/feature/input_shaping>` Well, that didn't fix it. I haven't done any serious coding in many years and when I did it wasn't using Visual Studio/platform.io, so it may be a simple issue but I have limited ability to troubleshoot. Anyhow, if it's not a simple thing to tell me how to get it enabled, I just wanted those who do have the ability to know that it's either not working or there aren't clear instructions that work (or at least not that I've been able to find). I'm still getting the same errors. I appreciate the help so far.
github-actions[bot] commented 2023-02-27 19:57:40 -06:00 (Migrated from github.com)

This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.

This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.
github-actions[bot] commented 2023-12-30 08:03:24 -06:00 (Migrated from github.com)

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wp/Marlin-2-0-x-Anycubic-i3-MEGA-S#402
No description provided.