@@ -234,9 +234,9 @@ Text-book version of a PID-controller without actuator saturation and anti-windu
234
234
235
235
See also [`LimPID`](@ref)
236
236
"""
237
- @component function PID (with_I = true , with_D = true ; name, k = 1 , Ti = 0.1 , Td = 0.1 , Nd = 10 , int__x = 0 ,
237
+ @component function PID (with_I = true , with_D = true ; name, k = 1 , Ti = 0.1 , Td = 0.1 ,
238
+ Nd = 10 , int__x = 0 ,
238
239
der__x = 0 )
239
-
240
240
pars = @parameters begin
241
241
k = k
242
242
Ti = Ti
@@ -250,24 +250,26 @@ See also [`LimPID`](@ref)
250
250
@named ctr_output = RealOutput () # control signal
251
251
252
252
with_I &&
253
- (@symcheck Ti ≥ 0 || throw (ArgumentError (" Ti out of bounds, got $(Ti) but expected Ti ≥ 0" )))
253
+ (@symcheck Ti ≥ 0 ||
254
+ throw (ArgumentError (" Ti out of bounds, got $(Ti) but expected Ti ≥ 0" )))
254
255
with_D &&
255
- (@symcheck Td ≥ 0 || throw (ArgumentError (" Td out of bounds, got $(Td) but expected Td ≥ 0" )))
256
+ (@symcheck Td ≥ 0 ||
257
+ throw (ArgumentError (" Td out of bounds, got $(Td) but expected Td ≥ 0" )))
256
258
257
259
@symcheck Nd > 0 ||
258
- throw (ArgumentError (" Nd out of bounds, got $(Nd) but expected Nd ≥ 0" ))
260
+ throw (ArgumentError (" Nd out of bounds, got $(Nd) but expected Nd ≥ 0" ))
259
261
260
262
@named gainPID = Gain (; k)
261
263
@named addPID = Add3 ()
262
264
if with_I
263
- @named int = Integrator (;k = 1 / Ti, x = int__x)
265
+ @named int = Integrator (; k = 1 / Ti, x = int__x)
264
266
else
265
- @named Izero = Constant (;k = 0 )
267
+ @named Izero = Constant (; k = 0 )
266
268
end
267
269
if with_D
268
- @named der = Derivative (;k = Td, T = 1 / Nd, x = der__x)
270
+ @named der = Derivative (; k = Td, T = 1 / Nd, x = der__x)
269
271
else
270
- @named Dzero = Constant (;k = 0 )
272
+ @named Dzero = Constant (; k = 0 )
271
273
end
272
274
sys = [err_input, ctr_output, gainPID, addPID]
273
275
if with_I
303
305
with_I (type:: Union{AbstractString, Symbol} ) = contains (lowercase (string (type)), " i" )
304
306
with_D (type:: Union{AbstractString, Symbol} ) = contains (lowercase (string (type)), " d" )
305
307
306
- PID (type:: Union{AbstractString, Symbol} ; kwargs ... ) = PID ( with_I (type), with_D (type) ; kwargs... )
307
-
308
-
308
+ function PID (type:: Union{AbstractString, Symbol} ; kwargs... )
309
+ PID ( with_I (type), with_D (type); kwargs ... )
310
+ end
309
311
310
312
"""
311
313
LimPI(; name, k = 1.0, T, Ta, int__x = 0.0, u_max = 1.0, u_min = -u_max)
0 commit comments