Filters
1.0
LPF, HPF, BPF, BSF, SRL
Toggle main menu visibility
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
32
namespace
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
214
T
dx_dt_min
= 0;
215
226
T
dx_dt_max
= 0;
227
234
T
y_k_1
= 0;
235
243
bool
start
=
false
;
244
};
245
246
#include "
../../src/limiter/srl.tpp
"
247
}
// namespace limiter
248
249
}
// namespace filter
250
251
#endif
// FILTER_SRL
filter::limiter::SRL::dt
T dt
Sampling time of the limiter.
Definition
srl.h:202
filter::limiter::SRL::update
T update(T x_k)
Processes a new input sample.
Definition
srl.h:25
filter::limiter::SRL::start
bool start
Indicates whether the limiter has received its first sample.
Definition
srl.h:243
filter::limiter::SRL::set_dx_dt_min
void set_dx_dt_min(T dx_dt_min_)
Sets the minimum slew rate.
Definition
srl.h:68
filter::limiter::SRL::get_dt
T get_dt()
Gets the sampling time.
Definition
srl.h:80
filter::limiter::SRL::config
void config(T dt_, T dx_dt_min_, T dx_dt_max_)
Configures the slew-rate limiter.
Definition
srl.h:11
filter::limiter::SRL::get_dx_dt_max
T get_dx_dt_max()
Gets the maximum slew rate.
Definition
srl.h:92
filter::limiter::SRL::get_fs
T get_fs()
Gets the sampling frequency.
Definition
srl.h:98
filter::limiter::SRL::set_param
void set_param(T dt_, T dx_dt_min_, T dx_dt_max_)
Sets the limiter parameters.
Definition
srl.h:17
filter::limiter::SRL::set_dt
void set_dt(T dt_)
Sets the sampling time.
Definition
srl.h:62
filter::limiter::SRL::dx_dt_max
T dx_dt_max
Maximum allowed slew rate.
Definition
srl.h:226
filter::limiter::SRL::get_dx_dt_min
T get_dx_dt_min()
Gets the minimum slew rate.
Definition
srl.h:86
filter::limiter::SRL::y_k_1
T y_k_1
Previous output sample.
Definition
srl.h:234
filter::limiter::SRL::dx_dt_min
T dx_dt_min
Minimum allowed slew rate.
Definition
srl.h:214
filter::limiter::SRL::SRL
SRL()
Constructs a slew-rate limiter.
Definition
srl.h:5
filter::limiter::SRL::reset
void reset()
Resets the limiter state.
Definition
srl.h:55
filter::limiter::SRL::set_dx_dt_max
void set_dx_dt_max(T dx_dt_max_)
Sets the maximum slew rate.
Definition
srl.h:74
filter
Contains digital signal filtering algorithms.
Definition
bpf_2.h:38
limiter
Contains signal limiter implementations.
srl.tpp
include
limiter
srl.h
Generated by
1.17.0