ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
pid_autotuner.h
Go to the documentation of this file.
1#pragma once
2
5#include "pid_controller.h"
6
7#include <vector>
8
9namespace esphome {
10namespace pid {
11
13 public:
14 struct PIDResult {
15 float kp;
16 float ki;
17 float kd;
18 };
20 float output;
21 optional<PIDResult> result_params;
22 };
23
24 void config(float output_min, float output_max) {
27 }
28 PIDAutotuneResult update(float setpoint, float process_variable);
29 bool is_finished() const { return state_ != AUTOTUNE_RUNNING; }
30
31 void dump_config();
32
33 void set_autotuner_id(std::string id) { this->id_ = std::move(id); }
34
35 void set_noiseband(float noiseband) {
36 relay_function_.noiseband = noiseband;
37 // ZC detector uses 1/4 the noiseband of relay function (noise suppression)
38 frequency_detector_.noiseband = noiseband / 4;
39 }
40 void set_output_positive(float output_positive) { relay_function_.output_positive = output_positive; }
41 void set_output_negative(float output_negative) { relay_function_.output_negative = output_negative; }
42
43 protected:
98 PIDResult calculate_pid_(float kp_factor, float ki_factor, float kd_factor);
99 void print_rule_(const char *name, float kp_factor, float ki_factor, float kd_factor);
100 PIDResult get_ziegler_nichols_pid_() { return calculate_pid_(0.6f, 1.2f, 0.075f); }
101
103 float setpoint_ = NAN;
108 float ku_;
109 float pu_;
110 std::string id_;
111};
112
113} // namespace pid
114} // namespace esphome
struct esphome::pid::PIDAutotuner::OscillationAmplitudeDetector amplitude_detector_
enum esphome::pid::PIDAutotuner::State state_
void config(float output_min, float output_max)
void set_output_positive(float output_positive)
void set_noiseband(float noiseband)
struct esphome::pid::PIDAutotuner::RelayFunction relay_function_
PIDResult calculate_pid_(float kp_factor, float ki_factor, float kd_factor)
void print_rule_(const char *name, float kp_factor, float ki_factor, float kd_factor)
void set_output_negative(float output_negative)
struct esphome::pid::PIDAutotuner::OscillationFrequencyDetector frequency_detector_
void set_autotuner_id(std::string id)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
static void uint32_t
void update(float error, RelayFunction::RelayFunctionState relay_state)
enum esphome::pid::PIDAutotuner::OscillationFrequencyDetector::FrequencyDetectorState state
enum esphome::pid::PIDAutotuner::RelayFunction::RelayFunctionState state