Commit Graph

51 Commits

Author SHA1 Message Date
Alex Voinea
05bd1ba57f Multi-segment pause resume initial 2022-08-24 20:19:26 +03:00
Yuri D'Elia
7907e14cbf Resync planner position upon exiting xyzcal
Split the planner sync code out of planner_abort_hard() so that we can
independently resync the planner position from the counters.

This is needed in xyzcal as we directly modify the stepper counters
(bypassing both planner and stepper).

Call this new function instead of planner_abort_hard() when leaving, so
that motion can resume in the middle of the gcode_M45 instruction.
2022-08-23 17:25:24 +02:00
Yuri D'Elia
5965572e88 Enforce full-loop handling of aborted commands
After calling planner_abort_hard() no motion command can be
scheduled until we return to the main loop since the call can
potentially be scheduled inside a nested process_command call.

Despite previous fixes, bugs keep creeping in due to nested calls not
being obvious to detect at all.

Stop allowing motion _completely_ for the entire processing loop by
default. That is, instead of aborting the current plan_buffer_line call,
abort the entire command until we can actually schedule motion safely
again.

This benefits handling of pretty much all g/m-codes, since this flag
(now "planner_aborted" for clarity) becomes a general "command aborted"
call.

This also now ensures that the flag prevents _any_ new block (including
blocks partially planned while servicing an interrupt) are scheduled
after planner_abort_hard is called.

There are only two exceptions where it's safe to resume in this context:

- Within uvlo_, where we never return to the main processing loop
- When we're intentionally scheduling a new process_command loop for a
  MK3 filament recheck (which is *bad*)

Handle those two cases as exceptions.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
ea46402e4d Replace EXTRUDE_MINTEMP with the configurable extrude_min_temp
Everywhere MINTEMP is checked, use the configurable value set by M302,
not an hardcoded value.

EXTRUDE_MINTEMP is now used only as the initial default value.

Reduce the precision of extrude_min_temp to an integer to reduce the
generated code size (constant folding did in fact do the same previously
anyway). Having tenths of degrees is not necessary for this feature.
2022-05-11 20:07:38 +02:00
Voinea Dragos
9abae2fd97 Remove maxlimit_status 2022-01-30 11:22:43 +00:00
Yuri D'Elia
79287ffb3d Use uint8_t consistently for the block buffer's index
Instead of using a mixture of int8_t, unsigned char and (incorrectly)
int, use uint8_t consistently for indexing the current block.

This improves the performance of the wait loop in plan_buffer_line,
which currently expands all comparisons to a word for no reason.

This also extends the theoretical limit to 128 entries.
Add some static assertions to ensure BLOCK_BUFFER_SIZE is correct.
2021-06-22 06:59:57 +02:00
Yuri D'Elia
30a806608f Also convert acceleration_rate to uint32_t
acceleration_rate is also unsigned
2020-08-03 19:01:38 +02:00
Yuri D'Elia
4654283f54 Restore indentation 2020-08-03 18:16:20 +02:00
Alex Voinea
12be141188 Fix high speed deceleration 2020-08-03 18:16:13 +02:00
DRracer
eb44ee0f57
Code size optimization: 2KB down (#2687)
* Combine repeated calls into functions with much less parameters -> 2KB
down.

* Save some bytes by removing unnecessary 1-character strings: "x" -> 'x'
used in SERIAL_xxx printing macros.
This is also saves some CPU cycles

* Fix compilation for MK25S and MK3

* Copy surrounding indentation

* Fix compilation for a rare HW setup

* rename mesh_planXX_buffer_line back to mesh_plan_buffer_line

* Remove active_extruder from remaining plan_buffer_line_destinationXYZE
calls and one more fix of indentation
2020-06-01 17:51:28 +02:00
Alex Voinea
2e50954710
Merge branch 'MK3' into MK3_fix_selftest_Z_crash2 2020-01-22 14:56:54 +02:00
Yuri D'Elia
bab756699f Fix incorrect usage of plan_set_e_position() in G92 E*
To maintain an accurate step count (which is required for correct
position recovery), any call to plan_set_position&co needs to be done
synchronously and from a halted state.

However, G92 E* is currently special-cased to skip the sync (likely to
avoid the associated performance cost), causing an incorrect E step
count and position to be set. This breaks absolute position recovery,
miscalculation of the LA factor and possibly other weird issues.

We rewrite the handling of G92 to always sync but still special-case the
frequent "G92 E0" for performance by using a free bit in the block flags.

To avoid a sync, we relay the request for reset first to the planner
which clears its internal state and then relays the request to the final
stepper isr.
2020-01-14 20:24:14 +01:00
Yuri D'Elia
5122f79a39 Merge remote-tracking branch 'upstream/MK3' into MK3_LA15 2019-12-04 17:27:23 +01:00
Yuri D'Elia
18eaf21baf Halve memory usage of saved feedrate
Truncate the saved feedrate to an uint16_t.
This is more than sufficient for recovery.
2019-11-28 17:16:37 +01:00
Yuri D'Elia
17176c1df2 Save/restore the default feedrate correctly
Since the global feedrate can be similarly modified for moves ahead of
time, save the original feedrate in the planner as we do for
gcode_target.

This avoids having to undo feedmultiply (and machine limits!) from
"nominal_speed" as previously done.

Thanks @leptun
2019-11-28 17:16:37 +01:00
Yuri D'Elia
4268c2fdae Fix recovery from relative/chunked moves
When starting to replay existing USB/SD commands from a recovery state,
an immediate relative move needs to compensate for a previously
interrupted move. This is almost the norm for the E axis.

Instead of saving the relative status of the move (which needs to
account for the world2machine conversion and is not always available on
a chunked move split by MBL) save directly the calculated target
position for the move in the original plan, which is easy to replay.
2019-11-28 16:42:35 +01:00
Yuri D'Elia
0f6b9b4051 Unroll the stack in restore_print_from_ram_and_continue
While handling moves in a recursive plan, such a filament check,
ensure restore_print_from_ram_and_continue unwinds the stack by
aborting early from any call that waits on the planner.

This currently only handles G1 moves, but hard-coded behavior that can
trigger recursive behavior (such as filament change) will probably have
to be checked too.
2019-11-28 15:57:20 +01:00
leptun
350e27810a fix selftest Z crash. Use stallGuard when testing Z 2019-10-11 21:00:51 +03:00
DRracer
a7c2aec04c Code size reduced by almost 5KB 2019-08-21 09:59:51 +02:00
Yuri D'Elia
0239f4bce1 Update/compute advance steps inside calculate_trapezoid_for_block
Do not store the block e_D ratio, store directly the computed
compression factor so that we can recompute the advance steps
quickly and update them in sync with the acceleration rates.
2019-06-05 20:25:26 +02:00
Yuri D'Elia
942c38c18b Minor reformatting 2019-05-24 17:08:32 +02:00
Yuri D'Elia
a2fa8e5313 Rewrite the advance_isr scheduler 2019-05-24 17:08:32 +02:00
Yuri D'Elia
cbf1a85ec3 Switch original LA implementation with LA1.5
This discards several Prusa optimizations for LA1.0.
We'll re-implement those later if needed.

Debugging is turned on.
2019-05-24 17:08:32 +02:00
Yuri D'Elia
eeea2725cb Partial LA15 support 2019-05-24 17:08:32 +02:00
Marek Bel
c38fef281d Use cs.max_feedrate_silent, cs.max_acceleration_units_per_sq_second_silent from ConfigurationStore. 2018-09-24 17:33:58 +02:00
Marek Bel
ac7c062161 Use cs.max_jerk from ConfigurationStore. 2018-09-24 16:35:33 +02:00
Marek Bel
bb66bfe6a7 Use cs.minsegmenttime from ConfigurationStore. 2018-09-24 16:22:50 +02:00
Marek Bel
10428b30d9 Use cs.mintravelfeedrate from ConfigurationStore. 2018-09-24 16:01:58 +02:00
Marek Bel
26e2fd1c76 Use cs.minimumfeedrate from ConfigurationStore. 2018-09-24 15:57:24 +02:00
Marek Bel
b8fefceb4d Use cs.retract_acceleration from ConfigurationStore. 2018-09-24 15:53:35 +02:00
Marek Bel
7dbe0afdc4 Use cs.acceleration from ConfigurationStore. 2018-09-24 15:47:36 +02:00
Marek Bel
cee51cf9c3 Use cs.max_acceleration_units_per_sq_second_normal from ConfigurationStore. 2018-09-24 15:40:35 +02:00
Marek Bel
02becb5e6a Use cs.max_feedrate_normal from ConfigurationStore. 2018-09-24 15:09:19 +02:00
Marek Bel
3f28632443 Use cs.axis_steps_per_unit from ConfigurationStore. 2018-09-24 14:54:41 +02:00
PavelSindler
ceb49d1262 finda filament runout: initial version 2018-08-27 04:21:43 +02:00
Robert Pelnar
896734c06b Display '!' instead of 'FR' on status screen when feedrate or acceleration limit reached. 2018-07-23 14:30:41 +02:00
Robert Pelnar
2ce210a8bb TMC2130 feedrate and acceleration limitation - separate profiles for normal and stealth mode 2018-07-19 18:56:01 +02:00
bubnikv
11e7eb27ee Merge remote-tracking branch 'remotes/origin/M221_fix' into MK3_fast_dbg 2018-03-05 19:13:07 +01:00
Robert Pelnar
57499dc6a0 M350 for E axis (8, 16, 32, 64, 128 microsteps) 2018-02-15 15:40:49 +01:00
bubnikv
7a972fd9b0 Split the stepper ISR routine into multiple inline functions,
added an optimized DDA routine for moves with less than 32767 ticks.
2018-01-14 22:37:07 +01:00
bubnikv
30b06488ca Redefined the DDA step and accumulator values to unions to support
access to the low / high words of the 32bit values.
This is a prerequisity for an optimized 16bit only DDA
in case the number of step is lower than 32767.
2018-01-14 17:01:04 +01:00
bubnikv
582a6270b0 Fix of a power panic print stop. 2017-09-21 17:50:39 +02:00
Robert Pelnar
e34d816004 Recover print 2017-09-20 16:04:02 +02:00
Robert Pelnar
2c3387e71d Recover print - simple solution 2017-09-19 21:38:47 +02:00
Robert Pelnar
c4e9e624f5 cmd queue and planner - functions for calculating sd position:
cmdqueue_calc_sd_length
planner_calc_sd_length
2017-09-18 19:36:18 +02:00
michalprusa
06fe85e9ee Linear Advance 2017-07-07 01:58:02 +02:00
PavelSindler
16fffed52d current feedrate and fan speed stored to eeprom in power panic, number of blocks (linear movements) in planner serve for counting SD card recover position, print fan speed error limit prolonged to 15s 2017-07-05 15:04:43 +02:00
PavelSindler
43d696659f 3.0.12-RC2 sync 2017-06-29 18:35:43 +02:00
bubnikv
29cb4b2b5d Removed the non-working pressure advance feature.
Improved accuracy of diagonal moves by oversampling the path discretization.
Accelerated the planner by rewriting time critical routines from floating
point to fixed point arithmetics.
2016-09-01 13:09:56 +02:00
michalprusa
307d17422d 3.0.6 sync 2016-08-11 10:42:53 +02:00