vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
cPidController Class Reference

PID Controller. More...

#include <pidcontroller.h>

Public Member Functions

 cPidController (double, double, double, double)
 Create a PID Controller.
 
double GetTargetValue ()
 
double GetPTerm ()
 
double GetITerm ()
 
double GetDTerm ()
 
void Reset ()
 Reset the internal state (integral sum and error history).
 
void SetTargetValue (double value)
 
double Update (double, double)
 Calculate the new output value.
 

Private Attributes

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.
 

Detailed Description

PID Controller.

Definition at line 21 of file pidcontroller.h.

Constructor & Destructor Documentation

◆ cPidController()

cPidController::cPidController ( double  kp,
double  ki,
double  kd,
double  maxOutput 
)

Create a PID Controller.

Parameters
kpProportional gain
kiIntegral gain
kdDerivative gain
maxOutputMax allowed output value (absolute)

Definition at line 31 of file pidcontroller.cpp.

References integralGain, maxIntegral, and maxOutput.

Member Function Documentation

◆ GetDTerm()

double cPidController::GetDTerm ( )
inline

Definition at line 27 of file pidcontroller.h.

References dTerm.

Referenced by cSoftHdAudio::ClockDriftCompensation().

◆ GetITerm()

double cPidController::GetITerm ( )
inline

Definition at line 26 of file pidcontroller.h.

References iTerm.

Referenced by cSoftHdAudio::ClockDriftCompensation().

◆ GetPTerm()

double cPidController::GetPTerm ( )
inline

Definition at line 25 of file pidcontroller.h.

References pTerm.

Referenced by cSoftHdAudio::ClockDriftCompensation().

◆ GetTargetValue()

double cPidController::GetTargetValue ( )
inline

Definition at line 24 of file pidcontroller.h.

References targetValue.

Referenced by cSoftHdAudio::ClockDriftCompensation().

◆ Reset()

void cPidController::Reset ( void  )

Reset the internal state (integral sum and error history).

Definition at line 94 of file pidcontroller.cpp.

References dTerm, firstRun, integralSum, iTerm, previousError, and pTerm.

Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::FlushBuffers(), and Update().

◆ SetTargetValue()

void cPidController::SetTargetValue ( double  value)
inline

Definition at line 29 of file pidcontroller.h.

References targetValue.

Referenced by cSoftHdAudio::ClockDriftCompensation().

◆ Update()

double cPidController::Update ( double  currentValue,
double  dt 
)

Calculate the new output value.

Parameters
currentValueThe current value
dtThe time elapsed since the last update (seconds)
Returns
The output value

Definition at line 51 of file pidcontroller.cpp.

References derivativeGain, dTerm, firstRun, integralGain, integralSum, iTerm, LOGWARNING, maxIntegral, maxOutput, previousError, proportionalGain, pTerm, Reset(), and targetValue.

Referenced by cSoftHdAudio::ClockDriftCompensation().

Member Data Documentation

◆ derivativeGain

double cPidController::derivativeGain = 0
private

Derivative Gain (Kd) - Dampening.

Definition at line 35 of file pidcontroller.h.

Referenced by Update().

◆ dTerm

double cPidController::dTerm = 0
private

Derivative term.

Definition at line 39 of file pidcontroller.h.

Referenced by GetDTerm(), Reset(), and Update().

◆ firstRun

bool cPidController::firstRun = true
private

Flag for first run.

Definition at line 45 of file pidcontroller.h.

Referenced by Reset(), and Update().

◆ integralGain

double cPidController::integralGain = 0
private

Integral Gain (Ki) - Drift correction.

Definition at line 34 of file pidcontroller.h.

Referenced by cPidController(), and Update().

◆ integralSum

double cPidController::integralSum = 0
private

Accumulator for the I-term.

Definition at line 42 of file pidcontroller.h.

Referenced by Reset(), and Update().

◆ iTerm

double cPidController::iTerm = 0
private

Integral term.

Definition at line 38 of file pidcontroller.h.

Referenced by GetITerm(), Reset(), and Update().

◆ maxIntegral

double cPidController::maxIntegral = 0
private

Anti-windup limit for the integral term.

Definition at line 47 of file pidcontroller.h.

Referenced by cPidController(), and Update().

◆ maxOutput

double cPidController::maxOutput = 0
private

Hard limit for output correction.

Definition at line 46 of file pidcontroller.h.

Referenced by cPidController(), and Update().

◆ previousError

double cPidController::previousError = 0
private

Error from the previous step (for D-term)

Definition at line 43 of file pidcontroller.h.

Referenced by Reset(), and Update().

◆ proportionalGain

double cPidController::proportionalGain = 0
private

Proportional Gain (Kp) - Reaction strength.

Definition at line 33 of file pidcontroller.h.

Referenced by Update().

◆ pTerm

double cPidController::pTerm = 0
private

Proportional term.

Definition at line 37 of file pidcontroller.h.

Referenced by GetPTerm(), Reset(), and Update().

◆ targetValue

double cPidController::targetValue = 0
private

The desired buffer fill level in frames.

Definition at line 41 of file pidcontroller.h.

Referenced by GetTargetValue(), SetTargetValue(), and Update().


The documentation for this class was generated from the following files: