@@ -75,6 +75,7 @@ bool FxdTiCtrl::batchRdy = false; // Indicates a batch of the fi
75
75
bool FxdTiCtrl::batchRdyForInterp = false ; // Indicates the batch is done being post processed,
76
76
// if applicable, and is ready to be converted to step commands.
77
77
bool FxdTiCtrl::runoutEna = false ; // True if runout of the block hasn't been done and is allowed.
78
+ bool FxdTiCtrl::runout = false ; // Indicates if runout is in progress.
78
79
79
80
// Trapezoid data variables.
80
81
xyze_pos_t FxdTiCtrl::startPosn, // (mm) Start position of block
@@ -123,6 +124,8 @@ hal_timer_t FxdTiCtrl::nextStepTicks = FTM_MIN_TICKS; // Accumulator for the nex
123
124
float FxdTiCtrl::e_advanced_z1 = 0 .0f ; // (ms) Unit delay of advanced extruder position.
124
125
#endif
125
126
127
+ constexpr uint32_t last_batchIdx = (FTM_WINDOW_SIZE) - (FTM_BATCH_SIZE);
128
+
126
129
// -----------------------------------------------------------------//
127
130
// Function definitions.
128
131
// -----------------------------------------------------------------//
@@ -143,8 +146,8 @@ void FxdTiCtrl::runoutBlock() {
143
146
if (runoutEna && !batchRdy) { // If the window is full already (block intervals was a multiple of
144
147
// the batch size), or runout is not enabled, no runout is needed.
145
148
// Fill out the trajectory window with the last position calculated.
146
- if (makeVector_batchIdx > FTM_BATCH_SIZE )
147
- for (uint32_t i = makeVector_batchIdx; i < 2 * (FTM_BATCH_SIZE ); i++) {
149
+ if (makeVector_batchIdx > last_batchIdx )
150
+ for (uint32_t i = makeVector_batchIdx; i < (FTM_WINDOW_SIZE ); i++) {
148
151
LOGICAL_AXIS_CODE (
149
152
traj.e [i] = traj.e [makeVector_batchIdx - 1 ],
150
153
traj.x [i] = traj.x [makeVector_batchIdx - 1 ],
@@ -159,8 +162,9 @@ void FxdTiCtrl::runoutBlock() {
159
162
);
160
163
}
161
164
162
- makeVector_batchIdx = FTM_BATCH_SIZE ;
165
+ makeVector_batchIdx = last_batchIdx ;
163
166
batchRdy = true ;
167
+ runout = true ;
164
168
}
165
169
runoutEna = false ;
166
170
}
@@ -184,14 +188,35 @@ void FxdTiCtrl::loop() {
184
188
}
185
189
186
190
// Planner processing and block conversion.
187
- if (!blockProcRdy) stepper.fxdTiCtrl_BlockQueueUpdate ();
191
+ if (!blockProcRdy && !runout ) stepper.fxdTiCtrl_BlockQueueUpdate ();
188
192
189
193
if (blockProcRdy) {
190
194
if (!blockProcRdy_z1) loadBlockData (current_block_cpy); // One-shot.
191
195
while (!blockProcDn && !batchRdy && (makeVector_idx - makeVector_idx_z1 < (FTM_POINTS_PER_LOOP)))
192
196
makeVector ();
193
197
}
194
198
199
+ if (runout && !batchRdy) { // The lower half of the window has been runout.
200
+ // Runout the upper half of the window: the upper half has been shifted into the lower
201
+ // half. Fill out the upper half so another batch can be processed.
202
+ for (uint32_t i = last_batchIdx; i < (FTM_WINDOW_SIZE) - 1 ; i++) {
203
+ LOGICAL_AXIS_CODE (
204
+ traj.e [i] = traj.e [(FTM_WINDOW_SIZE) - 1 ],
205
+ traj.x [i] = traj.x [(FTM_WINDOW_SIZE) - 1 ],
206
+ traj.y [i] = traj.y [(FTM_WINDOW_SIZE) - 1 ],
207
+ traj.z [i] = traj.z [(FTM_WINDOW_SIZE) - 1 ],
208
+ traj.i [i] = traj.i [(FTM_WINDOW_SIZE) - 1 ],
209
+ traj.j [i] = traj.j [(FTM_WINDOW_SIZE) - 1 ],
210
+ traj.k [i] = traj.k [(FTM_WINDOW_SIZE) - 1 ],
211
+ traj.u [i] = traj.u [(FTM_WINDOW_SIZE) - 1 ],
212
+ traj.v [i] = traj.v [(FTM_WINDOW_SIZE) - 1 ],
213
+ traj.w [i] = traj.w [(FTM_WINDOW_SIZE) - 1 ]
214
+ );
215
+ }
216
+ batchRdy = true ;
217
+ runout = false ;
218
+ }
219
+
195
220
// FBS / post processing.
196
221
if (batchRdy && !batchRdyForInterp) {
197
222
@@ -371,10 +396,12 @@ void FxdTiCtrl::reset() {
371
396
stepperCmdBuff_produceIdx = stepperCmdBuff_consumeIdx = 0 ;
372
397
373
398
traj.reset (); // Reset trajectory history
399
+ trajMod.reset (); // Reset modified trajectory history
374
400
375
401
blockProcRdy = blockProcRdy_z1 = blockProcDn = false ;
376
402
batchRdy = batchRdyForInterp = false ;
377
403
runoutEna = false ;
404
+ runout = false ;
378
405
379
406
endPosn_prevBlock.reset ();
380
407
@@ -611,8 +638,8 @@ void FxdTiCtrl::makeVector() {
611
638
#endif
612
639
613
640
// Filled up the queue with regular and shaped steps
614
- if (++makeVector_batchIdx == 2 * (FTM_BATCH_SIZE )) {
615
- makeVector_batchIdx = FTM_BATCH_SIZE ;
641
+ if (++makeVector_batchIdx == (FTM_WINDOW_SIZE )) {
642
+ makeVector_batchIdx = last_batchIdx ;
616
643
batchRdy = true ;
617
644
}
618
645
0 commit comments