ESPHome 2025.5.2
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
pid_autotuner.h
Go to the documentation of this file.
1#pragma once
2
5#include "pid_controller.h"
6#include "pid_simulator.h"
7
8#include <vector>
9
10namespace esphome {
11namespace pid {
12
14 public:
15 struct PIDResult {
16 float kp;
17 float ki;
18 float kd;
19 };
24
25 void config(float output_min, float output_max) {
28 }
29 PIDAutotuneResult update(float setpoint, float process_variable);
30 bool is_finished() const { return state_ != AUTOTUNE_RUNNING; }
31
32 void dump_config();
33
34 void set_autotuner_id(std::string id) { this->id_ = std::move(id); }
35
36 void set_noiseband(float noiseband) {
37 relay_function_.noiseband = noiseband;
38 // ZC detector uses 1/4 the noiseband of relay function (noise suppression)
39 frequency_detector_.noiseband = noiseband / 4;
40 }
41 void set_output_positive(float output_positive) { relay_function_.output_positive = output_positive; }
42 void set_output_negative(float output_negative) { relay_function_.output_negative = output_negative; }
43
44 protected:
99 PIDResult calculate_pid_(float kp_factor, float ki_factor, float kd_factor);
100 void print_rule_(const char *name, float kp_factor, float ki_factor, float kd_factor);
101 PIDResult get_ziegler_nichols_pid_() { return calculate_pid_(0.6f, 1.2f, 0.075f); }
102
103 uint32_t enough_data_phase_ = 0;
104 float setpoint_ = NAN;
109 float ku_;
110 float pu_;
111 std::string id_;
112};
113
114} // namespace pid
115} // 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
void update(float error, RelayFunction::RelayFunctionState relay_state)
enum esphome::pid::PIDAutotuner::OscillationFrequencyDetector::FrequencyDetectorState state
enum esphome::pid::PIDAutotuner::RelayFunction::RelayFunctionState state