Both during early init and in uvlo_tiny, display "POWER PANIC DETECTED"
if enough charge is left.
This is not worth doing in regular uvlo_, as we want to give full
priority to the X motor
If power has been lost during startup already a falling edge would be
skipped, causing the print to continue and lose its state without
being able to save again.
Check for a low line after arming the interrupt and simply wait
for reset.
Do not allow uvlo_tiny() to trigger before the previous print has
already been recovered.
A quick repeated power failure could cause uvlo_tiny to overwrite
the Z position before it has been correctly recovered.
enable/disable_z behave differently when PSU_Delta is defined.
During powerpanic and kill however we do *really* need to save energy
and poweroff the motors.
Rename enable/disable_z as poweron/poweroff_z and define some aliases so
that we can use the low-level function where needed.
Use 2 bytes to store extruder temperature during UVLO.
Re-use the storage of EEPROM_UVLO_TINY_Z_MICROSTEPS which has been freed
by previous changes.
Fixes#2303
- In both uvlo_ and uvlo_tiny, calculate Z usteps properly and adjust
the Z position to a true fullstep before disabling the motor. This
avoids shifs during recovery.
- In uvlo_tiny, instead of moving up indefinitely, adjust Z just
once using the smallest move possible (new def UVLO_TINY_Z_AXIS_SHIFT)
- Perform all the uvlo/recovery processing in physical coordinates
and MBL off: there should be no automatic Z movement!
- Disable heaters in both handlers to conserve more power.
- Add timing information to uvlo_tiny too.
- During recovery, to switch between physical and logical positioning
introduce a new "PRUSA MBL" gcode as most of the procedure is
enqueued, and no existing gcode was available.
There is frequently plenty of power left during a PP. Take advantage of
it by moving the extruder to either side of the axis to detach
completely the nozzle from the print.
Re-enable Z during this move to avoid losing the current step.
When the printer is connected to a USB host during a PP (and the host
does not lose power), the rambo can linger for longer, sometimes for
long enough to recover the print state. Drain some more power.
If the motors are off-phase, this is more likely to "bump" them to an
incorrect/reverse full-step, doing worse.
We need to ensure the motors are already positioned on a fullstep
during power panic instead.
Remove the PSU_DELTA exception: Z _always_ needs to be powered here.
Also clear the UVLO flag when using lcd_print_stop. This prevents an
aborted print which has been cancelled while unparking (just prior to
recover) to come back again at the next startup.
- Initially restore the last E position from the eeprom in any case, not
just when using absolute mode (although unnecessary: since it will be
reset later), fixing a possible unitialized position and crash during
recovery (thanks to @leptun)
- Remove useless extra calls to put the extruder in relative mode:
the extruder already starts in relative mode and is later switched to
absolute.
- Replace incorrect calls to STRINGIFY with sprintf_P
- Retract after pressure has been restored in uvlo_tiny, to be
consistent with a regular uvlo (remove the bogus double unretract
as a result).
- Set the real E position prior to the panic *after* the retraction,
using the now-fixed G92.
Do not process serial commands when re-enabling the global isr.
While printing via USB and a power panic is triggered, *any* extra
command should be ignored.
Abuse the "saved_printing" variable to inhibit serial processing.
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.
When check_z_endstop is set, Z_MIN_PIN is checkend regardless of the
moving direction to support Z calibration. This prevents the ability
to use _just_ SG when moving upwards.
But since we know the extruder is at Z_MIN, it's always safe to raise
irregardless, so we can dodge the issue.
Do not unconditionally enqueue a Z move if no move has been requested.
Since Z is calculated using the absolute current (saved) position and
scheduled for later execution, the queue order becomes relevant.
In preparation for #2161, use MBL (G80) as a "new print" boundary
instead of just re-homing to ensure the reset is issued only once for
each print.
Similarly, do not reset the autodetection when LA is disabled via M900
K0. This can/will be used during a print if different quality settings
are used for different filling roles.
Since the advance factor is computed per-segment in LA15, there's no
need to stop the planner. Allow changing K freely at each segment.
This allows varying quality factors for different filling roles, see:
https://github.com/supermerill/Slic3r/issues/108
During pause/resume/crashdetect or powerpanic K might temporarily be out
of sync when used this way. If this becomes an issue, we might need to
store K for each block, as done for the feedrate.
Move the common checks between filament sensors out of fsensor_update().
Disable the runout check if a saved state is already present (this check
was missing in the PAT9125 variant) as this is currently not supported.
Note that the CHECK_FSENSOR looks completely redundant besides
e_active().
Do not set/clear fsensor_watch_runout within fsensor_oq_meassure_start
which is used outside of fsensor_update where it could have a different
starting value.
Set it within fsensor_stop_and_save_print to immediately prevent
re-entry.
Also check for fan_check_error == EFCE_OK in addition to EFCE_FIXED.
Reorganize the check in order to fix both #if[n]def FANCHECK cases,
as similarly done in the SDSUPPORT case a few lines below.
Allow existing gcode using LA10 to transparently take advantage of LA15
by using a simple linear conversion function based on experimental
results with the MK3 implementation of linear advance.
Autodetect LA10 values based on the first M900 instruction contained in
the print. In order to support printing mixed files without resetting
the printer we also reset the autodetection status when starting a new
SD print and/or when explicitly disabling LA.
Since we cannot reliably detect whether a new print is started when
printing via USB, also reset the detection status when homing in G28,
which is generally performed once at each print. Note that this doesn't
clear the previous K value, it only allows a subsequent M900 to provide
LA10 values when printed after a LA15 file.
axis_relative_modes can cleanly handle G90/G91 and M82/M83 without the
need of "relative_mode" entirely.
Change G90/G91 to simply reset all axes according to the requested
state, which avoids to check two variables in get_coordinates(),
fixing the following incorrect handling:
G91 ; all axis relative
M83 ; set extruder absolute
G1 E1 ; should be an absolute move, but still relative
Correctly cleanup the printer state when stopping the current print:
- Disable interrupts while aborting the planner/queue to ensure
new serial commands are not inserted while aborting
- _Always_ call planner_abort_hard() to interrupt any pending move!
- Clear the saved_target, which might be set when calling stop
from within a paused state. Create a new function to clear the
paused state for future use.
- Do not disable/reset the MBL: doing so will destroy the ability to
restart correctly using M999.