Skip to content

Commit bafb150

Browse files
authored
Merge pull request #5 from CasBex/AntiWindupP-PD
Anti windup p pd
2 parents 88db5cd + 211ac8b commit bafb150

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/DiscretePIDs.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ function DiscretePID(;
7575
0 b 1 || throw(ArgumentError("b must be ∈ [0, 1]"))
7676
umax > umin || throw(ArgumentError("umax must be greater than umin"))
7777

78-
ar = Ts / Tt
78+
if Ti > 0
79+
ar = Ts / Tt
80+
else
81+
ar = zero(Ts / Tt)
82+
end
7983
ad = Td / (Td + N * Ts)
8084
bd = K * N * ad
8185

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ res2 = lsim(P, ctrl, 3)
134134

135135
# plot([res, res2], plotu=true)
136136
@test maximum(res2.u) == umax
137+
@test pid.I == 0.0
137138

138139

139140
@test DiscretePID(Ts=1f0) isa DiscretePID{Float32}
140141
@test DiscretePID(Ts=1.0) isa DiscretePID{Float64}
141142

142-
end
143+
end

0 commit comments

Comments
 (0)