Commit Graph

84 Commits

Author SHA1 Message Date
Yuri D'Elia
7c140bc497 Remove cumulative error in segments without cruising (take 3)
Remove another division by precomputing the division directly in
adv_comp.
2020-06-21 16:32:22 +02:00
Yuri D'Elia
753e651af3 Remove cumulative error in segments without cruising (take 2)
Reduce per-trapezoid calculations
2020-06-21 16:32:22 +02:00
Yuri D'Elia
15548958e9 Remove cumulative error in segments without cruising (take 1)
PR #2591 made LA compression always account for retractions instead of
discarding the current compression steps. While this fixed overextrusion
in short segments followed by wipes, it uncovered another issue in how
the compression steps are spread during the trapezoid calculations
leading to gaps in segments followed by retractions (as highlighted by
/some/ prints in #2693).

LA1.5 always computes the required target compression steps for a
segment at nominal speed. Because of how the extra steps are allocated
using multiples of the accelerating frequency, if the segment is
truncated before cruising is reached, an additional cycle of steps can
be inserted before deceleration starts. Deceleration is also not
guaranteed to be symmetric where up to _two_ cycles can be skipped
depending on the stepping cycle, leading to a situation where a
symmetric acceleration/deceleration block will lead up to a cycle of
accumulated compression.

While forcing an the extra step during deceleration is possible by
tweaking the error term (eISR_Err), this doesn't guarantee balance in
all cases. The underlying issue is that the function is aiming a
compression which cannot be reached (nominal speed), and not at the
effective max speed reached in the trapezoid, thus moving the average
result higher over time.

We fix this by calculating the effective maximum speed (and compression)
reached during the trapezoid, which stops compression on the required
cycle irregardless of the error term, balancing the result.

This is the first unoptimized POC: this is not for production: a lot of
calculations are redundand and could work directly in steps/s^2.
2020-06-21 16:32:22 +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
Yuri D'Elia
0b666ee733 Parametrize LA limits and threshold values
Allow the LA 1.5 MAX value to be configured in Configuration_adv.h.

Define a customizable LA10<>15 detection threshold in function of the
above limit.

Clamp the result of of the LA10->15 return value to always
respect the new LA_K_MAX.
2020-04-28 17:31:42 +02:00
Yuri D'Elia
ae4abdf11f Unify LA for all trapezoid steps
Handle uniformly compression & decompression at any stage of the
trapezoid.

Compared to before, this now enables LA compression also in the cruising
step (handling the converse of a chained wipe), as well as decompression
during acceleration.

Both of these can happen as a result of jerk moves, but are incredibly
rare. This is mostly needed to allow rapid decompression directly at the
acceleration step during travels between a retraction&deretraction.

We also check for the pressure level in a single place, reducing code
size as well as disabling LA earlier when not needed for the rest of the
block.
2020-04-12 01:28:34 +02:00
Yuri D'Elia
13b0e27cd7 Do not overflow during LA acceleration limiting
Perform the check one step earlier, avoiding 32bit overflow for very low
compression factors.

Fixes #2566 (although for K15 to have effect the conversion probably
needs to be adjusted on the low end)
2020-04-09 22:55:47 +02:00
Yuri D'Elia
02a36c498c Release excess pressure within cruising blocks
LA assumes all the nozzle pressure is released at the end of each
extrusion, which makes calculating the required pressure advance during
travels and retracts not normally necessary.

This is not always true in our planner, since the E axis is explicitly
ignored when not in use, but also due to E-jerk allowing a non-linear
jump in speed. And since the compression factor is currently tied by XYZ
axes and not independently calculated, this can result in a wrong
estimation of final pressure in several conditions.

To avoid overburdening the planner, change the underlying assumptions
about backpressure:

1) Pressure is no longer lost when LA is disabled: if a retract is
followed by an unretract of the same length, the pressure will be likely
maintained entirely. This also holds true during travels, as long as the
retract length can overcome all the backpressure (which is the case in
all but the most noodly materials)

2) Pressure is released as soon as possible during travels: we now
enable LA also during travels, but under the sole condition of undoing
excess pressure.

We do that by checking for backpressure at the start of any segment
without an acceleration phase that doesn't have any E-steps (a result
which can happen due to the above). If pressure is not nominal, we run
the extruder in reverse at maximum jerk as long as the segment allows
us, since proper acceleration would be prohibitive at this stage. As the
pressure difference resulting by the above is still _very_ low, any wipe
or short travel will be able to equalize the nozzle pressure *before*
extrusion is resumed, avoiding ooze.
2020-04-09 00:46:57 +02:00
Yuri D'Elia
47db75d5fd Fix overflow and infloop with LA15 and low step rates
When calculating the advance tick interval, be sure to check for integer
overflow. Very low step rates can result in values exceeding uint16_t
causing premature LA tick delivery.

An overflow resulting in zero would also block in an infinite loop
within advance_spread().

Even though such rates are worthless in terms of compensation and often
result in 0 extra ticks as well, do not disable LA for the block (as
doing so would reset the count for short segments) and do not check for
zero in multiple paces either.

Saturate the interval instead, delaying any further tick to the next
block.
2020-02-02 22:49:39 +01:00
Yuri D'Elia
0702e0de6e Use world2machine instead of repeating code 2020-01-26 17:46:50 +01: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
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
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
dc436b71fe Fix position_float after a quickStop condition 2019-06-05 20:25:05 +02:00
Yuri D'Elia
fa454f61e4 Drop unused "speed_lookup_table.h" from planner.cpp 2019-06-05 20:24:58 +02:00
Yuri D'Elia
fa7c0fb2c9 Avoid triggering LA during a Z-priming move
When recovering from a pause, the nozzle is often primed while
being lowered. If LA is triggered under such a move, the pressure
advance will be wasted.
2019-06-03 17:32:51 +02:00
Yuri D'Elia
51d6904dad Multiply the step rate when grouping advance steps 2019-05-27 14:44:09 +02:00
Yuri D'Elia
ab478ec281 Save another 144b by avoiding a calc_timer copy 2019-05-26 16:42:03 +02:00
Yuri D'Elia
294bf4068d Improve debug messages 2019-05-24 17:08:32 +02:00
Yuri D'Elia
53b77bab36 Do not operate on the prev block when already in use 2019-05-24 17:08:32 +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
9425b6b07a Planner: do not recalculate max_adv_steps, since it doesn't change 2019-05-24 17:08:32 +02:00
Yuri D'Elia
2c8e04bd5f Planner: use the correct block when updating LA factors 2019-05-24 17:08:32 +02:00
Yuri D'Elia
124540a06f Adapt LA changes to ConfigurationStore 2019-05-24 17:08:32 +02:00
Yuri D'Elia
45563bfdd3 Formatting sanity 2019-05-24 17:08:32 +02:00
Yuri D'Elia
eeea2725cb Partial LA15 support 2019-05-24 17:08:32 +02:00
Ondrej Tuma
b7fe43bf68 Deleted bad cols/rows definitions for translation. 2019-05-07 12:52:23 +02:00
PavelSindler
1ba046395e fan measurements fix: keep fanSpeedSoftPwm = 255 during measurements, selftest changes 2019-02-06 12:37:18 +01:00
PavelSindler
f9298b37b8 fan check hotfix (selftest, measuring RPM, fan errors) 2019-02-05 04:02:38 +01:00
Robert Pelnar
eea755496b Conditional translation for SYSTEM_TIMER_2 because we want to have posibility to switch between old/new implementation.
Timing functions (millis, micros and delay) replaced in whole source, defined in Marlin.h.
This commit enables original implementation (SYSTEM_TIMER_2 undefined)
Verified with passed complete wizard process.
2019-01-27 22:48:51 +01:00
Robert Pelnar
283e33dd69 Lang - text " cold extrusion prevented" removed from dictionary 2018-11-22 17:44:53 +01:00
Marek Bel
1585dc66b0 Merge remote-tracking branch 'prusa3d/MK3_dev' into simplify_EEPROM_M500
Known limitation: Unable to compile.
2018-10-08 15:58:49 +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