1
1
"""
2
2
Integrator(;name, k = 1, x = 0.0)
3
3
4
- Outputs `y = ∫k*u dt`, corresponding to the transfer function `1/s`.
5
- Initial value of integrator state `x ` can be set with `x`
4
+ Outputs `y = ∫k*u dt`, corresponding to the transfer function `` 1/s` `.
5
+ Initial value of integrator state ``x` ` can be set with `x`
6
6
7
7
# Connectors:
8
8
@@ -19,7 +19,7 @@ Initial value of integrator state `x` can be set with `x`
19
19
x (t) = 0.0 , [description = " State of Integrator" ]
20
20
end
21
21
@parameters begin
22
- k = 1 , [description = " Gain of Integrator " ]
22
+ k = 1 , [description = " Gain" ]
23
23
end
24
24
@equations begin
25
25
D (x) ~ k * u
30
30
Derivative(; name, k = 1, T, x = 0.0)
31
31
32
32
Outputs an approximate derivative of the input. The transfer function of this block is
33
- Initial value of the state `x ` can be set with `x`
33
+ Initial value of the state ``x` ` can be set with `x`
34
34
35
35
```
36
36
k k
@@ -57,11 +57,11 @@ A smaller `T` leads to a more ideal approximation of the derivative.
57
57
@mtkmodel Derivative begin
58
58
@extend u, y = siso = SISO ()
59
59
@variables begin
60
- x (t) = 0.0 , [description = " State of Derivative" ]
60
+ x (t) = 0.0 , [description = " Derivative-filter state " ]
61
61
end
62
62
@parameters begin
63
- T = T, [description = " Time constant of Derivative " ]
64
- k = 1 , [description = " Gain of Derivative " ]
63
+ T = T, [description = " Time constant" ]
64
+ k = 1 , [description = " Gain" ]
65
65
end
66
66
begin
67
67
@symcheck T > 0 ||
77
77
FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)
78
78
79
79
A first-order filter with a single real pole in `s = -T` and gain `k`. If `lowpass=true` (default), the transfer function
80
- is given by `Y(s)/U(s) = `
81
- Initial value of the state `x` can be set with `x`
80
+ is given by `` Y(s)/U(s) = ` `
81
+
82
82
83
83
```
84
84
k
@@ -94,10 +94,12 @@ sT + 1 - k
94
94
sT + 1
95
95
```
96
96
97
+ Initial value of the state `x` can be set with `x`
98
+
97
99
# Parameters:
98
100
99
101
- `k`: Gain
100
- - `T`: [s] Time constants (T>0 required)
102
+ - `T`: [s] Time constant (T>0 required)
101
103
102
104
# Connectors:
103
105
@@ -108,26 +110,28 @@ See also [`SecondOrder`](@ref)
108
110
"""
109
111
@mtkmodel FirstOrder begin
110
112
@extend u, y = siso = SISO ()
113
+ @structural_parameters begin
114
+ lowpass = true
115
+ end
111
116
@variables begin
112
117
x (t) = 0.0 , [description = " State of FirstOrder filter" ]
113
118
end
114
119
@parameters begin
115
- lowpass = true
116
- T = T, [description = " Time constant of FirstOrder filter" ]
117
- k = 1.0 , [description = " Gain of FirstOrder" ]
120
+ T = T, [description = " Time constant" ]
121
+ k = 1.0 , [description = " Gain" ]
118
122
end
119
123
begin
120
124
@symcheck T > 0 ||
121
125
throw (ArgumentError (" Time constant `T` has to be strictly positive" ))
122
126
end
123
127
@equations begin
124
128
D (x) ~ (k * u - x) / T
125
- getdefault ( lowpass) ? y ~ x : y ~ k * u - x
129
+ lowpass ? y ~ x : y ~ k * u - x
126
130
end
127
131
end
128
132
129
133
"""
130
- SecondOrder(; name, k = 1.0, w, d, x = 0.0, xd = 0.0)
134
+ SecondOrder(; name, k = 1.0, w = 1.0 , d = 1.0 , x = 0.0, xd = 0.0)
131
135
132
136
A second-order filter with gain `k`, a bandwidth of `w` rad/s and relative damping `d`. The transfer function
133
137
is given by `Y(s)/U(s) = `
@@ -160,9 +164,9 @@ Initial value of the state `x` can be set with `x`, and of derivative state `xd`
160
164
xd (t) = 0.0 , [description = " Derivative state of SecondOrder filter" ]
161
165
end
162
166
@parameters begin
163
- k = 1.0 , [description = " Gain of SecondOrder " ]
164
- w, [description = " Bandwidth of SecondOrder " ]
165
- d, [description = " Relative damping of SecondOrder " ]
167
+ k = 1.0 , [description = " Gain" ]
168
+ w = 1.0 , [description = " Bandwidth (angular frequency) " ]
169
+ d = 1.0 , [description = " Relative damping" ]
166
170
end
167
171
@equations begin
168
172
D (x) ~ xd
0 commit comments