Friday 16 September 2016

Recursive filter gain


I implemented a filter similar to the one below, within a FPGA. Two substractors and an accumulator.


enter image description here The recursive equation is given by:


enter image description here


My inputs are exponentially decaying pulses of the form enter image description here sampled every n


I want to express y[n] as a function of the pulse amplitude A (which I need to retrieve), and the constants enter image description here, L, and K.


Any hints would be greatly appreciated


Edit:



I followed Andy Walls' advice and this is what I get


$$H(z) = \frac{(1-Z^{-K})(1-Z^{-L})}{1-Z^{-1}}$$ $$X(z) = \frac{A}{1-aZ^{-1}} $$ $$with: a = e^{\frac{-nT}{\tau}}$$ $$Y(z) = H(z).X(z) = \frac{A}{1-aZ^{-1}} . \frac{(1-Z^{-K})(1-Z^{-L})}{1-Z^{-1}} $$ Using partial fraction expansion I try to find B and C so that $$ Y(z) = A.(\frac{B}{1-aZ^{-1}} + \frac{C}{1-Z^{-1}})$$ I get $$ B = \frac{A.(1-a^{-K})(1-a^{-L})}{(1-a^{-1})}; C=0$$ So $$Y(z) = \frac{A.(1-a^{-K})(1-a^{-L})}{(1-a^{-1})(1-aZ^{-1})}$$


I don't know if I am right at this point, but this is where I get stuck. This filter is trapezoidal, but because the input is an exponential decay, I would expect at least 2 exponential terms corresponding to the trapeze rise and fall times.


Am I on the right path?



Answer



Take the Z Transform of your difference equation and perform algebraic manipulations to find $H(z)=\dfrac{Y(z)}{X(z)}$ as a rational function of $z$.


Take the Z Transform of your input $x(nT) = x[n]$ to find $X(z)$.


Multiply to get $H(z)X(z) = Y(z)$.


Find the inverse Z Transform of $Y(z)$ to find $y[n]$. (This will be the difficult part, as you may need to use partial fraction expansion and other mathematical techniques so you can look up inverse transform in a table.)


These tables will help: http://lpsa.swarthmore.edu/LaplaceZTable/LaplaceZFuncTable.html



Update in response to comment


Here's what I get.


Finding the transfer function:


$$\mathcal{Z}\left\{y[n]\right\} = \mathcal{Z}\left\{y[n-1] + x[n] -x[n-K]-x[n-L]+x[n-K-L]\right\} $$


$$Y(z) = Y(z)z^{-1} + X(z) - X(z)z^{-K} -X(z)z^{-L} + X(z)z^{-K-L}$$


$$\begin{align*}H(z) = \dfrac{Y(z)}{X(z)} &= \dfrac{1-z^{-K}-z^{-L}+z^{-K-L}}{1-z^{-1}}\\ \\ &= \dfrac{\left(1-z^{-K}\right)\left(1-z^{-L}\right)}{1-z^{-1}}\\ \\ &= \left(1 + z^{-1} + \dots + z^{-K+1}\right)\left(1-z^{-L}\right)\\ \\ &= 1 + z^{-1} + \dots + z^{-K+1} -z^{-L}-z^{-L-1}- \dots -z^{-K-L+1}\\ \\ \end{align*}$$


Transforming the input:


$$X(z) = \mathcal{Z}\left\{x(nT)\right\} = \mathcal{Z}\left\{Ae^{-\frac{nT}{\tau}}u[n]\right\} = A\dfrac{z}{z-e^{-\frac{T}{\tau}}}= A\dfrac{1}{1-e^{-\frac{T}{\tau}}z^{-1}}$$


Filtering in the Z domain: $$\begin{align*}Y(z) &= H(z)X(z)\\ \\ &=\dfrac{1-z^{-K}-z^{-L}+z^{-K-L}}{1-z^{-1}} \cdot A\dfrac{1}{1-e^{-\frac{T}{\tau}}z^{-1}}\\ \\ &=A\left[\dfrac{1-z^{-K}-z^{-L}+z^{-K-L}}{\left(1-z^{-1}\right)\left(1-e^{-\frac{T}{\tau}}z^{-1}\right)}\right]\\ \\ &=A\left[\dfrac{C}{1-z^{-1}}+\dfrac{B}{1-e^{-\frac{T}{\tau}}z^{-1}}\right]\\ \\ \end{align*}$$


Performing partial fraction expansion:



$$\begin{align*}1-z^{-K}-z^{-L}+z^{-K-L} &= C\left(1-e^{-\frac{T}{\tau}}z^{-1}\right) + B\left(1-z^{-1}\right)\\ \\ \left(1 + z^{-1} + \dots + z^{-K+1}\right)\left(1-z^{-L}\right)\left(1-z^{-1}\right)&=C\left(1-e^{-\frac{T}{\tau}}z^{-1}\right) + B\left(1-z^{-1}\right)\\ \end{align*}$$


so $$\begin{align*}C &= 0 \\ \\ B &= 1 + z^{-1} + \dots + z^{-K+1} -z^{-L}-z^{-L-1}- \dots -z^{-K-L+1}\\ \end{align*}$$


Continuing filtering in the Z domain: $$\begin{align*}Y(z) &=A\dfrac{1 + z^{-1} + \dots + z^{-K+1} -z^{-L}-z^{-L-1}- \dots -z^{-K-L+1}}{1-e^{-\frac{T}{\tau}}z^{-1}}\\ \\ \end{align*}$$


Since there is no information on the values of $K$ and $L$, there is not really any more simplification we can do in the Z domain.


Taking the inverse Z-Tranform:


$$\begin{align*}y[n] &= A\left[e^{-\frac{nT}{\tau}}u[n]+e^{-\frac{(n-1)T}{\tau}}u[n-1]+\dots+e^{-\frac{(n-K+1)T}{\tau}}u[n-K+1]-e^{-\frac{(n-L)T}{\tau}}u[n-L]-e^{-\frac{(n-L-1)T}{\tau}}u[n-L-1]-\dots-e^{-\frac{(n-K-L+1)T}{\tau}}u[n-K-L+1] \right]\\ \\ &= A \sum_{k = 0}^{K-1} e^{-\frac{(n-k)T}{\tau}}u[n-k] - e^{-\frac{(n-k-L)T}{\tau}}u[n-k-L]\\ \\ \end{align*}$$


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...