Commit Graph

147 Commits

Author SHA1 Message Date
Marek Bel
aa45091400
Scale extruder motor current linearly with speed. (#2813)
Scale extruder motor current linearly with speed.

49% less heating when running at low speed and standstill, 4% more torque at maximum extrusion rate (15mm^3/s), 15% more torque in high speed movements (un/retractions).

StealthChop mode is used for low speeds (below 900mm/min)
spreadCycle is used above. Transition speed is well above maximum extrusion rate of 15mm^3/s (275mm/min) so mode transition is not expected to be visible on printed surface.

StealthChop is expected to improve printed surface quality (less artifacts).

Warning you can burn extruder motor if it is not the same impedance as original Prusa i3 Extruder stepper motor. There is no current feedback in low speed so lower impedance motor can be burned by over current.

Even there is no direct current feedback, there is no risk for original motor thermal runaway, as motor resistance increases with temperature, current decreases.

Standstill peak phase current is expected to be 500 mA and linearly increase with speed to 970 mA at 900mm/min where spreadCycle constant current regulation takes over and keeps peak current at 805 mA to maximum speed possible.

As motor heating increases with current squared, lowering low speed current from 700mA to 500mA decreases heating 49% in thate mode, where motor spends most of the time.

Enable E-motor cool mode in farm mode only (and experimental menu) - the experimental menu is visible AND the EEPROM_ECOOL variable has a value of the universal answer to all problems of the universe - i.e. two conditions must be met at the start of the FW to enable the E-cool mode. If the user enables the experimental menu, sets the E-cool mode and disables the menu afterwards, on the next start of the FW the E-cool mode will be DISABLED. This is still subject to discussion how much obscure (security through obscurity) we'd like this option to have .

Additional stuff:
* Add serial debug msg to verify if E-cool mode is on
* Avoid access to E-cool mode switch on machines without TMC2130
* Do not allow only M907 E in case of E-cool mode+warn the user on the serial line that the command was skipped

Co-authored-by: D.R.racer <drracer@drracer.eu>
2021-04-23 16:06:28 +02:00
DRracer
42311db5f1
Merge pull request #2789 from wavexx/MK3_TMC2130_DEDGE
Use/enable TMC2130 DEDGE support in MK3/MK3S
2021-01-29 11:13:09 +01:00
Yuri D'Elia
a9625747db Reinstate the nop instruction as delay in non-DEDGE
When TMC2130_MINIMUM_PULSE is 0 a minimum delay is implied.
In this case, use a single "nop" instruction.
2021-01-26 19:43:29 +01:00
Yuri D'Elia
d3734b02cc Also fix delay instances inside unused BACKLASH_[XY] 2021-01-26 16:18:23 +01:00
Yuri D'Elia
b17cdcd4d7 Ensure MINIMUM_PULSE is always 0 in DEDGE mode
This ensures delays are always properly elided without having to check
for DEDGE all over the place.
2021-01-26 16:12:59 +01:00
Yuri D'Elia
2a6989ecd5 Remove TMC2130 special-cases
With the new STEPPER_MINIMUM_DELAY being automatically removed for
TMC2130 we no longer need to add specialized #ifdefs for DEDGE in
babystep.
2021-01-26 16:09:23 +01:00
Yuri D'Elia
4fed728e08 Elide delayMicroseconds for TMC2130 in non-DEDGE mode
Introduce new macros TMC2130_MINIMUM_DELAY/STEPPER_MINIMUM_DELAY for
blocking pauses.

If MINIMUM_PULSE has defined to be zero, avoid the delay call entirely.
2021-01-26 16:02:53 +01:00
DRracer
008d3b0e65
Merge pull request #2792 from wavexx/MK3_fix_high_speed_deceleration
Mk3 fix high speed deceleration
2020-08-06 13:27:52 +02:00
Yuri D'Elia
aebaca5cdc Correct comments regarding acceleration ramp
Backport fixes from upstream Marlin
2020-08-03 18:53:13 +02:00
Yuri D'Elia
8108d50b59 Reintroduce/fix check for step_rate underflow during deceleration
Check for negative results and results under the final_rate
2020-08-03 18:53:13 +02:00
Alex Voinea
12be141188 Fix high speed deceleration 2020-08-03 18:16:13 +02:00
Yuri D'Elia
feafc5e5ab Alternative schedule for LA ticks
Remove most of the original complexity from advance_spread.

Instead of accumulating time to be scheduled, plan ahead of time each
eISR tick using the next main interval + an accumulator (eISR_Err),
which keeps everything much simpler.

The distribution of the advance ticks is now using the real LA
frequency, which leaves a bit more time between the last LA tick and
the main stepper isr.

We take advantage of the accumulator to force a LA tick right after the
first main tick, which removes a +/- 1 scheduling error at higher step
rates.

When decompressing, we force 2 steps instead, so that the direction
reversal happens immediately (first tick zeros esteps, second inverts
the sign), removing another +/- 1 error at higher step rates.
2020-07-29 19:14:48 +02:00
Yuri D'Elia
c54474f2db Guard against planning/numerical errors in short segments
Turns out for high-res curved models the numerical error and the
SLOWDOWN handling in the planner can cause enough variance in the
calculated pressure to trigger LA to continuosly, making matters worse.

Clamp LA again, but only during extrusion, so that the runaway error is
limited by the current segment length.
2020-07-16 18:54:00 +02:00
Yuri D'Elia
fb5f09da6d Fix incorrect precedence for retraction phase
The logic was inverted, causing the fastest isr to always retract
instead of counter-balance the acceleration properly.
2020-07-16 18:53:53 +02:00
Yuri D'Elia
c08f37da96 Use nominal rate for phase calculations
The local interval calculated by advance_spread() might oscillate too
much in narrow intervals.
2020-07-12 17:15:47 +02:00
Yuri D'Elia
78bbfc6237 Fix delay calculations inside babystep()
- Avoid all delays when using DEDGE stepping
- Correctly account for direction change delays
2020-06-24 17:58:43 +02:00
Yuri D'Elia
6ceca9bf85 Implement double-edge stepping
Introduce new wrapper macros to tick the stepper pins.
Default to the original raising-edge stepping mode.

When using the TMC double-edge stepping mode (aka half-wave or
square-wave mode) the _LO macros become no-ops.
2020-06-24 17:58:43 +02:00
Yuri D'Elia
f1efce7e52 Handle LA termination with double/quad stepping properly
Before PR #2591 LA was automatically capped during cruising or
deceleration. However we now rely on reaching the current pressure state
exactly to stop. When dual/quad stepping inside the eISR we might incur
in oscillating behavior if we do not handle it correctly.

This might be the cause behind #2757

This now changes e_step_loops to be a phase-local variable, so we now
reset it each phase too (instead of per-segment).
2020-06-23 16:51:54 +02:00
Yuri D'Elia
50a09824fd Avoid scheduling useless eISR ticks
When switching to a new trapezoid step with the right pressure, cancel
any pending eISR right away.

Similarly do not schedule another eISR if the pressure will be reached
by the end of the eISR.

This was done in the past to preserve the current LA_phase. This is not
needed anymore, since it will be reset at each trapezoid step when LA
is re-initialized.
2020-06-23 15:24:16 +02:00
Yuri D'Elia
173aa2deba Fix bogus timer check preventing fast LA steps to be scheduled
Simplify and fix the broken timer check when scheduling advance ticks.
This dates back to the original LA15 PR, an old bug...
2020-06-22 00:54:50 +02:00
Yuri D'Elia
51a539608c Reset LA_phase at each trapezoid stage
There used to be a single stage where an extruder reversal could occur,
but since PR #2591 reversals can happen up to two times per trapezoid.

Reset LA_phase when ADV_INIT is set, since it is re-inizialized only
when needed a few lines afterward. This improves performance by avoiding
to check the phase continuosly to the end of the trapezoid.

Likewise, always set ADV_INIT during the first cruising step, also to
force a LA_phase reset.
2020-06-22 00:19:47 +02:00
Yuri D'Elia
5082f2a36e Move reset LA state from G80 to M84
Move la10c_reset into finishAndDisableStepper, which is called in both
via lcd_print_stop() and indirectly via M84, saving some space.

M84 is checked-for to determine a complete file, so it's a superior
candidate to G80 (which some people avoid due to MBL issues).
2020-04-29 22:51:23 +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
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
919386c957 Remove several globals by using a single target pressure
In the current code we initialize the LA state on-demand already at the
right step, which makes keeping track of the tick position no longer
necessary.

Make the advance ISR almost stateless by removing the last vestiges of
the original implementation and introduce a single target pressure. This
will be needed later in order to trigger the LA isr inside the cruising
phase.
2020-04-09 00:46:57 +02:00
Yuri D'Elia
9ec0ac9c64 Always reset e_steps between blocks
If e_steps are scheduled, but not ticked, they're just lost.
Only carry over the pressure state.
2020-04-09 00:46:57 +02:00
Yuri D'Elia
e84f82a675 Rewrite filament sensor PAT9125 error handling
Rewrite the logic behind the "chunking"/error count behind the PAT9125.

Basic idea: check the _direction_ of movement returned by the optical
sensor and compare it to the direction of the stepper. To avoid doing
this continuosly (and because the optical sensor doesn't necessarily
have the accuracy to track small distances), do so in chunks.

Each time a chunk doesn't match the expected direction, increase the
error count.

Several improvements were done to the previous code:

- Increase the chunk window: this ensures that a filament with
  poor response returns an usable direction, while also moving the
  average return values from the sensor in the middle of the 12 bits
  available for maximum effectiveness.
- Since the returned values are more reliable, reduce the error count
  (1.25mm*4 = ~5mm before runout detection)
- Track _both_ positive and negative movement, although only trigger
  errors during extrusion (necessary due to several assumptions made
  in the mmu/unloading code)
- Do not reset the counters for each block: accumulate distances
  correctly, allowing detection of any block lenght.
2020-02-06 14:37:46 +01:00
Yuri D'Elia
5c4235b886 Correctly reset the PAT9125 filament counters
When the error count is cleared, the cumulative deltas as well as the
segment lenght which is kept inside the stepper isr need to be reset.

Introduce a helper function fsensor_reset_err_cnt to clear all the
required variables in one place which can be used in most cases
(the only exceptions being quality measument).

Introduce a new function st_reset_fsensor to also clear the segment
lenght within the isr.
2020-02-05 16:21:27 +01:00
Yuri D'Elia
6fbd632c84 Isolate all PAT9125-specific code, fix build on !MK3 variants
- Hide all prototypes related to PAT9125 to force all callers
  to check for the proper sensor, since the handling differences
  are substantial
- Remove unneeded lenght accounting from the stepper isr as as
  consequence.
- Keep detailed soft failure counts for the MK3 on the "last print
  failures" status screen, but fix build on variants without a PAT9125
  by fixing the lcd stats function.
2020-02-05 16:20:12 +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
Marek Bel
219a5e0625 Initialize EEPROM_SILENT in one place both for MK3 and MK25 printers and make it more clear. 2019-10-03 21:25:52 +02:00
leptun
444daceca3 Move define as requested 2019-09-12 13:39:04 +03:00
leptun
78708903e8 Also update eeprom value 2019-09-12 07:16:31 +03:00
leptun
90e5f14309 Fix compile error on MK3 2019-08-30 13:02:00 +03:00
leptun
56c949b9af Fix typo 2019-08-30 12:14:43 +03:00
leptun
d8d0069f97 Fix MK2.x Default stepper power out of sync 2019-08-30 12:12:29 +03:00
Yuri D'Elia
18b8dc89e5 Merge remote-tracking branch 'upstream/MK3' into MK3_LA15 2019-08-04 17:06:34 +02:00
Yuri D'Elia
1435e4a68d Use the computed direction in fsensor_st_block_begin 2019-08-04 16:53:48 +02:00
DRracer
8b806f692e
Merge pull request #1664 from MRprusa3d/PFW-811
"disable_z()" for Delta PSU
2019-07-16 16:46:34 +02:00
Yuri D'Elia
b6bcb901f3 Correct initialization of eISR_Err
Further tweak the initial term to improve the linearity of the resulting
speed after BW filtering.
2019-06-27 13:21:39 +02:00
Yuri D'Elia
2e073527fb Also avoid E direction inversions while coasting 2019-06-19 14:28:04 +02:00
Yuri D'Elia
4b3af0d2df Respect minimum direction change delay 2019-06-19 13:22:44 +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
048628083a Remove clear_current_adv_vars()
The pressure state is already reset implicitly at the end of each block,
meaning an extruder switch will never have to reset the internal state
anyway.

We clear the internal backpressure in the following conditions:

- when switching to a non-LA block
- when quickStop is called
- when the scheduler is idling (losing pressure)
2019-06-05 20:25:19 +02:00
Yuri D'Elia
7d33089d9a Remove use_advance_lead
The per-step state is kept implicitly using nextAdvanceISR,
while the current pressure is decoupled anyway.
2019-06-05 20:25:12 +02:00
Yuri D'Elia
cda9ed4a1d Reset LA state more carefully during stop conditions 2019-06-04 16:22:40 +02:00
Yuri D'Elia
1bed8cfa94 Don't call fsensor_st_next_block repeatedly during the last step
Rely on st_block_begin to perform a single call instead of calling
block_chunk for each advance tick in the last step
2019-06-04 16:22:33 +02:00
Yuri D'Elia
c50b1c0351 Rework the filament counter logic
- Move direction checks out of fsensor: fsensor_counter is now
  always in the same direction as e_steps
- Check the filament chunk after e_steps have been physically done,
  using the real e_step count so far
2019-06-01 22:08:00 +02:00
Yuri D'Elia
47d2562510 Typos 2019-05-26 21:06:29 +02:00