Skip to content

Commit c56daf0

Browse files
committed
fix Td definition in LimPID
1 parent 610b936 commit c56daf0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Blocks/continuous.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Proportional-Integral-Derivative (PID) controller with output saturation, set-po
318318
The equation for the control signal is roughly
319319
320320
```
321-
k(ep + 1/Ti * ∫e + 1/Td * d/dt(ed))
321+
k(ep + 1/Ti * ∫e + Td * d/dt(ed))
322322
e = u_r - u_y
323323
ep = wp*u_r - u_y
324324
ed = wd*u_r - u_y
@@ -389,7 +389,7 @@ function LimPID(; name, k = 1, Ti = false, Td = false, wp = 1, wd = 1,
389389
@named Izero = Constant(k = 0)
390390
end
391391
if with_D
392-
@named der = Derivative(k = 1 / Td, T = 1 / Nd, x_start = xd_start)
392+
@named der = Derivative(k = Td, T = 1 / Nd, x_start = xd_start)
393393
@named addD = Add(k1 = wd, k2 = -1)
394394
else
395395
@named Dzero = Constant(k = 0)

test/Blocks/continuous.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)