2

I have some difficulties understanding something. There are several discretization methods, such as zero-order-hold (ZOH), forward euler, backward euler, tustin, et cetera.

  1. Forward euler, backward euler, et cetera discretization methods approximate the computation of a integral (see below), but what is the integral approximation when using a ZOH? What does a ZOH do?
  2. Why does Matlab not support forward euler, backward euler, Simpsons rule or even higher order integral approximations as discretization methods? But only ZOH, tustin, zero-pole matching? Is there a reason for it?
  3. Is it even usefull to use for instance Simpsons rule as a discretization method or even use higher order approximations? As far as I read, from http://en.wikibooks.org/wiki/Control_Systems/Z_Transform_Mappings#Simpson.27s_Rule, Simpsons rule has only one disadvantage?

For instance,

Consider the transfer function

$$\frac{F(s)}{E(s)} = \frac{1}{s}$$

This corresponds to the differential equation

$$\frac{\mathrm{d}f(t)}{\mathrm{d}t} = e(t)$$

Integrating both sides gives

$$f(t) = f(t_0) + \int_{t_0}^{t} e(t) \mathrm{d}t$$

Now t is evenly spaced, e.g., t = kT, with k = 0,1,2,... During one sampling t0 = kT and t = kT + T, the solution becomes

$$f(kT + T) = f(kT) + \int_{kT}^{kT + T} e(t) \mathrm{d}t$$

Now using the trapeziodal rule (tustin) http://en.wikipedia.org/wiki/Trapezoidal_rule. The integral is approximated by

$$ \int_{a}^{b} f(x)\, dx \approx (b-a) \left[\frac{f(a) + f(b)}{2} \right]$$

As a result, we obtain

$$f(kT + T) = f(kT) + \frac{kT + T - kT}{2} \left( e(kT) + e(kT + T) \right)$$

Using the z-transform you get

$$(z - 1)F(z) = \frac{T}{2} (z + 1) E(z) \rightarrow \frac{F(z)}{E(z)} = \frac{T}{2} \frac{z + 1}{z - 1}$$

and as such you determine by comparing the result with the very first equation that

$$s = \frac{2}{T} \frac{z - 1}{z + 1}$$

The same you can determine using forward euler, backward euler, et cetera. Now I am wondering what is the replacement for the laplace variable s when you will be using ZOH? And what kind of approximation does the ZOH use? As far as I understand you discretize the system using ZOH by applying

$$G(z) = (1 - z^{-1}) \mathcal{Z}\left\{\frac{G(s)}{s}\right\}$$

Nick Alexeev
  • 37,739
  • 17
  • 97
  • 230
WG-
  • 161
  • 1
  • 1
  • 4
  • Take a look here, someone covers that when answering my question about the s-transform of a moving average: http://electronics.stackexchange.com/questions/154039/whats-the-laplace-transfer-function-of-a-moving-average – Mister Mystère May 09 '15 at 22:22
  • These videos should be helpful to those still looking for an answer: https://youtu.be/rL_1oWrOplk https://youtu.be/yetLPW9sQaI I would also highly recommend the other videos in the series for anyone who is interested in controls. – vyb Oct 29 '18 at 01:42

2 Answers2

3

In a hybrid system, the sampler and ZOH perform the operations: a continuous signal is sampled (analogue to digital conversion, ADC) to produce a discrete signal, and the discrete signal is returned to continuous form (digital-to-analogue conversion, DAC). Usually there is some digital processing between these two operations, but the combined DAC/ADC operation is normally represented as a single Laplace TF in the block diagram.

For simplicity, consider the ZOH in isolation, i.e. no data processing between the sample and hold. Let the input signal = x(t), the output signal = y(t), and the sampling increment = T sec. At the k'th sampling instant (ie at t=kT), the input to the ADC may be denoted x(k) and the output from the DAC is held constant at x(k) until the next sample arrives.

Thus, the DAC output between x(k) and x(k+1) is a rectangular pulse of height, x(k), and duration, T. This can be modelled, for Laplace transform representation, as a step of height x(k) at t=kT and a step of height -x(k) at time t=(k+1)T, and may be realised via the LT delay operator, e^-skT, which delays any signal by kT sec

Hence the LT of the isolated pulse is {e^(-skT)} x(k)/s - {e^[-s(k+1)T} x(k)/s, or:

e^(-skT) {1-e^-sT} x(k)/s

For the entire signal, from t=0 to t=kT this function reduces to Y(s) = X(s) {1-e^-sT}/s where X(s) and Y(s) are the Laplace transformed ZOH input and output. Hence Y(s)/X(s) = (1-e^-sT)/s

If, now, we wish to proceed by connecting a G(s) block to the ZOH output, the overall TF becomes (1 - e^-sT) G(s)/s. But there's a problem: if we are required to close the loop around this TF, the resultant CLTF will not be analytic due to e^-sT appearing in the CLTF denominator. So we must revert to z-transforms to render it analytic.

The z-transform of the exponential bit is easy; it's (1 - z^-1), because z^-1 is the delay operator in the z-domain (and is therefore equivalent to e^-sT) and we must then find the z-transform of G(s)/s to complete the picture.

Chu
  • 7,485
  • 2
  • 14
  • 16
  • 1
    this answer is not correct. the ZOH is **not** part of the ADC operation at all (whether there is a S/H there or not). the ZOH **is** part of a conventional DAC that holds the output at a constant voltage in between discrete sample instances. – robert bristow-johnson Dec 16 '15 at 19:19
  • @Robert bristow-Johnson; the ZOH is the combined sample+hold function, where 'sample' is the ADC, converting a sample to a binary number every T sec, and 'hold' is the DAC - reconstructing a continuous signal. Usually there is a discrete system (difference equation) between these two operations. – Chu Dec 16 '15 at 23:43
  • 2
    you do not understand this. It doesn't make **any** difference to the discrete-time data \$x[n]\$ whether the analog signal at time \$nT\$ was held to the value of \$x(nT)\$ or not. if \$x(t)\$ goes into the sampler and \$x[n] \triangleq x(nT)\$ comes out of the sampler into the DSP or whatever processor, the presence or absence of the S/H is immaterial to the data values. it's the same as an ideal sampler with dirac impulses. **but** on the other end, if it is **not** dirac impulses coming out of the DAC and peicewise-constant pulses instead, a model (the ZOH) is needed to convert it. – robert bristow-johnson Dec 17 '15 at 00:02
  • @robert Bristow-Johnson, Yes, I know what sampled data is, and I know how to reconstruct a continuous time signal from a discrete sequence using a zoh. What's your point? – Chu Dec 17 '15 at 01:30
  • my point is that your answer is wrong. there are **not** two ZOHs as your answer says. if your hybrid system was modeled with a ZOH preceding the A/D and another ZOH after the D/A, the total frequency response would be incorrect because it would have two ZOHs in it, instead of the correct number. i have started a question for us, as a Stack Exchange group, to get to the bottom of this. and we will. – robert bristow-johnson Dec 17 '15 at 01:36
  • My answer does NOT say there are two ZOH, I think you misunderstood. – Chu Dec 17 '15 at 01:43
  • *"but the combined DAC/ADC operation is normally represented as a single block ('ZOH') in the block diagram."* okay, i will concede that this statement is correct (if it's a conventional DAC). the single ZOH is a consequence of the DAC. – robert bristow-johnson Dec 17 '15 at 01:47
  • Perhaps I do 'understand this' – Chu Dec 17 '15 at 07:39
  • the ZOH does not *"encompass.. two operations"*. – robert bristow-johnson Dec 18 '15 at 08:03
  • just to let you know @Chu, i put in a question to rigorously describe and understand the role of the ZOH. i put a bounty on it to invite you or anyone else to answer it with a mathematical and engineering correct answer. someone named Timo answered it and, since he was the only person, other than me, to answer, that person will get the bounty. but i answered too. you might want to check it out. – robert bristow-johnson Dec 27 '15 at 02:41
1

To adress the 3 specific questions: 1. A zero-order hold element is used to take a discrete signal at time kT and holds the value constant (0-order, remember?) until time kT+T. See Wikipedia(in the comments).

  1. Matlab does, what they want.

  2. Sampling is damn fast these days. Zero order hold is basically the easiest thing you can do, and if you sample a lot faster, than the relevant dynamics are, you are good to go! Tustin does, what you described: trying to interpolate the integral by that of a linear function.

There are certain benefits of either method. Clearly higher orders would be nice. However, they come at computation cost and complexity. Some methods preserve the pole positions of the system (making the dynamics closely related), while others distort them pretty much. Generally speaking, higher order is not allways the way to go for. Lets say you sample a mars rocket with 1ms and apply a 4th order integral approximation. If you have maybe a degree change in 10 seconds, that makes 10000 samples to find out and react. No need to get higher order things in between.

As allways order depends on your application. In this case higher than linear is not really a benefit. I think you'd rather increase the sampling rate instead.

Specifically to the example: Chu's answer is correct, however for me it was stopping exactly, where I wanted to know more: at $$ G(z) = (1-z^{-1}) \; \mathcal{Z} \left\{ \frac{G(s)}{s} \right\} $$ and exactly how is \$G\big(s=F(z)\big)\$ obtained.

Deviating from the notation of the OP, let y be the output of an integrator, and x it's input. In the frequency domain (Laplace Transform) this is: G(s) = 1/s. Let \$T_s\$ be the sampling time. For the integrator in the time domain we have:

$$ y(kT+T) = y(kT) + \int_{kT_s}^{kT_s+T_s} x(\tau) d\tau $$ now just as in the OP's example we try to approximate this integrator by approximating $$ \frac{\hat{y}(z)}{\hat{x}(z)}$$. Since we do so by holding the value constant (zero order hold) which was applied at time kT, we get $$ y(kT+T) \approx y(kT) + x(kT) T_s$$. Applying the z transform this is equivalent to $$ z \hat{y}(z) = \hat{y}(z) + \hat{x}(z) T_s$$. By reordering, we get $$ \frac{\hat{y}(z)}{\hat{x}(z)} = \frac{T_s}{z-1}$$ and by remembering, that we modeled an integrator, which is $$ \frac{Y(s)}{X(s)} = \frac{1}{s}$$ we end up with: $$ s \leftarrow \frac{z-1}{T_s} $$ and can now write $$F(z) = \frac{z-1}{T_s}$$.

mike
  • 111
  • 4
  • i haven't seen this question before. it seems that the question and answers are conflating a couple of different topics. i would direct people to the [Wikipedia article about Zero-order hold](https://en.wikipedia.org/wiki/Zero-order_hold). not all wikipedia articles are technically accurate, but this one is. A zero-order hold is the model of what a typical DAC does converting discrete-time samples (whose value has no meaning in between the discrete samples) into a continuous-time waveform that is a piecewise-constant function. – robert bristow-johnson Dec 16 '15 at 19:14
  • @Robert Bristow-Johnson; Take a simple example, let \$G(s)=\dfrac{1}{s}\$. This leads to: \$ G^*(z) = (1-z^{-1}) \; \large \mathcal{Z}\small \left\{ \dfrac{G(s)}{s} \right\}=\dfrac{z-1}{z} \; \large \mathcal{Z}\small \left\{ \dfrac{1}{s^2} \right\}=\dfrac{z-1}{z}\dfrac{Tz}{(z-1)^2}=\dfrac{T}{z-1} \$ – Chu Dec 16 '15 at 23:58
  • that example doesn't mean anything until you define what \$G(\cdot)\$ is supposed to be and what \$G^*(\cdot)\$ is supposed to be. and you apparently haven't examined the main point i wrote. – robert bristow-johnson Dec 17 '15 at 00:07
  • and i sure as heck do not understand what the Z-transform of a function with \$ s \$ is. – robert bristow-johnson Dec 17 '15 at 00:17
  • F(z) is the z-transform of the sampled sequence, f(kT), where f(t) is the inverse laplace transform of F(s). Clearly, there is loss of information in the sampling operation. – Chu Dec 17 '15 at 01:23
  • i would use notation \$x(t)\$ and \$x(nT)\$ and leave "\$f\$" and "\$k\$" as frequency ordinances. there is a loss of information in the sampling operation **only** if \$x(t)\$ is insufficiently bandlimited. i will not make that assumption. in order to make good use of the sampling theorem, i will only be dealing sufficiently bandlimited input to the sampling operation. – robert bristow-johnson Dec 17 '15 at 01:29
  • I don't want to carry the sampling increment around with me, it's constant. Hence x(n) is more convenient than x(nT). 'k' tends to be used in Control Eng; 'n' in signal processing – Chu Dec 17 '15 at 07:52
  • then use notation common in modern lit for discrete-time functions. with square brackets. $$ x[n] \triangleq x(nT) $$ but when you go back to continuous-time, you will need \$T\$ again. unless you **define** your unit time (even in the analog part) to be the same as the sampling period \$T\$. – robert bristow-johnson Dec 18 '15 at 08:05
  • $$ \mathcal{Z}\left\{ \frac{G(s)}{s} \right\} $$ is meaningless if \$s\$ is the Laplace \$s\$. – robert bristow-johnson Dec 18 '15 at 08:07
  • Why is this meaningless? – Chu Dec 18 '15 at 09:03
  • @Chu, the Z-transform is a transform of a discrete-time function like \$x[n]\$. it is not the Inverse Laplace transform that might have an argument \$G(s)\$. – robert bristow-johnson Dec 27 '15 at 02:38
  • @robertbristow-johnson, The above usage is an abuse of notation by the control community. $$ \mathcal{Z}\left\{\frac{G(s)}{s}\right\}$$ really means $$\mathcal{Z}\left\{\mathcal{L}^{-1}\left\{\frac{G(s)}{s}\right\}_{t = kT}\right\}$$ – daaxix Aug 06 '16 at 13:32
  • where $$T$$ is the sampling period. Believe me, the math all works out for the zero order hold, it is just a rect() function in the time domain, taken to the *s*-domain, then you can directly compute that formula above by using $$z = e^{Ts}$$, which is the transformation from the *s*-domain to the *z*-domain. Also, any discretized function can be Z-transformed by just defining $$g[k]=f(kT)$$. – daaxix Aug 06 '16 at 13:39
  • @daaxix, thank you for pointing that out. but in actuality what you pointed out that $$ G(z) = \mathcal{Z}\left\{ \mathscr{L}^{-1}\left\{ \frac{G(s)}{s} \right\}_{t=nT} \right\} $$ is not yet the [zero-order hold (ZOH)](https://en.wikipedia.org/wiki/Zero-order_hold). there is no rect() function in the model. it is only the **step-invariant model** which is a spin offa the [impulse-invariant model](https://en.wikipedia.org/wiki/Impulse_invariance) of mapping an analog or continuous-time s-plane filter to a digital or discrete-time z-plane filter. – robert bristow-johnson Aug 08 '16 at 04:15
  • @robertbristow-johnson, Yes, your equation above is wrong and not what I wrote. To obtain $G(z)$, you must multiply by $(1-z^{-1})$ , i.e. $$G(z) = (1-z^{-1})\mathcal{Z}\left\{\mathcal{L}^{-1}\left\{\frac{G(s)}{s}\right\}_{t = kT}\right\}.$$ The $1/s$ term and the $(1-z^{-1})$ term come directly from the Laplace transform of a rect() of width $T$ centered at $T/2$: $$\frac{1-e^{-Ts}}{s}$$ – daaxix Aug 09 '16 at 02:38
  • oh yeah. with the analog integrator in there, it would need a digital differentiator. – robert bristow-johnson Aug 09 '16 at 03:35
  • so is the **step invariant** model equivalent to a **zero-order hold**? hmmmmmm... – robert bristow-johnson Aug 09 '16 at 03:36
  • BTW, i would save the letter "\$k\$" for the DFT. i.e. "\$X[k]\$". use "\$n\$" for discrete-time. like "\$x[n]\$". – robert bristow-johnson Aug 09 '16 at 03:39