Commit Graph

4650 Commits

Author SHA1 Message Date
3d-gussner
ee6821eb0e Add missing MSG_ c= r= 2022-09-14 11:33:24 +02:00
3d-gussner
270a1086ab No translation needed 2022-09-14 11:33:24 +02:00
3d-gussner
0a68de0bbe Update MSG c=xx
Mark unused strings as `_n`
2022-09-14 11:33:24 +02:00
3d-gussner
fd2d62dcd4 Set reserved space back after cherry-pick 2022-09-14 11:33:24 +02:00
3d-gussner
83315d0494 Update config.h translation documentation and move language to group2
Update fw-build.sh
 - Output used space of each translation (easier to troubleshoot)
 - Read config.h max size per translation
 - output variant .map files (easier to troubleshoot and finding missing/unused messages)
2022-09-14 11:33:24 +02:00
Yuri D'Elia
35c3e3ce68 Remove MSG_M117_V2_CALIBRATION
This message is never actually shown on the LCD (it's immediately
overwritten by other content). It also include g-code in a translatable
string, which is not a good idea. It's also otherwise identical to
MSG_V2_CALIBRATION, which we should have used.

Just remove it and save some space in the process.
2022-09-14 11:33:24 +02:00
Yuri D'Elia
c7354bdfe8 lang: Fix usage of new non-translated strings
Fix cherry-pick
2022-09-14 11:33:24 +02:00
Yuri D'Elia
7a80252556 lang: Add support for raw catalog references with _R
_R marks a raw catalog entry as Referenced (= used) for cases where the
catalog pointers are handled at a lower level.
2022-09-14 11:33:24 +02:00
Yuri D'Elia
05093fbf49 lang: Add inline documentation for the various language macros 2022-09-14 11:33:24 +02:00
Alex Voinea
510f13b24a Make the diag pins open collector with pullup.
Solves random crash detected on startup
2022-09-14 07:39:47 +02:00
Alex Voinea
bb57d99c35 Remove the crashDetection software counters and use sfilt 2022-09-14 07:39:47 +02:00
D.R.racer
996f9943a1 Extract PRINTER_ACTIVE into a noinline function
Having the original PRINTER_ACTIVE macro copied at multiple spots doesn't make sense.
Refactoring it into a non-inline function saved ~400 bytes of code.
It should be safe in terms of performance, all occurrences are at non-time critical spots.
2022-09-14 07:31:39 +02:00
Yuri D'Elia
16d666302b Allow choice positioning. Balance Yes/No messages.
Add an additional parameter to control the position of second choice
prompt position (while defaulting to the old).

This allows Yes/No prompts to be equally spaced.
2022-09-14 07:30:57 +02:00
Yuri D'Elia
b41fb8a13a Unify fullscreen/multiscreen/yes-no prompt message handling
Modify lcd_show_multiscreen_message_two_choices_and_wait_P to also
handle single-screen or empty (no-clear) prompts, making other functions
redundant. Saves 76 bytes.

Change existing functions to simply call
lcd_show_multiscreen_message_two_choices_and_wait_P with the correct
arguments.

This changes the prompt of existing Yes/No messages: the previous prompt
would use the last two lines of the LCD, while the new prompt is using
just the last line of the LCD instead.

Translation do not require updates, since the Yes/No translation was
already the same in both implementations.
2022-09-14 07:30:57 +02:00
Yuri D'Elia
d78506a8ea TM: Rename D70 I to D70 S for consistency with M310 S 2022-09-02 15:59:29 +02:00
Yuri D'Elia
9dbee61b74 TM: Remove an unnecessary fabsf call
Ironically gcc was stripping that one for us already.
2022-09-02 15:59:29 +02:00
Yuri D'Elia
81238fbb15 Move MSG_PAUSED_THERMAL_ERROR outside TEMP_MODEL
MSG_PAUSED_THERMAL_ERROR is not specific to model-checking and can be
used also on MK25* variants.
2022-09-02 15:59:29 +02:00
Yuri D'Elia
b48c698562 TM: Update default C/R0 estimates for MK3/MK3S variants 2022-09-02 15:59:29 +02:00
Yuri D'Elia
10c524fdb3 TM: Add M310 [F] parameter to enable autotune self-test 2022-09-02 15:59:29 +02:00
Yuri D'Elia
9b9ce1733c TM: Allow to keep model checking enabled during autotuning
Allow running the model checking during autotuning, with the only
exception being the parameter estimation stage where we alter the same
value which is used by the checker (done to conserve memory/code).

With previous changes the model checker will disable/enable itself when
passing through an unavailable R vector entry, allowing to start the
calibration by checking only the stages where the part fan is disabled.

The C/R0 values should be stable enough to provide a fail-safe mechanism
for printers of the same variant right from the factory.
2022-09-02 15:59:29 +02:00
Yuri D'Elia
ff459a6427 TM: Handle dynamic parameter changing
Instead of assuming the model state is always valid, allow NAN values to
pass-through the various check/estimation stages.

This allows running the model checker with incomplete parameters (for
example, missing entries in the R vector) and resume automatically.
2022-09-02 15:59:29 +02:00
Yuri D'Elia
54e5702f30 TM: Move initial R0 initialization closer to usage 2022-09-02 15:59:29 +02:00
Yuri D'Elia
9b5ef75b68 Correctly translate thermal model LCD messages 2022-09-02 15:59:29 +02:00
Yuri D'Elia
331de988f7 TM: Avoid an useless float promotion 2022-09-02 15:59:29 +02:00
3d-gussner
66b97683bb Update build.sh and travis to build EN_ONLY
Change FARM_MODE
- Active only on EINSYs in EN_ONLY
- Active on miniRAMBo in all languages
2022-08-30 13:57:43 +02:00
Alex Voinea
f5840e1b02 Fix minirambo build 2022-08-30 13:57:43 +02:00
Alex Voinea
d1c545fdd6 Disable farm mode in config file 2022-08-30 13:57:43 +02:00
Alex Voinea
ec84c22865 Remove unused define 2022-08-30 13:57:43 +02:00
Alex Voinea
2959cc0b64 Do not compile farm lcd_commands 2022-08-30 13:57:43 +02:00
Alex Voinea
2b4c2127e6 Make lcd function static 2022-08-30 13:57:43 +02:00
Alex Voinea
3537024ba2 Remove forgotten config in MK2_minirambo_1.0a 2022-08-30 13:57:43 +02:00
Alex Voinea
8033b65a02 Isolate farm preheat config 2022-08-30 13:57:43 +02:00
Alex Voinea
435ee66bdd Move all farm configuration to header 2022-08-30 13:57:43 +02:00
Alex Voinea
d049d09623 Isolate FARM_DEFAULT_SAFETYTIMER_TIME_ms 2022-08-30 13:57:43 +02:00
Alex Voinea
39eb728d54 More farm optimizations
Kudos @gudnimg
2022-08-30 13:57:43 +02:00
Alex Voinea
d1c30c338f Fix farmless mode 2022-08-30 13:57:43 +02:00
Alex Voinea
bef7b086e3 Isolate the entire farm and statistics code 2022-08-30 13:57:43 +02:00
Alex Voinea
7d597eb8b0 Move farm mode to separate file 2022-08-30 13:57:43 +02:00
Alex Voinea
4e7d686b83
Merge pull request #3574 from leptun/extra_optimizations
More optimizations for 3.12 to fit
2022-08-29 19:25:46 +03:00
Alex Voinea
692f51c51e Save target bed temperature, not current temperature 2022-08-28 11:21:17 +03:00
Guðni Már Gilbert
37c9dcbe53 Optimise calculations to use hypot() where possible
flash: -122
RAM: 0

It is defined: hypot(x,y) = sqrtf(x*x + y*y)
2022-08-26 19:36:28 +03:00
Alex Voinea
7d72f0ee2e better lcd printing for IP address
flash: -46
RAM: 0
2022-08-26 19:33:53 +03:00
Guðni Már Gilbert
4e798c9ed1 Remove unused variable maxlimit_status
flash: 0
RAM: -1
2022-08-26 19:29:32 +03:00
Guðni Már Gilbert
7711969e57 ftostr12ns: change xx from long to int
flash: -44
RAM: 0

Largest expected number is 999 after the multiplication by 100.

I measured the execution time drops from ~170us to ~73us.
2022-08-26 19:28:36 +03:00
Guðni Már Gilbert
88e0e33fb2 Use set_destination_to_current instead of memcpy
flash: -14
RAM: 0
2022-08-26 19:27:16 +03:00
Guðni Már Gilbert
7d86a0d121 Reduce a few magic numbers for FILENAME_LENGTH
flash: 0
RAM: 0
2022-08-26 19:26:26 +03:00
Guðni Már Gilbert
22582e560e Remove one redundant st_synchronize() call
flash: -4
RAM: 0

st_synchronize() is called just before leaving gcode_G28() so we don't need to call it again just after leaving gcode_G28()
2022-08-26 19:25:07 +03:00
Guðni Már Gilbert
89fc9f7a62 Optimise lcd_menu_show_sensors_state()
flash: -22
RAM: 0

menu_lcd_lcdupdate_func() takes care of starting lcd_timeoutToStatus if the knob is clicked.

When the knob is clicked we only want to back out of the menu.
This changes makes the menus slightly more conistant behind the scenes.
2022-08-26 19:22:23 +03:00
Guðni Már Gilbert
c2340d3648 lcd_babystep_z should not start lcd_timeoutToStatus
flash: -8
RAM: 0

When the menu is entered and left the function
menu_lcd_lcdupdate_func() takes care of resetting the timer.

Currently the firmware will reset the timer twice when the lcd_babystep_z menu is entered. This commit fixes that.
2022-08-26 19:20:22 +03:00
Guðni Már Gilbert
74d6aead2f Optimise if statements in lcd_tune_menu
flash: -10
RAM: 0

I am basically combining two if statements if(SilentModeMenu == SILENT_MODE_NORMAL)
2022-08-26 19:17:07 +03:00
Alex Voinea
25350dfbbc Remove unused variable bFilamentFirstRun
flash: 0
RAM: -1
2022-08-26 19:14:40 +03:00
Alex Voinea
4ded6f195e Move string to progmem
flash: -52
RAM: -6
2022-08-26 18:59:53 +03:00
Guðni Már Gilbert
f7ae3039f8 Don't include M851 in build if Auto Bed Leveling is not enabled
The variable cs.zprobe_zoffset is not used unless
auto bed leveling is enabled
2022-08-26 15:35:28 +00:00
Guðni Már Gilbert
d87999a020 workDirDepth can be one byte
We set the max working directory depth to 6 (see MAX_DIR_DEPTH)

Changes save 1 byte of SRAM and 50 bytes of flash
2022-08-26 10:56:02 +02:00
Alex Voinea
c7762386df
Merge pull request #3565 from wavexx/m115_respect_settings
Do not prompt on M115 if FW version check has been disabled
2022-08-25 19:43:12 +03:00
Yuri D'Elia
cf1edc85c3 Set a few function attributes to conserve space 2022-08-25 16:50:06 +02:00
Yuri D'Elia
7c8539a9f9 Report correct fan speeds in M155 during calibration 2022-08-25 16:15:51 +02:00
Alex Voinea
78534f3b48 Start at the first segment, not the last segment 2022-08-24 20:19:26 +03:00
Alex Voinea
671519caf3 Optimize by hand since the lto is still stooopit
saves ~100B
2022-08-24 20:19:26 +03:00
Alex Voinea
b27c8b50e0 Fix power panic handling 2022-08-24 20:19:26 +03:00
Alex Voinea
05bd1ba57f Multi-segment pause resume initial 2022-08-24 20:19:26 +03:00
DRracer
2e677ea3ee
Merge pull request #3569 from leptun/fix_card_removed
Fix "Card removed" on startup
2022-08-24 19:17:24 +02:00
DRracer
0933fdb6fe
Merge pull request #3552 from wavexx/temp_model_check
Thermal Model protection
2022-08-24 19:16:48 +02:00
Alex Voinea
ef8be4dfca Fix "Card removed" on startup 2022-08-24 20:10:09 +03:00
Alex Voinea
f2f136e014 Use timer3 instead of timer5 on miniRambo 2022-08-24 10:18:45 +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
35708a61fe No longer disable temperature management in xyzcal
We already disable the heaters upon entering, and the new temperature
isr doesn't perform any direct movement until we return to the main
loop.

This allows us to remove direct control of the soft_pwm interrupt from
the header, which is dangerous.
2022-08-23 17:19:23 +02:00
Yuri D'Elia
7cd888cd0a Update documentation of ThermalStop() 2022-08-21 15:22:46 +02:00
Yuri D'Elia
b672be90b2 Do not overwrite saved values if TM error occurs while paused 2022-08-21 14:53:42 +02:00
Yuri D'Elia
d8d085287e Re-enable bed temperature automatically for transitory errors 2022-08-21 14:49:12 +02:00
Yuri D'Elia
30dccb3252 Switch to ATOMIC sections instead of cli/sei/CRITICAL_SECTION 2022-08-21 14:49:12 +02:00
Yuri D'Elia
ee12cbd58e Do not prompt on M115 if FW version check has been disabled
As done for M862.4, do now show an upgrade prompt if FW version check as
been disabled in the Settings -> HW Setup -> Checks menu.
2022-08-20 16:55:32 +02:00
DRracer
3ebd8b88a4
Merge pull request #3486 from gudnimg/gudni-optimisation
Flash optimizations in loop() and status screen menu
2022-08-19 17:21:17 +02:00
DRracer
0a8d2a3224
Merge pull request #3456 from wavexx/filament_load_consistency
Cleanup: use more constants in M701
2022-08-19 17:14:54 +02:00
DRracer
84888507e3
Merge pull request #3557 from wavexx/fix_g28_code_value
G28: check for X/Y/Z parameters before calling code_value_long
2022-08-19 17:12:07 +02:00
DRracer
2a0989c440
Merge pull request #3551 from wavexx/eof_crash_reentry
Prevent re-entry in EOF command processing
2022-08-19 17:07:21 +02:00
Yuri D'Elia
06d19b472a G28: check for X/Y/Z parameters before calling code_value_long
Fixes #3555, thanks to @toombaumarkt
2022-08-07 00:36:54 +02:00
Yuri D'Elia
3a1914f2fb Simplify printingHasFinished
Unswitch the call to file.close().

Do not call quickStop(): motion has already completed due to
st_synchronize.
2022-08-06 23:29:34 +02:00
Yuri D'Elia
4f22de2333 Do *not* shorten the current command in printer_smodel_check
printer_smodel_check was incorrectly substituting the final " with a
null in the command to simplify the model string comparison, but in
doing so was also corrupting the next pop from the cmdqueue.

We can modify the current strchr_pointer as long as we *don't* change
it's length. This can cause an incorrect extra read from the queue,
resulting in the last command to be completely ignored.
2022-08-06 23:15:46 +02:00
Yuri D'Elia
68c04ca2f6 Switch a few pointers that don't manipute strings to const 2022-08-06 23:08:03 +02:00
Yuri D'Elia
a533ba3574 Reset sdpos_atomic when starting a new SD print
Fix an incorrect SD offset on the first G-Code command when the second
SD print is started.
2022-08-06 22:16:50 +02:00
3d-gussner
8cbe69e285 Update RepRap documentation 2022-08-02 17:56:53 +02:00
3d-gussner
9633f34e89
Merge pull request #3544 from 3d-gussner/MK3_Fix_po_for-MK25s
Sync PF-build.sh and MK404-build.sh with MK3_3.11.1 branch
2022-07-29 16:13:59 +02:00
Yuri D'Elia
c0b5fea525 Prevent re-entry in EOF command processing
cmdqueue will run commands when EOF is reached without returning to the
main loop, which is already incorrect.

However, since it needs to ensure the queue is empty, an st_synchronize
call can result in a re-entrant call to get_command, which will
reprocess EOF again. Even if we removed st_synchronize, another command
could be picked by an unsuspecting manage_inactivity() somewhere else.

Short-circuit EOF processing by closing the file early and checking for
the file state early in get_command.

This should fix #3549
2022-07-29 15:55:54 +02:00
Guðni Már Gilbert
ca8d47a6da If lcd_draw_update is set outside lcd_status_screen
then render the sceen without delay

This adds only 10 bytes of flash
2022-07-27 11:55:08 +00:00
Guðni Már Gilbert
f6fd91a235 Optimise lcd_status_screen
Saves 20 bytes of flash
2022-07-27 11:14:18 +00:00
Guðni Már Gilbert
33a0a58810 Optimise manage_inactivity call in loop()
Saves 12 bytes of flash
2022-07-27 11:14:17 +00:00
Yuri D'Elia
c5c2557c5e Improve M310 documentation 2022-07-25 17:30:22 +02:00
Yuri D'Elia
41abe1689c Block LCD during temperature model autocalibration 2022-07-25 17:30:22 +02:00
Yuri D'Elia
79161f829e Remove last_alert_sent_to_lcd and simplify mintemp alert automaton
Thanks to LCD message priorities this not needed anymore and it's just
overhead.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
374b829fb6 Generalize menu_block_entering_on_serious_errors for menu lockout
Call this variable menu_block_mask instead. We don't need to know the
exact reason of why we're locking the menu.

We will be able to reuse this to prevent menu entry during more
activities in a cleaner way than testing for each condition as it's
currently done for both menu entry and longpress.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
49a288e6cf Restore the "MINTEMP * fixed" message
Set the LCD messages with the correct priority
2022-07-25 17:30:22 +02:00
Yuri D'Elia
4ca0012077 Prevent longpress if a serious error is set 2022-07-25 17:30:22 +02:00
Yuri D'Elia
cb3fec5cac Improve M310 documentation 2022-07-25 17:30:22 +02:00
Yuri D'Elia
e77a5345a2 Do not show "THERMAL ANOMALY" with "M310 B0"
This allows us to use "M310 B0 W0.01" as a way to report the current
error continuosly on the serial without 1) more code and 2) without
preventing regular usage.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
19df196e1f Better differentiation between pause/paused resume/resumed states
Use OCTOPRINT_ASK_* for the present form of actions. In these cases the
host will perform the pausing manouvers for us.

Use OCTOPRINT_* instead for the past tense forms when we are in charge.

Also always emit the action, whether we are or not sd-printing. This is
due to the new Stopped handling behaving correctly in either case.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
39ad53ab11 Simplify fan checks now that lcd pause works correctly 2022-07-25 17:30:22 +02:00
Yuri D'Elia
1eb7871bab Also save fan speeds during a thermal error pause
Similarly to temperatures, the fan speed is overwritten and needs to be
restored appropriately.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
c98e133ae2 Never stop spinning the extruder fan on thermal failures 2022-07-25 17:30:22 +02:00
Yuri D'Elia
eccfcd7424 Save/restore temperatures during a thermal pause
Re-used saved_* vars (as normally used during the paused state) to
backup the original values when a thermal error occurs.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
63dab63f2e uvlo: Never wait for bed temperature when recovering
If the user accepted to resume, do not wait for bed temperature when
recovering. This only adds a pointless delay when recovering a short
pause and doesn't really improve the recovery quality after a long
pause.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
8f02262bbd Save/restore bed temperature during pause
This will be needed during a thermal error pause that disables the bed
as an additional safety precaution.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
9ef80226c9 Rename argument of ThermalStop for clarity 2022-07-25 17:30:22 +02:00
Yuri D'Elia
b9fc73c4c3 TM: Pause the print and allow recovery from a thermal error
Do not allow resuming until all thermal and fan errors are clear.

Call the appropriate resume function when resuming a printing depending
on the saved_print state (is saved_print is available, then we always
need to resume from the saved state even when printing via usb).

Clear the Stopped state when resuming, so that commands can be accepted
again.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
f454d1ecf2 TM autotune: fix off-by-one in fan power levels 2022-07-25 17:30:22 +02:00
Yuri D'Elia
5dc0d5f7fa TM autotune: fail if value is outside of the boundaries
Ensure we never fall into the boundary values provided by the min/max
limits.

Save/restore the initial guess value, so that a convergence failure
restores the initial model state.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
d1864011f4 Handle pause/stop in the main loop, again
Force processing of the pause and stop "parking" commands _after_ the
main loop completes.

This was/is currently done in lcd_commands, which is a poor place to
continue processing, since it can be called already within an aborted
command. This requires checking for planner_aborted before any action
can be performed.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
f835537e88 Exclude TempErrorSource::ambient for boards without a thermistor 2022-07-25 17:30:22 +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
48c7c9d464 Exclude M310 if TEMP_MODEL is not enabled 2022-07-25 17:30:22 +02:00
Yuri D'Elia
142db85bbb Pause: only move to park position when homed
This can happen is pause is issued before homing.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
fc10ca3146 Change how "Stopped" is handled internally, do not inhibit motion
Do not inhibit motion when Stopped is set.

We actually do need to move to move away the extruder from the bed, and
setting Stopped breaks it without adding any sort of security (M*
commands, such as M600 could still perform moves and still pass
through, while M104 would still set heaters).

During a hard error the internal queue is cleared (and sd file closed,
if any), so no new "unforeseen" command can be read.

Handle "Stopped" instead as a flag to inhibit serial processing and
automatically switch to "paused for user" state. While in this state
simply drop any input without incrementing the processed gcode line
number, behaving as-if the last command was still being processed.

This allows "Stopped" to correctly handle a printer-initiated paused
state and recover as expected by requesting a resend when resuming.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
b3ca70a007 Show thermal warnings using the new LCD_MESSAGE_INFO priority
Add a new LCD_MESSAGE_INFO priority which can be overridden by regular
status updates, but only if a certain amount of time has passed.

Assign a time stamp to all message updates, so that the time since the
last update can be determined. Also switch the message type to Status,
so that the message always becomes visibile.

Always show status or info messages when printing via SD if the message
is recent enough.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
8d9d367d6b Implement Timer::expired_cont()
Returns true if the timer is not running, effectively allowing to check
if a certain set time in the future has passed.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
dc2d596f40 Do not allow lcd_updatestatus to be called directly
Enfoce the usage of lcd_setalertstatuspgm and lcd_setstatus so what we
consistently have alert severities properly set.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
6751586db6 Cleanup original thermal error handlers.
Remove useless repeated calls to disable heaters and turn on the fans,
since this is done at a higher level.

Avoid repeating messages on the serial. Do it just once.

Make a critical alert sound unconditionally.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
50c71924a2 Include fan measurements when estimating resistance 2022-07-25 17:30:22 +02:00
Yuri D'Elia
92bc7554b6 Enable the model last, if set
We need all the values to be set before we can attempt to enable the
model.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
49048fdcd6 Add temperature model configuration for MK3 2022-07-25 17:30:22 +02:00
Yuri D'Elia
ea0840dee9 Refuse to run TM calibration if the printer is not idle 2022-07-25 17:30:22 +02:00
Yuri D'Elia
9c971b1b89 Add a note about resetting waiting_inside_plan_buffer_line_print_aborted 2022-07-25 17:30:22 +02:00
Yuri D'Elia
0680c0b428 Refresh the lcd periodically during calibration 2022-07-25 17:30:22 +02:00
Yuri D'Elia
47d2e9e61c Handle failures during calibration
Break out of the autotuning if a thermal error condition is detected and
attempt to restore a safe initial state irregardless of the error
handlers.

Also error out if the estimation fails to converge.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
cc96a47e7f Implement temperature model autotuning
Calibrate C/R values via univariate minimization using golden section.
This is done in several passes:

- Bootstrap C by setting an initial high R value
- Calibrate R at the requested working temperature
- Cooldown
- Refine C to the final value
- Estimate R losses for a subset of fan speeds
- Interpolate remaining values to speed-up the process

This results in robust values which are tailored to the current
filtering constants, and avoid having to sample for an extended
time to reach the required resolution.

The refining pass could avoid cooldown if the recording buffer was at
least twice as large, so that we could record both the heating and the
steady-state, saving _considerable_ time.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
ec74b88ebc Correct pre-warning to just warning 2022-07-25 17:30:22 +02:00
Yuri D'Elia
14622bc577 Actually disable the temperature manager in TempMgrGuard 2022-07-25 17:30:22 +02:00
Yuri D'Elia
8620059067 Allow to disable the model warning beeping
Mostly useful for debugging
2022-07-25 17:30:22 +02:00
Yuri D'Elia
6832ec7648 Allow to save/restore temperature model settings
This currently bypasses the ConfigurationStore, which doesn't fit the
malin model nicely.

temp_model is using it's own private copy directly.

But maybe we should change this in the future.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
b0b2ff5f9e Rewrite/modularize the model checker
- Allow all parameters to be changed at runtime through M310
- Move the model prototypes into a separate temp_model.h header
- Allow the checked to be enabled/disabled at runtime
- Introduce a warning threshold
2022-07-25 17:30:22 +02:00
Yuri D'Elia
fabf511b97 Add the ability to log continuously
TEMP_MODEL_LOGGING enables D70 to record precisely each cycle of the
temperature regulation for offline model simulation
2022-07-25 17:30:22 +02:00
Yuri D'Elia
690affe5a2 Further enhance thermal error priorities
When triggering a thermal error, allow higher-priority errors to
override the initial error source.

This allows a fatal error such as maxtemp to trigger to a full stop even
if thermal runaway has already been triggered.

Reorder error types according to their priority.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
8220d0196b Lock onto the first error source until cleared
Do not overwrite the error source if the error flag is already set.

As checks are performed in priority order, this ensures min/maxtemp
user-level handlers are triggered even if the thermal model can detect
an issue in the same cycle.

This restores MAXTEMP handling, which was simply shadowed.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
f82048977a Start PWM timers _after_ initializing min/maxtemp ranges
This would otherwise cause check_temp_raw() to operate on unitialized
values and trigger failures too early.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
f1d88ebd40 Protect pid_tuning_finished behind temperature.cpp
Setting pid_tuning_finished can result in the heaters stuck to full
power. As a result, we need to ensure that when PID management is
disabled, heaters are also.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
442b2e16de Set pid_tuning_finished globally to true
Use pid_tuning_finished as a flag to prevent automatic PID management.
As a result, set the default start-up state to true and adjust the
dependent code accordingly.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
92418e9d1b Do not perform PID management while autotune is running 2022-07-25 17:30:22 +02:00
Yuri D'Elia
c15d599f71 Convert two PID_autotune strings to PROGMEM 2022-07-25 17:30:22 +02:00
Yuri D'Elia
0c1c350a93 Simplify one expression 2022-07-25 17:30:22 +02:00
Yuri D'Elia
70093fc9dc Allow to redefine basic model constants 2022-07-25 17:30:22 +02:00
Yuri D'Elia
a15f2807d9 Allow to continue printing with TEMP_MODEL_CHECK_WARN_ONLY for debugging 2022-07-25 17:30:22 +02:00
Yuri D'Elia
929843e295 Switch two divisions to faster multiplications 2022-07-25 17:30:22 +02:00
Yuri D'Elia
bc53bd5305 Make the error threshold be sample-rate invariant 2022-07-25 17:30:22 +02:00
Yuri D'Elia
3eda8b61ee Include the model checker with hard-coded constants 2022-07-25 17:30:22 +02:00
Yuri D'Elia
61575995e0 Isolate temp runaway checks from PID management 2022-07-25 17:30:22 +02:00
Yuri D'Elia
026733e75f Improve comments 2022-07-25 17:30:22 +02:00
Yuri D'Elia
283d5566f1 Limit the rate manage_heater() as it did previously
Avoid running the user-level error handlers too fast.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
de77a47906 Correct handling of preheat/runaway errors
As for min/maxtemp, flag the error in the isr, then handle it in the
user code calling the original handler.
2022-07-25 17:30:22 +02:00
Yuri D'Elia
bd9a6acd59 Correct handling of min/maxtemp
- Flag the error condition from the temp_mgr_isr
- Handle the error state from the user code

Currently only handles min/maxtemp and relays the error to the original
handler (which is a poor fit for the current design).
2022-07-25 17:30:22 +02:00
Yuri D'Elia
4a0203d691 Isolate oTimer4minTempHeater/Bed into check_min_temp 2022-07-25 17:30:22 +02:00
Yuri D'Elia
7659844012 Reimplement disable_heater to take immediate effect
Split off setIsrTargetTemperatures and temp_mgr_pid() so that we can
propagate the target temperatures instantaneously down the pid/pwm chain
during emergencies.

This reduces the amount of code in disable_heater() itself, making it
a bit more maintenable.

The bed still isn't disabled on-the-spot yet, due to the heatbed_pwm
automaton. To be improved later.
2022-07-25 17:30:22 +02:00