libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
Pid.h
Go to the documentation of this file.
1
/* Copyright 2013-2019 Homegear GmbH
2
*
3
* libhomegear-base is free software: you can redistribute it and/or
4
* modify it under the terms of the GNU Lesser General Public License as
5
* published by the Free Software Foundation, either version 3 of the
6
* License, or (at your option) any later version.
7
*
8
* libhomegear-base is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
12
*
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with libhomegear-base. If not, see
15
* <http://www.gnu.org/licenses/>.
16
*
17
* In addition, as a special exception, the copyright holders give
18
* permission to link the code of portions of this program with the
19
* OpenSSL library under certain conditions as described in each
20
* individual source file, and distribute linked combinations
21
* including the two.
22
* You must obey the GNU Lesser General Public License in all respects
23
* for all of the code used other than OpenSSL. If you modify
24
* file(s) with this exception, you may extend this exception to your
25
* version of the file(s), but you are not obligated to do so. If you
26
* do not wish to do so, delete this exception statement from your
27
* version. If you delete this exception statement from all source
28
* files in the program, then also delete it here.
29
*/
30
31
#ifndef _PID_H_
32
#define _PID_H_
33
34
namespace
BaseLib
35
{
36
37
class
Pid
38
{
39
private
:
40
double
_dt;
41
double
_pMax;
42
double
_pMin;
43
double
_oMax;
44
double
_oMin;
45
double
_Kp;
46
double
_Ki;
47
double
_Kd;
48
double
_previousError;
49
double
_integral;
50
51
double
clamp(
double
value
,
double
min,
double
max);
52
double
scale(
double
value,
double
valueMin,
double
valueMax,
double
scaleMin,
double
scaleMax);
53
public
:
54
// Kp - proportional gain
55
// Ki - Integral gain
56
// Kd - derivative gain
57
// dt - loop interval time
58
// pMax - maximum value of process variable
59
// pMin - minimum value of process variable
60
// oMax - maximum value of output variable
61
// oMin - minimum value of output variable
62
Pid
(
double
dt,
double
pMax,
double
pMin,
double
oMax,
double
oMin,
double
Kp,
double
Ki,
double
Kd);
63
64
// Returns the manipulated variable given a setpoint and current process value
65
double
calculate
(
double
setpoint,
double
processVariable);
66
virtual
~Pid
();
67
};
68
69
}
70
71
#endif
BaseLib
Definition:
BaseLib.cpp:34
BaseLib::Pid::~Pid
virtual ~Pid()
Definition:
Pid.cpp:101
BaseLib::Pid::calculate
double calculate(double setpoint, double processVariable)
Definition:
Pid.cpp:66
value
PVariable value
Definition:
UiElements.h:217
BaseLib::Pid
Definition:
Pid.h:37
BaseLib::Pid::Pid
Pid(double dt, double pMax, double pMin, double oMax, double oMin, double Kp, double Ki, double Kd)
Definition:
Pid.cpp:37
HelperFunctions
Pid.h
Generated on Tue Nov 22 2022 10:45:31 for libhomegear-base by
1.8.12