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/zoh.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
-
# Analysis of hybrid continuous-discrete systems
2
-
In this example, we analyze the effect of ZoH sampling in continuous time and compare it to the equivalent discrete-time system
1
+
# Analysis of sampled-data systems
2
+
A sampled-data system contains both continuous-tiem and discrete-time components, such as a continuous-time plant and a discrete-time controller. In this example, we will look at how to analyze such systems using the ControlSystems.jl package. To learn more about the theory of sampled-data systems, consult the reference mentioned at the end of this page.
3
+
4
+
First, we analyze the effect of ZoH sampling in continuous time and compare it to the equivalent discrete-time system
3
5
4
6
We will consider a simple second-order system ``P``, which we define in continuous time:
5
7
```@example zoh
@@ -10,7 +12,7 @@ P = tf(0.1, [1, 0.1, 0.1])
10
12
11
13
## Continuous to discrete
12
14
13
-
Next, we discretize this system using the standard [`c2d`](@ref) function, which uses ZoH sampling by default. We compare the frequency response of the discretized system with the frequency response of the original continuous-time system multiplied by the transfer function of the ZoH operator
15
+
Next, we discretize this system using the standard [`c2d`](@ref) function, which uses ZoH sampling by default. We compare the frequency response of the discretized system with the frequency response of the original continuous-time system multiplied by the transfer function of the ZoH operator[^CCS]
14
16
```math
15
17
Z(s) = \dfrac{1 - e^{-T_s s}}{s}
16
18
```
@@ -56,7 +58,7 @@ With a _continuous_ input signal, the result is different,
56
58
after the initial transient, the output of `Pz` matches that of `Pd` exactly
57
59
(try plotting with the plotly() backend and zoom in at the end)
Discrete-time systems can be converted to continuous-time systems formulated with delay terms in such a way that the frequency-response of the two systems match exactly, using the substiturion``z^{-1} = e^{-sT_s}``. To this end, the function [`d2d_exact`](@ref) is used. This is useful when analyzing hybrid systems with both continuous-time and discrete-time components and accurate frequency-domain calculations are required over the entire frequency range up to the Nyquist frequency.
72
+
Discrete-time systems can be converted to continuous-time systems formulated with delay terms in such a way that the frequency-response of the two systems match exactly, using the substitution``z^{-1} = e^{-sT_s}``. To this end, the function [`d2c_exact`](@ref) is used. This is useful when analyzing hybrid systems with both continuous-time and discrete-time components and accurate frequency-domain calculations are required over the entire frequency range up to the Nyquist frequency.
71
73
72
74
Below, we compare the frequency response of a discrete-time system with delays to
73
75
two continuous-time systems, one translated using the exact method and one using the standard `d2c` method with inverse ZoH sampling.
If we instead make use of the second method above, exactly translating the discrete-time controller to continuous time, we can more easily determine that the closed-loop system will be stable by inspecting the Bode plot
126
+
If we instead make use of the second method above, exactly translating the discrete-time controller to continuous time, we can more easily determine that the closed-loop system will be stable by inspecting the Bode plot. Here, we show the Bode plot of ``P`` and that of the loop-transfer function, including the ZoH operator, ``P(s)Z(s)C(s)``.
we can simulate the response to a continuous-time input disturbance that contains frequencies higher than the Nyquist frequency of the discrete-time system, we do this below. We also try doing this with the discretized plant, which yields a very poor result
138
140
```@example zoh
139
-
PS = feedback(P, Cc) # Use the continuous-time plant and continuous translation of the controller
141
+
PS = feedback(P, Z*Cc) # Use the continuous-time plant and continuous translation of the controller + ZoH operator
140
142
PSd = feedback(Pd, C) # Use the discretized plant and discrete controller
141
143
ω = 5.53 # Frequency of input disturbance (rad/s) (Nyquist frequency is π rad/s)
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.
149
+
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
+
## Caveats
152
+
- 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
+
155
+
## References
156
+
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.
148
158
149
-
### Caveats
150
-
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.
0 commit comments