Skip to content

Commit 8a3d561

Browse files
authored
Merge pull request #230 from SciML/fb/PI_docs
improve docstring and interface to PI controller
2 parents 0fbd414 + 84793a1 commit 8a3d561

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/Blocks/continuous.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,19 @@ Initial value of the state `x` can be set with `x`, and of derivative state `xd`
172172
end
173173

174174
"""
175-
PI(;name, gainPI.k = 1.0, T, int.x = 0.0)
175+
PI(;name, k = 1.0, T = 1.0, int.x = 0.0)
176176
177177
Textbook version of a PI-controller without actuator saturation and anti-windup measure.
178-
The proportional gain can be set with `gainPI.k`
178+
The proportional gain can be set with `k`
179179
Initial value of integrator state `x` can be set with `int.x`
180180
181-
# Parameters:
181+
The PI controller is implemented on standard form:
182+
```math
183+
U(s) = k (1 + \\dfrac{1}{sT}) E(S)
184+
```
182185
186+
# Parameters:
187+
- `k`: Proportional gain
183188
- `T`: [s] Integrator time constant (T>0 required)
184189
185190
# Connectors:
@@ -191,7 +196,8 @@ See also [`LimPI`](@ref)
191196
"""
192197
@mtkmodel PI begin
193198
@parameters begin
194-
T, [description = "Integrator time constant"]
199+
k = 1.0, [description = "Proportional gain"]
200+
T = 1.0, [description = "Integrator time constant"]
195201
end
196202
begin
197203
@symcheck T > 0 ||
@@ -200,7 +206,7 @@ See also [`LimPI`](@ref)
200206
@components begin
201207
err_input = RealInput() # control error
202208
ctr_output = RealOutput() # control signal
203-
gainPI = Gain(; k = 1.0)
209+
gainPI = Gain(; k)
204210
addPI = Add()
205211
int = Integrator(k = 1 / T, x = 0.0)
206212
end
@@ -294,6 +300,12 @@ end
294300
295301
Text-book version of a PI-controller with actuator saturation and anti-windup measure.
296302
303+
The PI controller is implemented on standard form
304+
```math
305+
u(t) = sat(k (e(t) + ∫\\dfrac{1}{T}e(t) dt) )
306+
```
307+
The simplified expression above is given without the anti-windup protection.
308+
297309
# Parameters:
298310
299311
- `k`: Proportional gain

test/Blocks/continuous.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ end
147147
@testset "PI" begin
148148
re_val = 2
149149
@named ref = Constant(; k = re_val)
150-
@named pi_controller = PI(int.k = 1, T = 1)
150+
@named pi_controller = PI(k = 1, T = 1)
151151
@named plant = Plant()
152152
@named fb = Feedback()
153153
@named model = ODESystem([

0 commit comments

Comments
 (0)