Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Working of Digital filters...

Status
Not open for further replies.

koolguy

Active Member
I was just thinking how Digital filters work in case of analog we just connected
RC to the signal input to amplifiers, etc
but in case of Digital filter....what happen??
In case of analog low pass filter with connect R and C by using cut of frq. F=1/(2*PI*R*C)....and analyzing by Bode plot.
But this how really work in digital filters??
The input isin form of 010101010 if i want low freq. output of digital signal then what to do??

thanks
 
The input is analog and the output is analog. Search google for more information.
 
I was just thinking how Digital filters work in case of analog we just connected
RC to the signal input to amplifiers, etc
but in case of Digital filter....what happen??
In case of analog low pass filter with connect R and C by using cut of frq. F=1/(2*PI*R*C)....and analyzing by Bode plot.
But this how really work in digital filters??
The input isin form of 010101010 if i want low freq. output of digital signal then what to do??

thanks


Hi,

A digital filter works by way of utilizing the differences between successive samples of the input and output over a number of samples where the number of samples can vary. This means that the filter might do computations on any of the following:
the current input,
the N last inputs,
the current output,
the M last outputs.

The computations involve coefficients and sums. As real arbitrary (possibly not realistic) example:
y[k]=1+x[k]+x[k-1]-x[k-2]-y[k-1]

What this does is it starts with 1, adds the current input sample x[k], adds the previous input sample x[k-1], subtracts the previous sample before that one x[k-2], and subtracts the previous output y[k-1] and that result becomes the new output.

To design a low pass filter we could start with a linear filter and transform it to a digital filter and then transform that to a difference equation where we could then implement that directly in micro controller code.

We can do a quick example of a low pass filter.
 
To design a low pass filter we could start with a linear filter and transform it to a digital filter and then transform that to a difference equation where we could then implement that directly in micro controller code.

We can do a quick example of a low pass filter.

Hi again sir,

Yes sure you can go........
I will be thankful.
 
Start with the continuous time low pass filter:
Vout/Vin=1/(s*R*C+1)

and now we make the substitution (this is known as the Bilinear Transform):
s=(2/T)*(1-z1)/(1+z1)

where
z1=1/z

and after doing that and simplifying we get:
y(z)/x(z)=(z+1)*T/((z+1)*T+(2-2*z)*R*C)

or:
y(z)/x(z)=x(z)*(z+1)*T/((z+1)*T+(2-2*z)*R*C)

Divide top and bottom of the right side by z we get:
y(z)=x(z)*((1+z1)*T)/((1+z1)*T+(2-2*z1)*R*C)

Replace y(z) with y[n] and replace x(z) with x[n]:
y(n)=x(n)*((1+z1)*T)/((1+z1)*T+(2-2*z1)*R*C)

multiply that out:
y[n]*((1+z1)*T+(2-2*z1)*R*C)=x[n]*((1+z1)*T)

or:
y[n]*z1*T+y[n]*T-2*y[n]*z1*C*R+2*y[n]*C*R=x[n]*z1*T+x[n]*T

Replace any y[n]*z1 with y[n-1] (same with x):
y[n-1]*T+y[n]*T-2*y[n-1]*C*R+2*y[n]*C*R=x[n-1]*T+x[n]*T

solve for y[n]:
y[n]=((x[n]-y[n-1]+x[n-1])*T+2*y[n-1]*C*R)/(T+2*C*R)

We see that y[n] depends on the samples x[n] and x[n-1] and on y[n-1] also,
and T is the sample period, and R and C are the same as in the analog filter.

Comparing this last result with the original continuous time filter we see similar results with proper choice of T although not exactly the same.
 
Last edited:
Hi again,


I will like to study from basic of impulse response of digital filters...
as what the of it in filters....or simply what does it mean..??

what does this mean X(n)= 1 8 5 4 and H(n) impulse = 1 5 4 6
What impulse response are not in 0 or 1??
 
The impulse response is just the theoretical response to a network from an input that is an impulse.
This is fairly important because the impulse response is used to characterize the response of a system.
Once you know the impulse response, you can then use that to calculate the output with various inputs.
For your X(n) and H(n) since you know what H(n) is you can convolve it with X(n) and that gives you the output of the network H(n) that results from using X(n) as the input. If you use a different sequence X(n) then you get a different output.
If you use an impulse as the input you get H(n) back again because that's the definition of H(n).
 
Last edited:
If you use a different sequence X(n) then you get a different output.
If you use an impulse as the input you get H(n) back again because that's the definition of H(n).

So, why for filter we have differnt impluse response like for X(n) = 1 we have h(n)= 2 and X2(n)= 5 we have h(n2)=5..like that??

please provide aeasy block diag. which can fig. this out??

Thanks
 
To calculate the output we would use the discrete convolution sum:

[LATEX]x*h = \sum^{\infty}_{i=-\infty} (\, x[n]\,h[n-i]\, )[/LATEX]

In plain text:
x*h=sum[-inf to +inf ] ( x[n] h[n-i] )
 
Last edited:
HI sir,

I am asking about impluse response...
what are these in real?? can you provide and fig. to point this out??

As if we have impluse response of then 7 or 9 what changes will come in circuit or working that the exact question i want to know...
 
Hi,

Again im not really sure what you are asking here.

Another way to describe the impulse response is that it is the inverse Laplace Transform of the transfer function H(s).
It's a way to characterize the circuit that allows quick analysis for inputs other than an impulse.
 
Hello sir,

Another way to describe the impulse response is that it is the inverse Laplace Transform of the transfer function H(s).

my question is digital filters or transform use impluse response...which is discrete value.
So,, this discrete value is stored in uC for processing FFT, etc.....
So, from where or how we choose value of this impulse response and feed o uC or digital chips??

I think now ithe impulse question is clear....
 

Attachments

  • untitled.JPG
    untitled.JPG
    108.3 KB · Views: 321
Hi again,


Well one way would be to apply an impulse to the filter transfer function (we talked about previously) and record the output and code that into the uC chip.

I think you should really do a search for this on the web however because you'll find various techniques in use. In particular, look for:
"FIR Filter".

I'll see if i can get a drawing up that illustrates what this all means.
 
Last edited:
Hi,

I thought it was going to take longer to work up an example, but it turns out it didnt take that long at all.

This example uses the previous example of a continuous time RC low pass filter transfer function transformed into a digital filter transfer function. For this example R=1 and C=1, and the sample time T=1 also.
Since the digital filter transfer function therefore was already available, an impulse (more appropriately called 'unit sample') was used as the excitation and the resulting output sequence recorded. Since that output sequence represents the impulse response, that impulse response was then convolved with an input step wave and the output sequence recorded. The continuous time response could then be compared to the discrete time response.

The result of the continuous time response and the result of the digital response were plotted vs time and that plot is shown in the attachment.
The blue plot is the continuous time response and the red dots are the digital response points obtained as the output from a sequence of all ones convolved with the impulse response obtained from the digital transfer function.

As we can see from a quick inspection of the two plots, the digital response is not exactly the same but it does act in a similar manner.

The impulse response (more appropriately called the 'unit sample response') was recorded for 10 points and were the following values:
0.3333333333
0.4444444444
0.1481481481
0.04938271605
0.01646090535
0.00548696845
0.001828989483
0.0006096631611
0.0002032210537
6.774035123e-005

The above could be used as the impulse response and coded into the micro controller memory.

The actual numerical data for the output is as follows:
0
0.3333333333
0.7777777778
0.9259259259
0.975308642
0.9917695473,
0.9972565158
0.9990855053
0.9996951684
0.9998983895

and those values are plotted as the large red dots in the drawing.
 

Attachments

  • Continuous-vs-Discrete-01.gif
    Continuous-vs-Discrete-01.gif
    11 KB · Views: 334
Last edited:
Hi again sir,

(I think) The graph is representing the output waveform when unit step is input while it takes some time to reach its peak value ( i.e. logic 1)
one more thing, Is impulse mean like we use AND gate and have input to one side A and sampling pulse at B of AND gate and taking output from C??

last thing,
as per fig. impulse mean discrete amplitude of sigmnal at time period of 1sec..??

The above could be used as the impulse response and coded into the micro controller memory.

That mean we first need to enter impulse in uC, can we get this impulse response seen in oscilloscope or simulation software (MATLAB)
 
Hi,

The graph is showing a regular RC network with a step input, and the sampled data filter output (red dots) with step input after we found the 'unit sample' from using the bilinear transform on the continuous time system. See below for more on this.

Which brings us to some small terminology difference...we should be calling the digital response the 'unit sample' response rather than the impulse response as that's more correct. You can find the response of your digital filter by using a unit sample input and recording h(h), the output. The unit sample is applied at t=0.

Really we refer to the values as 'samples' but they are like impulses with a given height, and are usually drawn as dots at the required place with a line that extends from the dot down to zero. So they look like little lolly pops :) They are defined only for that sample time.

If you wanted to see the unit sample response (to be coded in uC) on the scope, you could input a unit sample at t=0 and watch output on the scope. It will go though various transitions and usually the sample will last the whole time period rather than for just one instant so keep that in mind.

To see the impulse response of a continuous time system, you could use a step input and a fast, scaled differentiator on the output. For example an op amp differentiator with time constant 1ms would be scaled 1000 to 1. This assumes a linear transfer function.

More on the digital low pass filter example...

Note that the output can be obtained by adding successive values of the unit sample response. This gives rise to another idea that seems to work very nicely.
The idea is that we apply a step input to the low pass filter, sample it's outputs at several sampling intervals, and use the difference between samples as our unit sample response. Interestingly, when we do it this way and we convolve it with a step input we get the exact output as we would from the continuous time system except the output is a set of samples instead of a continuous wave. The values at the sample instants however are exactly the same as the continuous time system assuming no finite register length truncation.
 
Last edited:
Hi again,

I am still confuse with the use of H(n) impulse response with x(n) sample value....

See we have sin wave in analog form we convert into digital by sampling the output value will be like this:-
0 1 2 3 4 5 4 3 2 1 0 1..........like this the 5V is maximum.
we store this in PROM and a addr counter connected to PROM will give output in digital for will convert it in analog by DAC......like this
then where comes the use of impulse response in this.
 
Hi,

Using a table like that is not exactly the same as using an impulse response to get an output. All that is is a lookup table, where the values are stored in tabular form and the next value that is looked up is simply directed to the output. That's not the same as when using an impulse response as the following will show.

Say we start with a simple sine lookup table like this (the '9' and '-9' here are rounded from 8.66 and -8.66 for simplicity):
{ 0, 5, 9, 10, 9, 5, 0, -5, -9,-10, -9, -5 }

That's a table of values for sine where the peak is 10 volts. To get the next output, we simply step to the next counter value and read the table value and direct that to the output. That's not exactly the same as when we use an impulse response, although we could make it into one.

A better example is this one. Lets say that our h(n) is this instead of the sine table:
{ 5, 4, 1, -1, -4, -5, -5, -4, -1, 1, 4, 5 }

Look strange? It might look strange, but if we use a step input for x(n) guess what we get as output?
x(n)*h(n)={ 0, 5, 9, 10, 9, 5, 0, -5, -9,-10, -9, -5 }

and that's the original sine table.

So with the lookup table we simply look up values and direct them to the output, and there doesnt have to be any input. When using the impulse response, we have to convolve it with the input in order to get the output. The impulse response (or better called "unit sample response" here) could be that of a filter so that the output ends up being the input signal filtered in some way.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top