forked from zillevdr/vdr-plugin-softhddevice-drm
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpidcontroller.h
More file actions
54 lines (44 loc) · 1.7 KB
/
pidcontroller.h
File metadata and controls
54 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* @file pidcontroller.h
* PID (proportional, integral, derivative) Controller Header File
*
* @license{AGPL-3.0-or-later}
*/
#ifndef PID_CONTROLLER_H
#define PID_CONTROLLER_H
// Comment this in to transmit PID controller data for tuning/visualization. See DEVELOPER/README.md for instructions.
// #define PID_CONTROLLER_TUNING_AID_ADDRESS "192.168.2.22"
/**
* PID Controller
*
* @ingroup audio
*/
class cPidController {
public:
cPidController(double, double, double, double);
double GetTargetValue() { return targetValue; }
double GetPTerm() { return pTerm; }
double GetITerm() { return iTerm; }
double GetDTerm() { return dTerm; }
void Reset();
void SetTargetValue(double value) { targetValue = value; }
double Update(double, double);
private:
double proportionalGain = 0; ///< Proportional Gain (Kp) - Reaction strength
double integralGain = 0; ///< Integral Gain (Ki) - Drift correction
double derivativeGain = 0; ///< Derivative Gain (Kd) - Dampening
double pTerm = 0; ///< Proportional term
double iTerm = 0; ///< Integral term
double dTerm = 0; ///< Derivative term
double targetValue = 0; ///< The desired buffer fill level in frames
double integralSum = 0; ///< Accumulator for the I-term
double previousError = 0; ///< Error from the previous step (for D-term)
bool firstRun = true; ///< Flag for first run
double maxOutput = 0; ///< Hard limit for output correction
double maxIntegral = 0; ///< Anti-windup limit for the integral term
#ifdef PID_CONTROLLER_TUNING_AID_ADDRESS
void SendTuningAidData(double, double, double, double, double, double);
#endif
};
#endif