Skip to content
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

Fix FT Motion layer shifting #26014

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e27fdd1
FT_MOTION : it's impossible to enble EI shaping mode with M493 S12, t…
narno2202 Jun 22, 2023
18cbb41
FT_MOTION : Disable M493 S0 during an ongoig print as it causes layer…
narno2202 Jun 22, 2023
06b2275
forbid 'M493 S' during print job
thinkyhead Jun 23, 2023
83ebb75
Allow M493 S in G-code files
thinkyhead Jun 23, 2023
f4573f0
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jun 23, 2023
b9cfea3
flag.reset_ft causes layer shift when changing the frequencies of the…
narno2202 Jun 23, 2023
f23f672
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jun 24, 2023
191e499
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jun 26, 2023
85898c4
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jun 27, 2023
8de1a25
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jun 29, 2023
ee1e85a
Merge 'bugfix-2.1.x' into pr/26014
thinkyhead Jun 29, 2023
03c0d83
Further runout updates: resolves layer shift on mode or frequency cha…
ulendoalex Jun 29, 2023
47fc161
Already synchronized
thinkyhead Jun 29, 2023
3f1fb8e
more predef
thinkyhead Jun 29, 2023
6884c2b
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jul 1, 2023
bedccd0
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jul 2, 2023
aaa22ef
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jul 5, 2023
85e7980
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
narno2202 Jul 8, 2023
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
4 changes: 2 additions & 2 deletions Marlin/src/gcode/feature/ft_motion/M493.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void GcodeSuite::M493() {
// TODO: Frequency minimum is dependent on the shaper used; the above check isn't always correct.
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
fxdTiCtrl.cfg.baseFreq[X_AXIS] = val;
flag.update_n = flag.reset_ft = flag.report_h = true;
flag.update_n = flag.report_h = true;
}
else // Frequency out of range.
SERIAL_ECHOLNPGM("Invalid [", AS_CHAR('A'), "] frequency value.");
Expand Down Expand Up @@ -289,7 +289,7 @@ void GcodeSuite::M493() {
const float val = parser.value_float();
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
fxdTiCtrl.cfg.baseFreq[Y_AXIS] = val;
flag.update_n = flag.reset_ft = flag.report_h = true;
flag.update_n = flag.report_h = true;
}
else // Frequency out of range.
SERIAL_ECHOLNPGM("Invalid frequency [", AS_CHAR('B'), "] value.");
Expand Down
75 changes: 23 additions & 52 deletions Marlin/src/module/ft_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "ft_motion.h"
#include "stepper.h" // Access stepper block queue function and abort status.
// Access planner singleton for settings, busy flag, etc..

FxdTiCtrl fxdTiCtrl;

Expand Down Expand Up @@ -75,7 +76,7 @@ bool FxdTiCtrl::batchRdy = false; // Indicates a batch of the fi
bool FxdTiCtrl::batchRdyForInterp = false; // Indicates the batch is done being post processed,
// if applicable, and is ready to be converted to step commands.
bool FxdTiCtrl::runoutEna = false; // True if runout of the block hasn't been done and is allowed.
bool FxdTiCtrl::runout = false; // Indicates if runout is in progress.
bool FxdTiCtrl::blockDataIsRunout = false; // Indicates the last loaded block variables are for a runout.

// Trapezoid data variables.
xyze_pos_t FxdTiCtrl::startPosn, // (mm) Start position of block
Expand Down Expand Up @@ -142,31 +143,22 @@ void FxdTiCtrl::startBlockProc(block_t * const current_block) {

// Moves any free data points to the stepper buffer even if a full batch isn't ready.
void FxdTiCtrl::runoutBlock() {
if (!runoutEna) return;

if (runoutEna && !batchRdy) { // If the window is full already (block intervals was a multiple of
// the batch size), or runout is not enabled, no runout is needed.
// Fill out the trajectory window with the last position calculated.
if (makeVector_batchIdx > last_batchIdx)
for (uint32_t i = makeVector_batchIdx; i < (FTM_WINDOW_SIZE); i++) {
LOGICAL_AXIS_CODE(
traj.e[i] = traj.e[makeVector_batchIdx - 1],
traj.x[i] = traj.x[makeVector_batchIdx - 1],
traj.y[i] = traj.y[makeVector_batchIdx - 1],
traj.z[i] = traj.z[makeVector_batchIdx - 1],
traj.i[i] = traj.i[makeVector_batchIdx - 1],
traj.j[i] = traj.j[makeVector_batchIdx - 1],
traj.k[i] = traj.k[makeVector_batchIdx - 1],
traj.u[i] = traj.u[makeVector_batchIdx - 1],
traj.v[i] = traj.v[makeVector_batchIdx - 1],
traj.w[i] = traj.w[makeVector_batchIdx - 1]
);
}
startPosn = endPosn_prevBlock;
ratio.reset();

makeVector_batchIdx = last_batchIdx;
batchRdy = true;
runout = true;
}
runoutEna = false;
accel_P = decel_P = 0.0f;

static constexpr uint32_t shaper_intervals = (FTM_BATCH_SIZE) * ceil((FTM_ZMAX) / (FTM_BATCH_SIZE)),
min_max_intervals = (FTM_BATCH_SIZE) * ceil((FTM_WINDOW_SIZE) / (FTM_BATCH_SIZE));

max_intervals = cfg.modeHasShaper() ? shaper_intervals : 0;
if (max_intervals <= min_max_intervals - (FTM_BATCH_SIZE)) max_intervals = min_max_intervals;
max_intervals += (FTM_WINDOW_SIZE) - makeVector_batchIdx;

blockProcRdy = blockDataIsRunout = true;
runoutEna = blockProcDn = false;
}

// Controller main, to be invoked from non-isr task.
Expand All @@ -188,35 +180,17 @@ void FxdTiCtrl::loop() {
}

// Planner processing and block conversion.
if (!blockProcRdy && !runout) stepper.fxdTiCtrl_BlockQueueUpdate();
if (!blockProcRdy) stepper.fxdTiCtrl_BlockQueueUpdate();

if (blockProcRdy) {
if (!blockProcRdy_z1) loadBlockData(current_block_cpy); // One-shot.
if (!blockProcRdy_z1) { // One-shot.
if (!blockDataIsRunout) loadBlockData(current_block_cpy);
else blockDataIsRunout = false;
}
while (!blockProcDn && !batchRdy && (makeVector_idx - makeVector_idx_z1 < (FTM_POINTS_PER_LOOP)))
makeVector();
}

if (runout && !batchRdy) { // The lower half of the window has been runout.
// Runout the upper half of the window: the upper half has been shifted into the lower
// half. Fill out the upper half so another batch can be processed.
for (uint32_t i = last_batchIdx; i < (FTM_WINDOW_SIZE) - 1; i++) {
LOGICAL_AXIS_CODE(
traj.e[i] = traj.e[(FTM_WINDOW_SIZE) - 1],
traj.x[i] = traj.x[(FTM_WINDOW_SIZE) - 1],
traj.y[i] = traj.y[(FTM_WINDOW_SIZE) - 1],
traj.z[i] = traj.z[(FTM_WINDOW_SIZE) - 1],
traj.i[i] = traj.i[(FTM_WINDOW_SIZE) - 1],
traj.j[i] = traj.j[(FTM_WINDOW_SIZE) - 1],
traj.k[i] = traj.k[(FTM_WINDOW_SIZE) - 1],
traj.u[i] = traj.u[(FTM_WINDOW_SIZE) - 1],
traj.v[i] = traj.v[(FTM_WINDOW_SIZE) - 1],
traj.w[i] = traj.w[(FTM_WINDOW_SIZE) - 1]
);
}
batchRdy = true;
runout = false;
}

// FBS / post processing.
if (batchRdy && !batchRdyForInterp) {

Expand Down Expand Up @@ -401,7 +375,6 @@ void FxdTiCtrl::reset() {
blockProcRdy = blockProcRdy_z1 = blockProcDn = false;
batchRdy = batchRdyForInterp = false;
runoutEna = false;
runout = false;

endPosn_prevBlock.reset();

Expand Down Expand Up @@ -530,7 +503,7 @@ void FxdTiCtrl::loadBlockData(block_t * const current_block) {
s_2e = s_1e + F_P * T2_P;

// One less than (Accel + Coasting + Decel) datapoints
max_intervals = N1 + N2 + N3 - 1U;
max_intervals = N1 + N2 + N3;

endPosn_prevBlock += moveDist;
}
Expand Down Expand Up @@ -643,13 +616,11 @@ void FxdTiCtrl::makeVector() {
batchRdy = true;
}

if (makeVector_idx == max_intervals) {
if (++makeVector_idx == max_intervals) {
blockProcDn = true;
blockProcRdy = false;
makeVector_idx = 0;
}
else
makeVector_idx++;
}

// Interpolates single data point to stepper commands.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/ft_motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class FxdTiCtrl {
static bool blockProcRdy, blockProcRdy_z1, blockProcDn;
static bool batchRdy, batchRdyForInterp;
static bool runoutEna;
static bool runout;
static bool blockDataIsRunout;

// Trapezoid data variables.
static xyze_pos_t startPosn, // (mm) Start position of block
Expand Down
Loading