Wednesday, May 2, 2018

discrete signals - What does z^(-1) represent here?


I understand that when you have a Laplace function, you can do a bilinear or forward/backward Euler substitution for $s$ to phrase it in terms of $z^{-1}$. In a typical filter, $z^{-1}$ represents the input to the filter delayed by one sample.


But what about if it's something that's not really meant to be a filter? Ie. Something that's not really meant to get an input?



eg. Let's say you have the equation, which comes from work using the differentiation theory for Laplace transforms:


enter image description here


Where V=velocity, m=mass, v0= initial velocity, and R=impedance.


This can be phrased in terms of time as:


enter image description here


I understand how to use the time based version. You can simply run a timer from time 0 and add the sampling period to it each sample, and put that timer in for "t" to get the output each sample.


But what about the Laplace version? If you tried to sub in say a backward Euler $s=(1−z^{−1})/T$, what does $z^{-1}$ represent?


$V(z) = (m * v0) / (m * [(1−z^{−1})/T] + (2 * R))$


What now is $z^{-1}$? From a coding standpoint, what do I put into this equation for $z^{-1}$? ie. What do you delay by one sample and put back into the equation here?


ie. If you were writing this equation in C++, what would you write for the $z^{-1}$? Thanks.



Edit: I appreciate the answers but I think they're missing what I'm looking for so please let me rephrase:


I can code the simple time based equation like this:


velocity = v0 * exp ((-2 * R * timer)/mass);
timer = timer + (1/sampleRate);

And it will output velocity appropriately at each sample.


I am asking, how would I write some basic code to do the same with the z equation? I cannot understand what variable or data to put in for $z^{-1}$.


s = (1-z_1)/T;
velocity = (m * v0) / ((m * s) + (2*R));


Now in this code, what exactly is z_1?


Thanks again.



Answer



The $\mathcal{Z}$-transform expression corresponds to a difference equation which can be solved for $v[n]$, the velocity at sample $n$. From


$$V(z)=\frac{v_0T}{1+\frac{2RT}{m}-z^{-1}}\tag{1}$$


you get


$$v[n]=\frac{1}{1+\frac{2RT}{m}}\big(v[n-1]+v_0T\big)\tag{2}$$


So the delay operates on the samples $v[n]$. You just choose an initial condition (e.g., $v[-1]=0$), and you can solve the difference equation $(2)$ for $v[n]$, $n\ge 0$.


EDIT: In reaction to your edited question, I would like to ask you to think about the Laplace transform $V(s)$. What would you put in for $s$? The answer is "nothing", it's just an equation that can be solved for the desired transform $V(s)$, which can then be transformed back to the time domain. Of course, you can replace $s$ by $j\omega$ (in case the imaginary axis is inside the region of convergence), and analyze the frequency behavior of the function. The same is true for the $\mathcal{Z}$-transform: set $z=e^{j\omega}$ to obtain the frequency response. But often you just use the Laplace transform and the $\mathcal{Z}$-transform in order to solve differential (difference) equations.


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...