You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kp, Ki, Kd =convert_pidparams_to_parallel(param_p, param_i, param_d, form)
69
-
TE =Continuous()
70
70
if!isnothing(Tf)
71
71
if Ki !=0
72
72
A = [010; 001; 0-2/Tf^2-2/Tf]
@@ -88,11 +88,84 @@ function pid_ss(param_p, param_i, param_d=zero(typeof(param_p)); form=:standard,
88
88
returnss([Kp])
89
89
end
90
90
else
91
-
throw(DomainError("cannot create controller as a state space if Td != 0 without a filter. Either create the controller as a transfer function, pid(TransferFunction; params...), or supply Tf to create a filter."))
91
+
throw(DomainError("cannot create controller as a state space if Td != 0 without a filter. Either create the controller as a transfer function, pid(params..., state_space=false), or supply keyword argument Tf to add a filter."))
92
+
end
93
+
K =ss(A, B, C, D)
94
+
balance ?first(balance_statespace(K)) : K
95
+
end
96
+
97
+
"""
98
+
C = pid_2dof(param_p, param_i, [param_d]; form=:standard, state_space=true, N = 10, [Ts], b=1, c=0, disc=:tustin)
99
+
100
+
Calculates and returns a PID controller on 2DOF form with inputs `[r; y]` and outputs `u` where `r` is the reference signal, `y` is the measured output and `u` is the control signal.
101
+
102
+
Belowm we show two different depections of the contorller, one as a 2-input system (left) and one where the tw internal SISO systems of the controller are shown (right).
103
+
```
104
+
┌──────┐
105
+
r │ │
106
+
───►│ Cr ├────┐
107
+
r ┌─────┐ ┌─────┐ │ │ │ ┌─────┐
108
+
──►│ │ u │ │ y └──────┘ │ │ │ y
109
+
│ C ├────►│ P ├─┬─► +───►│ P ├─┬───►
110
+
┌►│ │ │ │ │ ┌──────┐ │ │ │ │
111
+
│ └─────┘ └─────┘ │ y │ │ │ └─────┘ │
112
+
│ │ ┌─►│ Cy ├────┘ │
113
+
└─────────────────────┘ │ │ │ │
114
+
│ └──────┘ │
115
+
│ │
116
+
└───────────────────────────┘
117
+
```
118
+
119
+
The `form` can be chosen as one of the following (determines how the arguments `param_p, param_i, param_d` are interpreted)
- `b` is a set-point weighting for the proportional term
124
+
- `c` is a set-point weighting for the derivative term, this defaults to 0.
125
+
- If both `b` and `c` are set to zero, the feedforward path of the controller will be strictly proper.
126
+
- `Tf` is a time constant for a filter on the derivative term, this defaults to `Td/N` where `N` is set to 10. Instead of passing `Tf` one can also pass `N` directly. The proportional term is not affected by this filter. **Please note**: this derivative filter is not the same as the one used in the `pid` function, where the filter is of second order and applied in series with the contorller, i.e., it affects all three PID terms.
127
+
- A PD controller is constructed by setting `param_i` to zero.
128
+
- A balanced state-space realization is returned, unless `balance = false`
129
+
- If `Ts` is supplied, the controller is discretized using the method `disc` (defaults to `:tustin`).
130
+
131
+
This controller has negative feedback built in, and the closed-loop system from `r` to `y` is thus formed as
132
+
```
133
+
Cr, Cy = C[1, 1], C[1, 2]
134
+
feedback(P, Cy, pos_feedback=true)*Cr # Alternative 1
0 commit comments