Skip to content

Commit

Permalink
Merge pull request #5 from CasBex/AntiWindupP-PD
Browse files Browse the repository at this point in the history
Anti windup p pd
  • Loading branch information
baggepinnen committed Jun 29, 2023
2 parents 88db5cd + 211ac8b commit bafb150
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/DiscretePIDs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ function DiscretePID(;
0 b 1 || throw(ArgumentError("b must be ∈ [0, 1]"))
umax > umin || throw(ArgumentError("umax must be greater than umin"))

ar = Ts / Tt
if Ti > 0
ar = Ts / Tt
else
ar = zero(Ts / Tt)
end
ad = Td / (Td + N * Ts)
bd = K * N * ad

Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ res2 = lsim(P, ctrl, 3)

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


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

end
end

0 comments on commit bafb150

Please sign in to comment.