# Digitally undoing a hardware filter

I have a bunch of data that went through a hardware filter before being digitized. The data has been taken this way for quite some time, and everyone is fine with that. Now, there is a new application in development that requires unfiltered data. Rather than wait a year to collect new data, we would like to "unfilter" this old data. The transfer function of the hardware filter is: $$H(s)=\dfrac{24.2s+1}{2.2s+1}$$

My first throught was to take the inverse of this transfer function, and go straight to the z domain by applying the Eurler approximation. $$f_s=30Hz$$

$$H(z)=\dfrac{67-66z^{-1}}{727-726z^{-1}}$$

Converted to the difference equation:

$$V_{in}[n]=10.8507V_{out}[n]-10.8538V_{out}[n-1]+0.9851V_{in}[n-1]$$

I've run data through that difference equation in Scilab, and got a result. I want to validate the difference equation by running the result through the difference equation of the original filter, but I haven't been able to get the original data out of the second difference equation.

Which leads me to question, is what I've done here even valid? Is what I'm trying to do even possible?

## 1 Answer

Using the Euler approximation, the mapping between the $s$-plane and the $z$-plane would be:

$$s \rightarrow \frac{z - 1}{T}$$ where $1/T = f_s = 30$ (thus $s \rightarrow 30(z-1)$).

Substituting back in the original transfer function yields:

\begin{align} H(z) &= \frac{24.2\cdot 30 (z-1) + 1}{2.2\cdot 30 (z-1) + 1} \\ &= \frac{726 (z-1) + 1}{66 (z-1) + 1} \\ &= \frac{726z - 725}{66z-65} \\ &= \frac{726 - 725z^{-1}}{66-65z^{-1}} \end{align}

Which converted to a difference equation is:

$$V_{in}[n] \approx 0.0909V_{out}[n] - 0.0895V_{out}[n-1] + 0.9986V_{in}[n-1]$$

As far as whether retrieving the original signal is possible partly depends on whether the original signal did not in fact include significant energy above $f_s/2$.