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.
This commit is contained in:
Yuri D'Elia 2022-06-27 00:17:46 +02:00
parent ec74b88ebc
commit cc96a47e7f
6 changed files with 227 additions and 27 deletions

View file

@ -1779,7 +1779,7 @@ void serial_read_stream() {
* Output autoreport values according to features requested in M155
*/
#if defined(AUTO_REPORT)
static void host_autoreport()
void host_autoreport()
{
if (autoReportFeatures.TimerExpired())
{
@ -7785,8 +7785,8 @@ Sigma_Exit:
case 310:
{
// parse all parameters
float P = NAN, C = NAN, R = NAN, E = NAN, W = NAN, T = NAN, A = NAN;
int8_t I = -1, S = -1, B = -1;
float P = NAN, C = NAN, R = NAN, E = NAN, W = NAN, T = NAN;
int8_t I = -1, S = -1, B = -1, A = -1;
if(code_seen('C')) C = code_value();
if(code_seen('P')) P = code_value();
if(code_seen('I')) I = code_value_short();
@ -7796,10 +7796,10 @@ Sigma_Exit:
if(code_seen('E')) E = code_value();
if(code_seen('W')) W = code_value();
if(code_seen('T')) T = code_value();
if(code_seen('A')) A = code_value();
if(code_seen('A')) A = code_value_short();
// report values if nothing has been requested
if(isnan(C) && isnan(P) && isnan(R) && isnan(E) && isnan(W) && isnan(T) && isnan(A) && I < 0 && S < 0 && B < 0) {
if(isnan(C) && isnan(P) && isnan(R) && isnan(E) && isnan(W) && isnan(T) && I < 0 && S < 0 && B < 0 && A < 0) {
temp_model_report_settings();
break;
}
@ -7811,7 +7811,7 @@ Sigma_Exit:
if(I >= 0 && !isnan(R)) temp_model_set_resistance(I, R);
// run autotune
if(!isnan(A)) temp_model_autotune(A != 0? A: NAN);
if(A >= 0) temp_model_autotune(A);
}
break;