Skip to content

Commit 67fb786

Browse files
committed
🔧 Refine Input Shaping check
1 parent 7a49fab commit 67fb786

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

Marlin/src/inc/SanityCheck.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -4379,10 +4379,17 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
43794379
#error "Input Shaping is not compatible with POLARGRAPH kinematics."
43804380
#elif ENABLED(DIRECT_STEPPING)
43814381
#error "Input Shaping is not compatible with DIRECT_STEPPING."
4382-
#elif ENABLED(INPUT_SHAPING_X) && ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX)
4383-
#error "INPUT_SHAPING_X is not supported with COREXY, COREYX, COREXZ, COREZX, or MARKFORGED_*."
4384-
#elif ENABLED(INPUT_SHAPING_Y) && ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, MARKFORGED_YX)
4385-
#error "INPUT_SHAPING_Y is not supported with COREXY, COREYX, COREYZ, COREZY, or MARKFORGED_*."
4382+
#elif BOTH(INPUT_SHAPING_X, CORE_IS_XZ)
4383+
#error "INPUT_SHAPING_X is not supported with COREXZ."
4384+
#elif BOTH(INPUT_SHAPING_Y, CORE_IS_YZ)
4385+
#error "INPUT_SHAPING_Y is not supported with COREYZ."
4386+
#elif ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
4387+
#if !BOTH(INPUT_SHAPING_X, INPUT_SHAPING_Y)
4388+
#error "INPUT_SHAPING_X and INPUT_SHAPING_Y must both be enabled for COREXY, COREYX, or MARKFORGED_*."
4389+
#else
4390+
static_assert(SHAPING_FREQ_X == SHAPING_FREQ_Y, "SHAPING_FREQ_X and SHAPING_FREQ_Y must be the same for COREXY / COREYX / MARKFORGED_*.");
4391+
static_assert(SHAPING_ZETA_X == SHAPING_ZETA_Y, "SHAPING_ZETA_X and SHAPING_ZETA_Y must be the same for COREXY / COREYX / MARKFORGED_*.");
4392+
#endif
43864393
#endif
43874394

43884395
#ifdef __AVR__

Marlin/src/inc/Warnings.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -790,3 +790,10 @@
790790
#if BOTH(POLAR, S_CURVE_ACCELERATION)
791791
#warning "POLAR kinematics may not work well with S_CURVE_ACCELERATION."
792792
#endif
793+
794+
/**
795+
* Input Shaping
796+
*/
797+
#if HAS_SHAPING && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX)
798+
#warning "Input Shaping for CORE / MARKFORGED kinematic axes is still experimental."
799+
#endif

Marlin/src/module/stepper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ void Stepper::init() {
30203020
* Calculate a fixed point factor to apply to the signal and its echo
30213021
* when shaping an axis.
30223022
*/
3023-
void Stepper::set_shaping_damping_ratio(const AxisEnum axis, const float zeta) {
3023+
void Stepper::set_shaping_damping_ratio(const AxisEnum axis, const_float_t zeta) {
30243024
// from the damping ratio, get a factor that can be applied to advance_dividend for fixed point maths
30253025
// for ZV, we use amplitudes 1/(1+K) and K/(1+K) where K = exp(-zeta * M_PI / sqrt(1.0f - zeta * zeta))
30263026
// which can be converted to 1:7 fixed point with an excellent fit with a 3rd order polynomial
@@ -3029,9 +3029,9 @@ void Stepper::init() {
30293029
else if (zeta >= 1.0f) factor2 = 0.0f;
30303030
else {
30313031
factor2 = 64.44056192 + -99.02008832 * zeta;
3032-
const float zeta2 = zeta * zeta;
3032+
const_float_t zeta2 = zeta * zeta;
30333033
factor2 += -7.58095488 * zeta2;
3034-
const float zeta3 = zeta2 * zeta;
3034+
const_float_t zeta3 = zeta2 * zeta;
30353035
factor2 += 43.073216 * zeta3;
30363036
factor2 = floor(factor2);
30373037
}
@@ -3049,7 +3049,7 @@ void Stepper::init() {
30493049
return -1;
30503050
}
30513051

3052-
void Stepper::set_shaping_frequency(const AxisEnum axis, const float freq) {
3052+
void Stepper::set_shaping_frequency(const AxisEnum axis, const_float_t freq) {
30533053
// enabling or disabling shaping whilst moving can result in lost steps
30543054
planner.synchronize();
30553055

Marlin/src/module/stepper.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -154,38 +154,39 @@
154154

155155
// Add time for each stepper
156156
#if HAS_X_STEP
157-
#define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES
157+
#define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES
158158
#endif
159159
#if HAS_Y_STEP
160-
#define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES
160+
#define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES
161161
#endif
162162
#if HAS_Z_STEP
163-
#define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES
163+
#define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES
164164
#endif
165165
#if HAS_I_STEP
166-
#define ISR_I_STEPPER_CYCLES ISR_STEPPER_CYCLES
166+
#define ISR_I_STEPPER_CYCLES ISR_STEPPER_CYCLES
167167
#endif
168168
#if HAS_J_STEP
169-
#define ISR_J_STEPPER_CYCLES ISR_STEPPER_CYCLES
169+
#define ISR_J_STEPPER_CYCLES ISR_STEPPER_CYCLES
170170
#endif
171171
#if HAS_K_STEP
172-
#define ISR_K_STEPPER_CYCLES ISR_STEPPER_CYCLES
172+
#define ISR_K_STEPPER_CYCLES ISR_STEPPER_CYCLES
173173
#endif
174174
#if HAS_U_STEP
175-
#define ISR_U_STEPPER_CYCLES ISR_STEPPER_CYCLES
175+
#define ISR_U_STEPPER_CYCLES ISR_STEPPER_CYCLES
176176
#endif
177177
#if HAS_V_STEP
178-
#define ISR_V_STEPPER_CYCLES ISR_STEPPER_CYCLES
178+
#define ISR_V_STEPPER_CYCLES ISR_STEPPER_CYCLES
179179
#endif
180180
#if HAS_W_STEP
181-
#define ISR_W_STEPPER_CYCLES ISR_STEPPER_CYCLES
181+
#define ISR_W_STEPPER_CYCLES ISR_STEPPER_CYCLES
182182
#endif
183183
#if HAS_EXTRUDERS
184-
#define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES // E is always interpolated, even for mixing extruders
184+
#define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES // E is always interpolated, even for mixing extruders
185185
#endif
186186

187187
// And the total minimum loop time, not including the base
188-
#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_GANG(+ ISR_E_STEPPER_CYCLES, + ISR_X_STEPPER_CYCLES, + ISR_Y_STEPPER_CYCLES, + ISR_Z_STEPPER_CYCLES, + ISR_I_STEPPER_CYCLES, + ISR_J_STEPPER_CYCLES, + ISR_K_STEPPER_CYCLES, + ISR_U_STEPPER_CYCLES, + ISR_V_STEPPER_CYCLES, + ISR_W_STEPPER_CYCLES))
188+
#define _PLUS_AXIS_CYCLES(A) + (ISR_##A##_STEPPER_CYCLES)
189+
#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_MAP(_PLUS_AXIS_CYCLES))
189190

190191
// Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate
191192
#define _MIN_STEPPER_PULSE_CYCLES(N) _MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N))
@@ -802,9 +803,9 @@ class Stepper {
802803
}
803804

804805
#if HAS_SHAPING
805-
static void set_shaping_damping_ratio(const AxisEnum axis, const float zeta);
806+
static void set_shaping_damping_ratio(const AxisEnum axis, const_float_t zeta);
806807
static float get_shaping_damping_ratio(const AxisEnum axis);
807-
static void set_shaping_frequency(const AxisEnum axis, const float freq);
808+
static void set_shaping_frequency(const AxisEnum axis, const_float_t freq);
808809
static float get_shaping_frequency(const AxisEnum axis);
809810
#endif
810811

0 commit comments

Comments
 (0)