semf
semf::PidController Class Reference

Implementation of an pid (proportional integral derivative) regulator. More...

#include <pidcontroller.h>

Collaboration diagram for semf::PidController:
Collaboration graph

Public Member Functions

 PidController (double kp, double ki, double kd, double sampleTime, double yMin, double yMax, double setpoint=0, double yStart=0, double deltaMax=DBL_MAX)
 Constructor. More...
 
virtual ~PidController ()=default
 
void setKp (double kp)
 Set the proportional gain. More...
 
double kp () const
 Returns the proportional gain. More...
 
void setKi (double ki)
 Set the gain of the integral. More...
 
double ki () const
 Get the gain of the integral. More...
 
void setKd (double kd)
 Set the gain of the derivative. More...
 
double kd () const
 Returns the gain of the derivative. More...
 
void setSampleTime (double sampleTime)
 Set the sample time of the controller. More...
 
double sampleTime () const
 Returns the current configured sample time. More...
 
void setSetpoint (double setpoint)
 Set the controller set point. More...
 
double setpoint () const
 Returns the current set point. More...
 
void setMaxOutput (double max)
 Limits the maximum value of the output. More...
 
double maxOuput () const
 Returns the maximum value which the output is allowed to have. More...
 
void setMinOutput (double min)
 Set the minimum possible output. More...
 
double minOutput () const
 Returns the minimum possible output. More...
 
void setMaxDelta (double delta)
 Set the max delta of the output between two samples. More...
 
double maxDelta () const
 Returns Set the max delta of the output between two samples. More...
 
void reset (double yStart=0)
 Resets the past sampled values which will be used for the calculation of the integral and derivative. More...
 
virtual double calculate (double currentValue)
 Calculates the output value dependent to the actual value. This method must be called cyclically at the interval of the set sampling time. More...
 

Detailed Description

Implementation of an pid (proportional integral derivative) regulator.

Definition at line 20 of file pidcontroller.h.

Constructor & Destructor Documentation

◆ PidController()

semf::PidController::PidController ( double  kp,
double  ki,
double  kd,
double  sampleTime,
double  yMin,
double  yMax,
double  setpoint = 0,
double  yStart = 0,
double  deltaMax = DBL_MAX 
)

Constructor.

Parameters
kpProportional coefficient.
kiIntegral coefficient.
kdDerivative coefficient.
sampleTimeThe sampling time [s].
yMinThe minimum output value.
yMaxThe maximum output value.
setpointThe value on which the output is to be regulated.
yStartThis value is used for the first calculation.
deltaMaxThe maximum permissible change of the output value.

Definition at line 16 of file pidcontroller.cpp.

◆ ~PidController()

virtual semf::PidController::~PidController ( )
virtualdefault

Member Function Documentation

◆ calculate()

double semf::PidController::calculate ( double  currentValue)
virtual

Calculates the output value dependent to the actual value. This method must be called cyclically at the interval of the set sampling time.

Parameters
currentValueThe current value.
Returns
The new output value of the controller (the input to the plant).

Definition at line 146 of file pidcontroller.cpp.

◆ kd()

double semf::PidController::kd ( ) const

Returns the gain of the derivative.

Returns
The gain of the derivative.

Definition at line 71 of file pidcontroller.cpp.

Here is the caller graph for this function:

◆ ki()

double semf::PidController::ki ( ) const

Get the gain of the integral.

Returns
The gain.

Definition at line 57 of file pidcontroller.cpp.

Here is the caller graph for this function:

◆ kp()

double semf::PidController::kp ( ) const

Returns the proportional gain.

Returns
The proportional gain.

Definition at line 45 of file pidcontroller.cpp.

Here is the caller graph for this function:

◆ maxDelta()

double semf::PidController::maxDelta ( ) const

Returns Set the max delta of the output between two samples.

Returns
The max delta of the output.

Definition at line 129 of file pidcontroller.cpp.

◆ maxOuput()

double semf::PidController::maxOuput ( ) const

Returns the maximum value which the output is allowed to have.

Returns
The maximum limit of the output.

Definition at line 107 of file pidcontroller.cpp.

◆ minOutput()

double semf::PidController::minOutput ( ) const

Returns the minimum possible output.

Returns
The minimum possible output.

Definition at line 118 of file pidcontroller.cpp.

◆ reset()

void semf::PidController::reset ( double  yStart = 0)

Resets the past sampled values which will be used for the calculation of the integral and derivative.

Parameters
yStartThe start value for the integral (should 0 of no integral is used).

Definition at line 134 of file pidcontroller.cpp.

◆ sampleTime()

double semf::PidController::sampleTime ( ) const

Returns the current configured sample time.

Returns
The sample time.

Definition at line 85 of file pidcontroller.cpp.

Here is the caller graph for this function:

◆ setKd()

void semf::PidController::setKd ( double  kd)

Set the gain of the derivative.

Parameters
kdThe new gain.

Definition at line 62 of file pidcontroller.cpp.

Here is the call graph for this function:

◆ setKi()

void semf::PidController::setKi ( double  ki)

Set the gain of the integral.

Parameters
kiThe new gain.

Definition at line 50 of file pidcontroller.cpp.

Here is the call graph for this function:

◆ setKp()

void semf::PidController::setKp ( double  kp)

Set the proportional gain.

Parameters
kpThe new gain

Definition at line 37 of file pidcontroller.cpp.

Here is the call graph for this function:

◆ setMaxDelta()

void semf::PidController::setMaxDelta ( double  delta)

Set the max delta of the output between two samples.

Parameters
deltaThe max delta of the output.

Definition at line 123 of file pidcontroller.cpp.

◆ setMaxOutput()

void semf::PidController::setMaxOutput ( double  max)

Limits the maximum value of the output.

Parameters
maxThe maximum value of the output.

Definition at line 101 of file pidcontroller.cpp.

◆ setMinOutput()

void semf::PidController::setMinOutput ( double  min)

Set the minimum possible output.

Parameters
minThe minimum possible output.

Definition at line 112 of file pidcontroller.cpp.

◆ setpoint()

double semf::PidController::setpoint ( ) const

Returns the current set point.

Returns
The current set point.

Definition at line 96 of file pidcontroller.cpp.

Here is the caller graph for this function:

◆ setSampleTime()

void semf::PidController::setSampleTime ( double  sampleTime)

Set the sample time of the controller.

Parameters
sampleTimeThe sample time.

Definition at line 76 of file pidcontroller.cpp.

Here is the call graph for this function:

◆ setSetpoint()

void semf::PidController::setSetpoint ( double  setpoint)

Set the controller set point.

Parameters
setpointThe set point.

Definition at line 90 of file pidcontroller.cpp.

Here is the call graph for this function: