-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input shaping #24797
Merged
thinkyhead
merged 11 commits into
MarlinFirmware:bugfix-2.1.x
from
tombrazier:input_shaping
Oct 21, 2022
Merged
Input shaping #24797
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3553b72
Input Shaping
tombrazier fb5ba8e
Only use one input shaping buffer and one dividend buffer for signifi…
tombrazier 56bb9b3
Added config menu for input shaping
tombrazier 354af11
Fix some things
thinkyhead 28754b4
Style adjustment, tweak xy pulse for closer sync
thinkyhead e22f9cf
renaming that got missed at some point
tombrazier c784a23
Reduce speed to prevent buffer overflows
tombrazier daf3dcf
COmpile error
tombrazier 1412493
tweak speed factor limit
thinkyhead 0a6ab15
Merge remote-tracking branch 'upstream/bugfix-2.1.x' into pr/24797
thinkyhead 9d1268e
followup
thinkyhead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] | ||
* | ||
* Based on Sprinter and grbl. | ||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "../../../inc/MarlinConfig.h" | ||
|
||
#if ENABLED(INPUT_SHAPING) | ||
|
||
#include "../../gcode.h" | ||
#include "../../../module/stepper.h" | ||
|
||
void GcodeSuite::M593_report(const bool forReplay/*=true*/) { | ||
report_heading_etc(forReplay, F("Input Shaping")); | ||
#if HAS_SHAPING_X | ||
SERIAL_ECHO_MSG("M593 X" | ||
" F", stepper.get_shaping_frequency(X_AXIS), | ||
" D", stepper.get_shaping_damping_ratio(X_AXIS) | ||
); | ||
#endif | ||
#if HAS_SHAPING_Y | ||
SERIAL_ECHO_MSG("M593 Y" | ||
" F", stepper.get_shaping_frequency(Y_AXIS), | ||
" D", stepper.get_shaping_damping_ratio(Y_AXIS) | ||
); | ||
#endif | ||
} | ||
|
||
/** | ||
* M593: Get or Set Input Shaping Parameters | ||
* 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. | ||
*/ | ||
void GcodeSuite::M593() { | ||
if (!parser.seen_any()) return M593_report(); | ||
|
||
const bool seen_X = TERN0(HAS_SHAPING_X, parser.seen_test('X')), | ||
seen_Y = TERN0(HAS_SHAPING_Y, parser.seen_test('Y')), | ||
for_X = seen_X || TERN0(HAS_SHAPING_X, (!seen_X && !seen_Y)), | ||
for_Y = seen_Y || TERN0(HAS_SHAPING_Y, (!seen_X && !seen_Y)); | ||
|
||
if (parser.seen('D')) { | ||
const float zeta = parser.value_float(); | ||
if (WITHIN(zeta, 0, 1)) { | ||
if (for_X) stepper.set_shaping_damping_ratio(X_AXIS, zeta); | ||
if (for_Y) stepper.set_shaping_damping_ratio(Y_AXIS, zeta); | ||
} | ||
else | ||
SERIAL_ECHO_MSG("?Zeta (D) value out of range (0-1)"); | ||
} | ||
|
||
if (parser.seen('F')) { | ||
const float freq = parser.value_float(); | ||
if (freq > 0) { | ||
if (for_X) stepper.set_shaping_frequency(X_AXIS, freq); | ||
if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq); | ||
} | ||
else | ||
SERIAL_ECHO_MSG("?Frequency (F) must be greater than 0"); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically these should be able to coexist, with either the direct stepping blocks being shaped or by having the direct stepping blocks skip the shaper altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. They may even work okay as is. I think direct stepping would probably just not be affected by input shaping. But I don't have the capacity to check that out right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that Klipper's direct stepping protocol sends basic segments but the shaping happens on the printer's mainboard, so it makes sense to also do that for Direct Stepping. But maybe Klipper does some pre-calculation for the benefit of shaping before it sends those segments over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use the same block protocol as Klipper? Or is there a front end out there somewhere for feeding Marlin specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct Stepping G6 specifically requires https://github.com/colinrgodsey/step-daemon