-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPCTEMP improvements #25503
MPCTEMP improvements #25503
Conversation
…t temperature detection
Make sure timers are initialised
…MPCTEMP-tuning-to-use-the-Alternative-Method-
Ooof - good catch, and good fix :) |
I need more checks to see if my "manual" cherry-pick is ok but it seems not to cool down correctly (M360 T S0). It started to cool down but stopped at 110C° |
in method |
I changed to: |
Yes, you're quite right! |
Fixed initialisation of ambient_temp
331d2c2
to
43d21d5
Compare
dca8a7b
to
8848205
Compare
By changing some of the general-purpose elements of the I have (for the moment) preserved both implementations, although that now seems less important, especially considering that |
e5ee06c
to
9b9a622
Compare
a2b69e2
to
14e43f0
Compare
14e43f0
to
fec8d50
Compare
Oh wow - good work! I was pondering whether there would be value in having a statically allocated global "scratchpad" of memory allocated that could be used by systems as working memory rather than each system having it's own workspace. For example you won't be running Temperature Tuning and Bed Levelling at the same time, so if there was a way of allowing those two systems to share their working memory that may be of benefit. |
Description
I've broken down the large MPCTEMP auto-tuning function into a simpler function containing the maths logic and a helper class
MPC_autotuner
that performs and hold the results of all the measurements.It may be hard to read this pull request due to the restructuring of the code, however to summarise the code locations on bugfix_2.1.x:
housekeeping
lambda (ln 935) andOnExit
handler (ln 936) have been moved intoMPC_autotuner
class`MPC_autotuner::measure_ambient_temp()
MPC_autotuner::measure_heatup()
MPC_autotuner::measure_transfer()
This branch also adds the functionality to allow MPC autotuning to use an alternative method to establish model parameters from the rate of change of heating.
The tuning algorithm falls back to this method if the original (asymptotic) method fails to produce sensible values for the
sensor_responsiveness
andblock_capacity
Details
MPC_autotuner::housekeeping()
andMPC_autotuner::init_timers()
handles the management of timers by keeping track of current time and next report times.Literals (e.g.
10000UL
) have been converted to const variables (e.g.const millis_t test_interval_ms = 1000UL;
) to improve code readabilityAdded enum return type:
to improve readability of return from the housekeeping function. Used to be a
bool
withtrue
meaning the test has been cancelled by M108, now just returns CANCELLED.Brought consistency to all variables by following the convention of using the
_ms
postfix to indicate times in millisecondsAdded a
MS_TO_SEC_PRECISE(N)
macro to turn a time in milliseconds into time in (fractions of) seconds.Used
MS_TO_SEC_PRECISE
andSEC_TO_MS
macros to make conversions more readable (rather than using literals).'M306 T' Command has been extended to allow 'M306 TA' and 'M306 TD' to force asymptotic and differential tuning. Omitting the
A
orD
will attempt asymptotic first and fall back to differential. See: MarlinFirmware/MarlinDocumentation#491Requirements
None
Benefits
The code is clearer to reason about. Each measurement step is isolated in it's own function separated from the business logic of using the measurements to calculate the parameters of MPC temp.
This makes the MPC Temperature auto tuning more reliable in situations where the original method fails.
Gives a solid basis for me to be able to implement: #25496
Configurations
None - works in all configs.
Related Issues
Gives a solid basis for me to be able to implement: #25496
Related documentation changes: MarlinFirmware/MarlinDocumentation#491