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.
Loading...
Searching...
No Matches
i.h
Go to the documentation of this file.
1
5 * @details
6 * This file defines the @ref control_system::integral::I class, which
7 * implements a discrete-time integral controller.
8 *
9 * The controller generates a control output by integrating the error
10 * between a reference value and the measured or current value over
11 * time.
12 *
13 * The controller maintains the previous output as internal state and
14 * applies a configurable maximum output limit.
15 *
16 * @tparam T Numeric data type used for the controller calculations.
17 *
18 * @author Abhinay Kumar
19 * @version 1.0.0
20 * @date 2026-08-11
21 *
22 * @copyright
23 * Copyright (c) 2026 Abhinay Kumar
24 */
25
26#ifndef CONTROL_SYSTEM_INTEGRAL_I_H
27#define CONTROL_SYSTEM_INTEGRAL_I_H
29#include "../utility/utility.h"
30
31namespace control_system
32{
36
37
38 namespace integral
39 {
48
50 * The I class implements a discrete-time integral controller
51 * using a configurable integral gain and sampling time.
52 *
53 * The controller maintains its previous output as internal state
54 * and applies a configurable maximum output limit.
55 *
56 * @tparam T Numeric data type used for the controller.
57 *
58 * @par Example
59 * @code{.cpp}
60 * control_system::integral::I<double> controller;
61 *
62 * controller.init(
63 * 0.001,
64 * Ki,
65 * 0.0,
66 * 100.0
67 * );
68 *
69 * double output = controller.update(reference, measurement);
70 * @endcode
71 */
72 template <typename T>
73 class I
74 {
75 public:
78
80 * Constructs the controller with its parameters and internal
81 * state initialized to their default values.
82 */
83 I();
84
86 * @brief Initializes the integral controller.
87 *
88 * @param[in] dt_ Controller sampling time in seconds.
89 * @param[in] Ki_ Integral gain.
90 * @param[in] u_k_1_ Previous controller output.
91 * @param[in] u_max_ Maximum allowed controller output.
92 *
93 * @details
94 * Initializes the controller sampling time, integral gain,
95 * previous controller output, and output limit.
96 */
97 void init(T dt_, T Ki_, T u_k_1_, T u_max_);
98
111 void set_param(T dt_, T Ki_, T u_k_1_, T u_max_);
112
127 T update(T x_0, T x);
128
135 void reset();
136
147 void merge(T u_k_1_);
148
154 void set_dt(T dt_);
155
161 void set_Ki(T Ki_);
162
168 void set_u_0(T u_k_1_);
169
175 void set_u_max(T u_max_);
176
182 T get_dt();
183
189 T get_Ki();
190
196 T get_u_k_1();
197
203 T get_u_max();
204
205 private:
213 T dt = 0.0;
214
221 T u_k_1 = 0.0;
222
226 T Ki = 0.0;
227
235 T u_max = 9999999999;
236 };
237
239 }
240}
241
242#endif
void set_u_0(T u_k_1_)
Sets the previous controller output.
Definition i.h:62
void init(T dt_, T Ki_, T u_k_1_, T u_max_)
Initializes the integral controller.
Definition i.h:13
I()
Constructs an integral controller.
Definition i.h:5
void set_u_max(T u_max_)
Sets the maximum controller output.
Definition i.h:68
T update(T x_0, T x)
Computes the integral control output.
Definition i.h:28
void set_dt(T dt_)
Sets the controller sampling time.
Definition i.h:50
T get_dt()
Gets the controller sampling time.
Definition i.h:74
void set_Ki(T Ki_)
Sets the integral gain.
Definition i.h:56
T get_u_max()
Gets the maximum controller output.
Definition i.h:92
T get_u_k_1()
Gets the previous controller output.
Definition i.h:86
T dt
Controller sampling time.
Definition i.h:213
T u_max
Maximum controller output.
Definition i.h:235
T get_Ki()
Gets the integral gain.
Definition i.h:80
void merge(T u_k_1_)
Merges an external controller output into the integral state.
Definition i.h:44
void reset()
Resets the integral controller state.
Definition i.h:38
T u_k_1
Previous controller output.
Definition i.h:221
void set_param(T dt_, T Ki_, T u_k_1_, T u_max_)
Sets the integral controller parameters.
Definition i.h:19
T Ki
Integral gain.
Definition i.h:226
Contains control-system algorithms and controllers.
Definition d.h:32
Contains integral controller implementations.
Utility functions for the Control System library.