PID Control
1.0
Discrete time implementation of P, PI, PD, PID. Including derivative filter, integral clamping, feed-forward, gain scheduling in standard and parallel form.
Toggle main menu visibility
Loading...
Searching...
No Matches
p.h
Go to the documentation of this file.
1
5
* @details
6
* This file defines the @ref control_system::proportional::P class,
7
* which implements a proportional controller.
8
*
9
* The controller generates an output proportional to the difference
10
* between the reference input and the measured or current value.
11
*
12
* The controller output is limited by the configured maximum output
13
* value.
14
*
15
* The class is templated to support different numeric types such as
16
* @c float and @c double.
17
*
18
* @tparam T Numeric data type used for the controller calculations.
19
*
20
* @author Abhinay Kumar
21
* @version 1.0.0
22
* @date 2026-08-11
23
*
24
* @copyright
25
* Copyright (c) 2026 Abhinay Kumar
26
*/
27
28
#ifndef CONTROL_SYSTEM_PROPORTIONAL_P_H
29
#define CONTROL_SYSTEM_PROPORTIONAL_P_H
30
31
#include "
../utility/utility.h
"
32
33
namespace
control_system
34
{
35
/**
36
* @namespace control_system
37
* @brief Contains control-system algorithms and controllers.
38
*/
39
40
namespace
proportional
41
{
45
46
47
/**
48
* @class P
49
* @brief Proportional controller.
50
*
51
* @details
52
* The P class implements a proportional controller in which the
53
* control output is proportional to the control error.
54
*
55
* The controller uses a configurable proportional gain and
56
* maximum output limit.
57
*
58
* @tparam T Numeric data type used for the controller.
59
*
60
* @par Example
61
* @code{.cpp}
62
* control_system::proportional::P<double> controller;
63
*
64
* controller.init(2.0, 100.0);
65
*
66
* double output = controller.update(reference, measurement);
67
* @endcode
68
*/
69
template
<
typename
T>
70
class
P
71
{
72
public
:
80
P
();
81
91
void
init
(T Kp_, T u_max_);
92
102
void
set_param
(T Kp_, T u_max_);
103
113
T
update
(T x_0, T x);
114
121
void
reset
();
122
128
void
set_Kp
(T Kp_);
129
135
void
set_u_max
(T u_max_);
136
142
T
get_Kp
();
143
149
T
get_u_max
();
150
151
private
:
155
T
Kp
= 0.0;
156
164
T
u_max
= 9999999999;
165
};
166
167
#include "
../../src/proportional/p.tpp
"
168
}
169
}
170
171
#endif
control_system::proportional::P::init
void init(T Kp_, T u_max_)
Initializes the proportional controller.
Definition
p.h:11
control_system::proportional::P::u_max
T u_max
Maximum controller output.
Definition
p.h:164
control_system::proportional::P::P
P()
Constructs a proportional controller.
Definition
p.h:5
control_system::proportional::P::Kp
T Kp
Proportional gain.
Definition
p.h:155
control_system::proportional::P::set_u_max
void set_u_max(T u_max_)
Sets the maximum controller output.
Definition
p.h:41
control_system::proportional::P::update
T update(T x_0, T x)
Computes the proportional control output.
Definition
p.h:24
control_system::proportional::P::get_Kp
T get_Kp()
Gets the proportional gain.
Definition
p.h:47
control_system::proportional::P::set_param
void set_param(T Kp_, T u_max_)
Sets the controller parameters.
Definition
p.h:17
control_system::proportional::P::get_u_max
T get_u_max()
Gets the maximum controller output.
Definition
p.h:53
control_system::proportional::P::reset
void reset()
Resets the controller.
Definition
p.h:30
control_system::proportional::P::set_Kp
void set_Kp(T Kp_)
Sets the proportional gain.
Definition
p.h:35
control_system
Contains control-system algorithms and controllers.
Definition
d.h:32
proportional
Contains proportional control implementations.
p.tpp
utility.h
Utility functions for the Control System library.
include
proportional
p.h
Generated by
1.17.0