How does the z transform work in practice?

456 Views Asked by At

What I've found

I've implemented a PID controller using the equations 7 and 9 of this article, which states that: $$\frac{U(s)}{E(s)}=K_p+\frac{K_i}{s}+K_ds$$ Translates to $$\frac{U(z)}{E(z)}=K_p+\frac{K_i}{1-z^{-1}}+K_d(1-z^{-1})$$ Meaning that I had to implement: $$u(k)=u(k-1)+(K_p+K_i+K_d)e(k)-(K_p+2K_d)e(k-1)+K_de(k-2)$$ It looks like it's working fine, so I wanted to understand how they got this equation but I don't end up with the same results.

What I've done

Apparently the z-transform is linear so I just have to find the z-transform of the integrator $\frac{1}{s}$ and the derivative $s$. Tables give the z transform of the integrator as $\frac{1}{1-z^{-1}}$ but do not give that of the derivative (why?) so I tried to do both this way: $$\text{integral}(k)=\text{integral}(k-1)+\frac{\text{input}(k)+\text{input}(k-1)}{2}T$$ $$\text{derivative}(k)=\frac{\text{input}(k)-\text{input}(k-1)}{T}$$ Which, if previous values are multiplied by $z^{-1}$, yields: $$\text{integral}(z)=\text{integral}(z)z^{-1}+\frac{\text{input}(z)+\text{input}(z)z^{-1}}{2}T$$ $$\text{derivative}(k)=\frac{\text{input}(k)-\text{input}(k)z^{-1}}{T}$$ Rearranged: $$\frac{\text{integral}}{\text{input}}(z)=\frac{T}{2}\frac{1+z^{-1}}{1-z^{-1}}$$ $$\frac{\text{derivative}}{\text{input}}(z)=\frac{1-z^{-1}}{T}$$ Question

Why don't they give the same answer? How does the z-transform work in practice (including how to get from the z transfer function to discrete time)? I could not find anything well explained online.

1

There are 1 best solutions below

2
On BEST ANSWER

The formula for $U(z)/E(z)$ cannot be right - it makes no reference to sample time. There are many good references with correct formulas for discrete PID controllers. They are not unique - there are several slightly different constructions that implement the idea of PID control.

It is not completely clear what a $z$-transform of a function of $s$ would be. One of the reasons why an exact differentiator cannot be built in discrete time has to do with causality.