Filters 1.0
LPF, HPF, BPF, BSF, SRL
Loading...
Searching...
No Matches
srl.h
Go to the documentation of this file.
1
5 * @details
6 * This file defines the @ref filter::limiter::SRL class, which implements
7 * a discrete-time slew-rate limiter.
8 *
9 * A slew-rate limiter restricts how quickly an output signal can increase
10 * or decrease. It limits the rate of change of the output between two
11 * consecutive samples to a configurable minimum and maximum value.
12 *
13 * The limiter is useful for signal conditioning and for preventing
14 * commands from changing faster than a physical system can safely
15 * respond.
16 *
17 * The class is templated to support different numeric types such as
18 * @c float and @c double.
19 *
20 * @tparam T Numeric data type used for the limiter calculations.
21 *
22 * @author Abhinay Kumar
23 * @version 1.0.0
24 *
25 * @copyright
26 * Copyright (c) 2026 Abhinay Kumar
27 */
28
29#ifndef FILTER_SRL
30#define FILTER_SRL
31
32namespace filter
33{
38
39 namespace limiter
40 {
45
55 * maximum slew rates.
56 *
57 * The rate limits are specified in units of signal units per
58 * second.
59 *
60 * @tparam T Numeric data type used for the limiter.
61 *
62 * @par Example
63 * @code{.cpp}
64 * filter::limiter::SRL<double> limiter;
65 *
66 * limiter.config(
67 * 0.001, // Sampling time [s]
68 * -10.0, // Minimum slew rate [units/s]
69 * 10.0 // Maximum slew rate [units/s]
70 * );
71 *
72 * double output = limiter.update(input);
73 * @endcode
74 */
75 template <typename T>
76 class SRL
77 {
78 public:
80 * @brief Constructs a slew-rate limiter.
81 *
82 * @details
83 * Constructs the limiter with its parameters and internal
84 * state initialized to their default values.
85 */
86 SRL();
87
90
92 * @param[in] dx_dt_min_ Minimum allowed rate of change.
93 * @param[in] dx_dt_max_ Maximum allowed rate of change.
94 *
95 * @details
96 * Configures the sampling time and the minimum and maximum
97 * allowable rates of change of the output signal.
98 */
99 void config(T dt_, T dx_dt_min_, T dx_dt_max_);
100
102
112 void set_param(T dt_, T dx_dt_min_, T dx_dt_max_);
113
128 T update(T x_k);
129
136 void reset();
137
143 void set_dt(T dt_);
144
150 void set_dx_dt_min(T dx_dt_min_);
151
157 void set_dx_dt_max(T dx_dt_max_);
158
164 T get_dt();
165
171 T get_dx_dt_min();
172
178 T get_dx_dt_max();
179
193 T get_fs();
194
195 private:
202 T dt = 0;
203
215
227
234 T y_k_1 = 0;
235
243 bool start = false;
244 };
245
247 } // namespace limiter
248
249} // namespace filter
250
251#endif // FILTER_SRL
T dt
Sampling time of the limiter.
Definition srl.h:202
T update(T x_k)
Processes a new input sample.
Definition srl.h:25
bool start
Indicates whether the limiter has received its first sample.
Definition srl.h:243
void set_dx_dt_min(T dx_dt_min_)
Sets the minimum slew rate.
Definition srl.h:68
T get_dt()
Gets the sampling time.
Definition srl.h:80
void config(T dt_, T dx_dt_min_, T dx_dt_max_)
Configures the slew-rate limiter.
Definition srl.h:11
T get_dx_dt_max()
Gets the maximum slew rate.
Definition srl.h:92
T get_fs()
Gets the sampling frequency.
Definition srl.h:98
void set_param(T dt_, T dx_dt_min_, T dx_dt_max_)
Sets the limiter parameters.
Definition srl.h:17
void set_dt(T dt_)
Sets the sampling time.
Definition srl.h:62
T dx_dt_max
Maximum allowed slew rate.
Definition srl.h:226
T get_dx_dt_min()
Gets the minimum slew rate.
Definition srl.h:86
T y_k_1
Previous output sample.
Definition srl.h:234
T dx_dt_min
Minimum allowed slew rate.
Definition srl.h:214
SRL()
Constructs a slew-rate limiter.
Definition srl.h:5
void reset()
Resets the limiter state.
Definition srl.h:55
void set_dx_dt_max(T dx_dt_max_)
Sets the maximum slew rate.
Definition srl.h:74
Contains digital signal filtering algorithms.
Definition bpf_2.h:38
Contains signal limiter implementations.