Commit Graph

249 Commits

Author SHA1 Message Date
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
Yuri D'Elia
e070bc6455 Remove obsolete and commented variables 2022-07-25 17:30:22 +02:00
Yuri D'Elia
7d82cd641e Rename ADC callback 2022-07-25 17:30:22 +02:00
Yuri D'Elia
bcd8496113 Introduce a new set of temperature values for the PID regulation
*_temperature_raw: buffer for the ADC ISR (read by temp ISR)
*_temperature_isr: latest temperatures for PID regulation (copied from
  _raw values)
*_temperature: latest temperature for user code

The flow:
  - ADC ISR (async)
    - perform oversampling
    - call ADC callback: copy to _raw (async)
  - temp ISR (timer)
    - convert to C (_isr values)
  - user code (async)
      - check temp_meas_ready
      - call updateTemperature()
        - copy from _isr to current
        - syncronize target temperatures

This removes PINDA value averaging (if needed, should be re-implemented
by averaging in user code where needed)
2022-07-25 17:30:22 +02:00
Yuri D'Elia
65cf8e541a Isolate current/target temperature in pid_heater/bed functions 2022-07-25 17:30:22 +02:00
Yuri D'Elia
9e826afee9 Switch regulation interval to 270ms 2022-07-25 17:30:22 +02:00
Yuri D'Elia
c6d0494cbc Split temperature management into it's own ISR
Use a new low-priority "temp_mgr_isr" running at constant rate for
temperature management.

This is done so that the temperatures are sampled at a constant
independent interval *and* with reduced jitter. Likewise for actual
PID management.

This will require further adjustment for the min/max/runaway display,
which cannot be done directly into this function anymore (the code will
need to disable heaters but flag for display to be handled in
manage_heaters).
2022-07-25 17:30:21 +02:00
Yuri D'Elia
2ca16a06cd Rename tp_init to soft_pwm_init for consistency 2022-07-25 17:30:21 +02:00
Yuri D'Elia
38b3e53f67 Syntax/comment cleanup 2022-07-25 17:30:21 +02:00
Yuri D'Elia
932fcbb33f Simplify soft_pwm_isr even further
Isolate the PWM management into soft_pwm_core
2022-07-25 17:30:21 +02:00
Yuri D'Elia
dfd8fee712 Isolate babystep to a separate function 2022-07-25 17:30:21 +02:00
Yuri D'Elia
bd28007312 Rename check_fans>readFanTach manageFans>checkFans 2022-07-25 17:30:21 +02:00
Yuri D'Elia
383319dbac Rename temperature_isr to soft_pwm_isr 2022-07-25 17:30:21 +02:00
Yuri D'Elia
16b9acf8bc Decouple temperature ISR from ADC readings
Read from ADC as fast as possible using the ADC interrupt to get
more accurate instantaneous readings.

Decouple the temperature_isr from the adc reading interval, so that
the two can run independently for future use.
2022-07-25 17:30:21 +02:00
Yuri D'Elia
e87188e7e3 Ensure ADC and thermistor tables use the same oversampling
The current code assumes that values are directly comparable
2022-07-25 17:30:21 +02:00
Yuri D'Elia
2535d072c4 Do not recursively enter temperature_isr
Disable the interrupt source instead, which avoids the added latency of
reentering the isr in the first place.
2022-07-25 17:30:21 +02:00
Yuri D'Elia
82e221e3c7 Remove ADC pullup checks
Setting pullups on the ADC should trigger the model-based check, making
this redundant and wasteful.

Keep the DEBUG_PULLUP_CRASH menu so that we can verify this behavior in
the future.
2022-07-25 17:30:21 +02:00
Yuri D'Elia
f8de274db3 Split fan checks out of temperature.cpp 2022-07-18 17:53:27 +02:00
Yuri D'Elia
e37435b53f Merge remote-tracking branch 'upstream/MK3_3.11.1' into mk311_sync 2022-07-04 16:14:23 +02:00
Yuri D'Elia
5b3441b2bd Fix AMBIENT_RAW_*_TEMP define names
The max/min temperature check were incorrectly using
HEATER_AMBIENT_RAW_*_TEMP (non-existing) instead of the correct
AMBIENT_RAW_*_TEMP (this is not a heater afterall).

This doesn't change the current behavior, since the check defaulted to
the correct path for the MK3+ configuration anyway.
2022-04-29 16:54:39 +02:00
Alex Voinea
e3f48ead9f
Merge pull request #3440 from gudnimg/optimise-checkFanSpeed
Optimise `checkFanSpeed()` Flash use
2022-04-21 14:04:23 +02:00
Alex Voinea
b52597f1b2
Merge branch 'MK3_3.11.1' into MK3_3.10.2 2022-04-07 14:05:34 +02:00
Guðni Már Gilbert
c62c412cc3 Remove unused setting PID_ADD_EXTRUSION_RATE
Even if the setting was turned on, it doesn't do anything useful.
2022-03-30 19:03:41 +01:00
Guðni Már Gilbert
d42ef4784c Optimise checkFanSpeed()
Changes save 28 bytes of flash
2022-03-06 12:54:24 +00:00
Alex Voinea
4ec8781df2 Fix usb print timer 2022-02-13 22:52:49 +01:00
Alex Voinea
fb1c8ee0a3 Change the pullup test 2022-02-08 10:53:47 +01:00
Alex Voinea
c06ec9d05b Add pullup error test to define 2022-02-07 13:56:46 +01:00
Alex Voinea
b7806bf25f Crash if pullups get enabled on the thermistor inputs 2022-02-01 12:34:07 +01:00
Alex Voinea
67e6361ff1 Fix temperature runaway variable types (merge conflict) 2022-01-30 13:16:05 +01:00
Guðni Már Gilbert
9bf45773f9 Merge remote-tracking branch 'upstream/MK3' into rebase-testing-ground-v2 2022-01-30 11:43:16 +00:00
Guðni Már Gilbert
a940c364c9 Create enum class for heating_status variable 2022-01-30 11:39:27 +00:00
Alex Voinea
fb10b4398e Merge pull request #6 from gudnimg/gudni-PR1
Purged some `int`s for `uint8_t` when using the axis enum
2022-01-30 11:30:25 +00:00
Guðni Már Gilbert
f81db56793 temp_runaway_check() parameter _heater_id should be uint8_t
Saves 58 bytes of flash
2022-01-30 11:22:45 +00:00
Guðni Már Gilbert
261f311825 Change two arrays from int to uint8_t
__preheat_counter has max value of 16
__preheat_errors has max value of 5

Saves 58 bytes of flash memory and 4 bytes of SRAM
2022-01-30 11:22:45 +00:00
Voinea Dragos
42c393764f Adjust temperature runaway extruder count 2022-01-30 11:22:43 +00:00
DRracer
0be90dc5d1
Merge pull request #3320 from prusa3d/MK3_3.10.1
Merge MK3_3.10.1 into MK3 after release
2021-12-17 14:02:13 +01:00
Yuri D'Elia
320835a1b7 Do not cancel wait-for-temperature loops in disable_heaters()
Partially revert previous change: cancelling a single loop would often
advance the gcode stream to the next wait-for loop if executed at the
beginning of an SD print, implicitly turning off the flag again.

Cancel the loop directly in UnconditionalStop() which stops the command
queue as well in an atomic way, handling this correctly.
2021-12-10 01:46:20 +01:00
Yuri D'Elia
7ff117d0c4 temp_runaway_stop: remove spourious space in error message 2021-12-07 19:27:18 +01:00