Skip to content

Commit 1e267db

Browse files
authored
Merge pull request #152 from SciML/fb/pid_Td
fix `Td` definition in LimPID
2 parents 8464576 + 9372faf commit 1e267db

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Blocks/continuous.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ See also [`LimPID`](@ref)
229229
@named Izero = Constant(k = 0)
230230
end
231231
if with_D
232-
@named der = Derivative(k = 1 / Td, T = 1 / Nd, x_start = xd_start)
232+
@named der = Derivative(k = Td, T = 1 / Nd, x_start = xd_start)
233233
else
234234
@named Dzero = Constant(k = 0)
235235
end
@@ -319,7 +319,7 @@ Proportional-Integral-Derivative (PID) controller with output saturation, set-po
319319
The equation for the control signal is roughly
320320
321321
```
322-
k(ep + 1/Ti * ∫e + 1/Td * d/dt(ed))
322+
k(ep + 1/Ti * ∫e + Td * d/dt(ed))
323323
e = u_r - u_y
324324
ep = wp*u_r - u_y
325325
ed = wd*u_r - u_y
@@ -390,7 +390,7 @@ where the transfer function for the derivative includes additional filtering, se
390390
@named Izero = Constant(k = 0)
391391
end
392392
if with_D
393-
@named der = Derivative(k = 1 / Td, T = 1 / Nd, x_start = xd_start)
393+
@named der = Derivative(k = Td, T = 1 / Nd, x_start = xd_start)
394394
@named addD = Add(k1 = wd, k2 = -1)
395395
else
396396
@named Dzero = Constant(k = 0)

test/Blocks/continuous.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ end
169169
@testset "PID" begin
170170
re_val = 2
171171
@named ref = Constant(; k = re_val)
172-
@named pid_controller = PID(k = 3, Ti = 0.5, Td = 100)
172+
@named pid_controller = PID(k = 3, Ti = 0.5, Td = 1 / 100)
173173
@named plant = Plant()
174174
@named fb = Feedback()
175175
@named model = ODESystem([
@@ -280,7 +280,7 @@ end
280280
@testset "LimPID" begin
281281
re_val = 1
282282
@named ref = Constant(; k = re_val)
283-
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 100, u_max = 1.5, u_min = -1.5,
283+
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5, u_min = -1.5,
284284
Ni = 0.1 / 0.5)
285285
@named plant = Plant()
286286
@named model = ODESystem([
@@ -342,7 +342,7 @@ end
342342
end
343343
@testset "set-point weights" begin
344344
@testset "wp" begin
345-
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 100, u_max = 1.5,
345+
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5,
346346
u_min = -1.5, Ni = 0.1 / 0.5, wp = 0, wd = 1)
347347
@named model = ODESystem([
348348
connect(ref.output, pid_controller.reference),
@@ -363,7 +363,7 @@ end
363363
@test all(-1.5 .<= sol[pid_controller.ctr_output.u] .<= 1.5) # test limit
364364
end
365365
@testset "wd" begin
366-
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 100, u_max = 1.5,
366+
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5,
367367
u_min = -1.5, Ni = 0.1 / 0.5, wp = 1, wd = 0)
368368
@named model = ODESystem([
369369
connect(ref.output, pid_controller.reference),

0 commit comments

Comments
 (0)