semf
pidcontroller.h
Go to the documentation of this file.
1
10#ifndef SEMF_UTILS_PROCESSING_PIDCONTROLLER_H_
11#define SEMF_UTILS_PROCESSING_PIDCONTROLLER_H_
12
13#include <cfloat>
14
15namespace semf
16{
21{
22public:
35 PidController(double kp, double ki, double kd, double sampleTime, double yMin, double yMax, double setpoint = 0, double yStart = 0,
36 double deltaMax = DBL_MAX);
37 virtual ~PidController() = default;
38
43 void setKp(double kp);
48 double kp() const;
53 void setKi(double ki);
58 double ki() const;
63 void setKd(double kd);
68 double kd() const;
73 void setSampleTime(double sampleTime);
78 double sampleTime() const;
83 void setSetpoint(double setpoint);
88 double setpoint() const;
93 void setMaxOutput(double max);
98 double maxOuput() const;
103 void setMinOutput(double min);
108 double minOutput() const;
113 void setMaxDelta(double delta);
118 double maxDelta() const;
124 void reset(double yStart = 0);
131 virtual double calculate(double currentValue);
132
133private:
135 void calculateQ0();
137 void calculateQ1();
139 void calculateQ2();
140
141 double m_kp;
142 double m_ki;
143 double m_kd;
144 double m_sampleTime;
145 double m_q0;
146 double m_q1;
147 double m_q2;
148 double m_yMin;
149 double m_yMax;
150 double m_deltaMax;
151 double m_setpoint;
152 double m_yLast1;
153 double m_eLast1;
154 double m_eLast2;
155};
156} /* namespace semf */
157#endif /* SEMF_UTILS_PROCESSING_PIDCONTROLLER_H_ */
Implementation of an pid (proportional integral derivative) regulator.
Definition: pidcontroller.h:21
PidController(double kp, double ki, double kd, double sampleTime, double yMin, double yMax, double setpoint=0, double yStart=0, double deltaMax=DBL_MAX)
Constructor.
double maxOuput() const
Returns the maximum value which the output is allowed to have.
void setKd(double kd)
Set the gain of the derivative.
void setSetpoint(double setpoint)
Set the controller set point.
void reset(double yStart=0)
Resets the past sampled values which will be used for the calculation of the integral and derivative.
void setKp(double kp)
Set the proportional gain.
void setMinOutput(double min)
Set the minimum possible output.
virtual double calculate(double currentValue)
Calculates the output value dependent to the actual value. This method must be called cyclically at t...
void setKi(double ki)
Set the gain of the integral.
virtual ~PidController()=default
double ki() const
Get the gain of the integral.
void setSampleTime(double sampleTime)
Set the sample time of the controller.
double kp() const
Returns the proportional gain.
void setMaxDelta(double delta)
Set the max delta of the output between two samples.
void setMaxOutput(double max)
Limits the maximum value of the output.
double setpoint() const
Returns the current set point.
double kd() const
Returns the gain of the derivative.
double maxDelta() const
Returns Set the max delta of the output between two samples.
double sampleTime() const
Returns the current configured sample time.
double minOutput() const
Returns the minimum possible output.