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
Copy file name to clipboardExpand all lines: docs/src/examples/delay_systems.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,4 +32,7 @@ For a more advanced example using time delays, see the [Smith predictor](@ref) t
32
32
Time-delay systems are numerically challenging to simulate, if you run into problems, please open an issue with a reproducing example. The [`lsim`](@ref), [`step`](@ref) and [`impulse`](@ref) functions accept keyword arguments that are passed along to the ODE integrator, this can be used to both select integration method and to tweak the integrator options. The documentation for solving delay-differential equations is available [here](https://diffeq.sciml.ai/latest/types/dde_types/) and [here](https://diffeq.sciml.ai/latest/tutorials/dde_example/).
33
33
34
34
## Estimation of delay
35
-
See the companion tutorial in ControlSystemIdentification.jl on [Delay estimation](file:///home/fredrikb/.julia/dev/ControlSystemIdentification/docs/build/examples/delayest.html). This tutorial covers the both the detection of the presence of a delay, and estimation of models for systems with delays.
35
+
See the companion tutorial in ControlSystemIdentification.jl on [Delay estimation](file:///home/fredrikb/.julia/dev/ControlSystemIdentification/docs/build/examples/delayest.html). This tutorial covers the both the detection of the presence of a delay, and estimation of models for systems with delays.
36
+
37
+
## Approximation and discretization of delays
38
+
Delay systems may be approximated as rational functions by means of [Padé approximation](https://en.wikipedia.org/wiki/Pad%C3%A9_approximant) using the function [`pade`](@ref). Pure continuous-time delays can also be discretized using the function [`thiran`](@ref). Continuous-time models with internal delays can be discretized using [`c2d`](@ref), provided that the delay is an integer multiple of the sampling time (fractional delays are not yet supported by [`c2d`](@ref)).
Copy file name to clipboardExpand all lines: docs/src/examples/zoh.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ Next, we discretize this system using the standard [`c2d`](@ref) function, which
16
16
```math
17
17
Z(s) = \dfrac{1 - e^{-T_s s}}{s}
18
18
```
19
+
[^CCS]: Åström, K. J., & Wittenmark, B. (1997). Computer-Controlled Systems: Theory and Design.
19
20
20
21
```@example zoh
21
22
Ts = 1 # Sample interval
@@ -113,7 +114,7 @@ The discrete-time controller ``C(z)`` is a basic PI controller
113
114
Ts = 1
114
115
C = pid(0.01,10; Ts, Tf = 1/100, state_space=true)
115
116
```
116
-
If we choose option 1. in this case, we get a discretized plant that has a very poor frequency-response fit to the original continuous-time plant, making frequency-domain analysis difficult
117
+
If we choose option 1, we get a discretized plant that has a very poor frequency-response fit to the original continuous-time plant, making frequency-domain analysis difficult
The continuous-time analysis eventually settles at a periodic output that matches the amplitude predicted by the continuous-time frequency response. However, the discrete-time simulation yields, as expected, a very poor result. Noticeable in the simulation is the appearance of a beat frequency, which is expected due to the modulation introduced by sampling.[^CCS]
150
+
The continuous-time analysis eventually settles at a periodic output that matches the amplitude predicted by the continuous-time frequency response. However, the discrete-time simulation yields, as expected, a very poor result. Noticeable in the simulation is the appearance of a beat frequency, which is expected due to the modulation introduced by sampling.[^CCS]
150
151
151
152
## Caveats
152
153
- The exact output of the system that was translated from discrete to continuous time is not going to be accurate, so transient properties of the hybrid system cannot be accurately assessed using this kind of analysis.
153
-
- Interpretation of frequency-responses for sampled-data systems must be done with care. The modulation introduced by sampling implies the creating of additional frequencies in the output. For an input with frequency ``\omega``, the output will contain all frequencies ``\omega ± \omega_s k`` where ``\omega_s`` is the sampling frequency and ``k`` is an integer.[^CCS]
154
+
- Interpretation of frequency-responses for sampled-data systems must be done with care. The modulation introduced by sampling implies the creating of additional frequencies in the output. For an input with frequency ``\omega``, the output will contain all frequencies ``\omega ± \omega_s k`` where ``\omega_s`` is the sampling frequency and ``k`` is an integer.[^CCS]
154
155
155
156
## References
156
157
Learn more about sampled-data systems and zero-order hold sampling in chapter 7 of the reference below.
157
-
[^CCS]: Åström, K. J., & Wittenmark, B. (1997). Computer-Controlled Systems: Theory and Design.
Copy file name to clipboardExpand all lines: docs/src/man/creating_systems.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,6 +123,12 @@ Sample Time: 0.1 (seconds)
123
123
Discrete-time transfer function model
124
124
```
125
125
126
+
127
+
## Converting between continuous and discrete time
128
+
A continuous-time system represents differential equations or a transfer function in the [Laplace domain](https://en.wikipedia.org/wiki/Laplace_transform), while a discrete-time system represents difference equations or a transfer function in the [Z-domain](https://en.wikipedia.org/wiki/Z-transform).
129
+
130
+
The functions [`c2d`](@ref) and [`d2c`](@ref) implement sampling/discretization of continuous-time systems and the inverse mapping from discrete-time to continuous-time systems.
131
+
126
132
## Delay Systems
127
133
The constructor [`delay`](@ref) creates a pure delay, which may be connected to a system by multiplication:
128
134
```julia
@@ -138,7 +144,7 @@ L = 1.2 # Delay time
138
144
tf(1, [1, 1]) *exp(-L*s)
139
145
```
140
146
141
-
Padé approximations of delays can be created using [`pade`](@ref).
147
+
Padé approximations of delays can be created using [`pade`](@ref). Models with delays can be discretized using [`c2d`](@ref), currently, only delays that are integer multiples of the sample time are supported. Pure fractional delays can be approximately discretized using the function [`thiran`](@ref).
Compute the `N`th order Padé approximation of a time-delay of length `τ`.
132
+
133
+
See also [`thiran`](@ref) for discretization of delays.
131
134
"""
132
135
functionpade(τ::Real, N::Int)
133
136
if!(1<= N <=10); error("Order of Padé approximation must be between 1 and 10. Got $N."); end
@@ -149,3 +152,25 @@ function pade(G::DelayLtiSystem, N)
149
152
X =append(ss(pade(τ,N)) for τ in G.Tau) # Perhaps append should be renamed blockdiag
150
153
returnlft(G.P.P, X)
151
154
end
155
+
156
+
"""
157
+
thiran(τ::Real, Ts)
158
+
159
+
Discretize a potentially fractional delay ``τ`` as a Thiran all-pass filter with sample time `Ts`.
160
+
161
+
The Thiran all-pass filter gives an a maximally flat group delay.
162
+
163
+
If ``τ`` is an integer multiple of ``Ts``, the Thiran all-pass filter reduces to ``z^{-τ/Ts}``.
164
+
165
+
Ref: T. I. Laakso, V. Valimaki, M. Karjalainen and U. K. Laine, "Splitting the unit delay [FIR/all pass filters design]," in IEEE Signal Processing Magazine, vol. 13, no. 1, 1996.
166
+
"""
167
+
functionthiran(τ::Real, Ts)
168
+
D = τ/Ts
169
+
N =ceil(Int, D)
170
+
a =ones(N+1)
171
+
for k =1:N
172
+
P =prod((D-N+n) / (D-N+n+k) for n in0:N)
173
+
a[k+1] = (-1)^k *binomial(N, k) * P # Eq 86 in reference
0 commit comments