EE422
Homework #36
Due Tuesday, April 27
0.
DO NOT ATTEMPT THIS HW UNTIL AFTER EXAM III!!I have posted the solution, but please try to do this on your own.
1a)
Starting with the analog first-order low pass filter,![]()
find the response due to the following inputs:
i)
ii)
iii)
b)
For the low pass filter in part a), design a digital filter H(z) with Ts=10 msec using the following techniques:i)
Impulse Invariant (please use the practical impulse we spoke of in class,ii)
Step Invariant (Make sure you do not multiply by Ts when finding Y(z)!!)iii)
Bilinear Transformationc)
Using T=10msec and Matlab's filter() command, plot the response of each of your digital filter designs to the following discrete inputs:i)
ii)
iii)
d)
Also, use Matlab to plot your answers to part a) and compare each digital filter design response to the original analog filter responses.
2a)
Draw a block diagram of your bilinear digital filter from part 1b) using phase variable realization (phase variable realization is also called direct form II in your book)
In the above problem, you realized your digital filter by using discrete blocks such as summers (adders), gain blocks (shift and add registers) and delays (flip-flops). In practice, however, digital filters are most commonly realized using A/D D/A systems and some sort of micro-processor as shown below:
![]()
To this end, consider the general first-order digital filter,
.
b)
Cross-multiply H(z) and take the inverse Z-transform to obtain an expression in terms of yk, yk-1, wk, wk-1.
c)
Now solve this expression for yk in terms of yk-1, wk, wk-1
d)
Find values for a0, a1, b0 and b1 for your bilinear filter design in part 1b)
The A/D D/A system we have in the lab is a 12 bit, ± 10 volt (i.e., dynamic range of 20 volts) system with the following standard linear encoding scheme:
-10 volts is encoded to 0
10 volts is encoded to 4095 (i.e., 212 - 1)
So, to determine what an encoded number inside our computer represents in volts, we would use the following conversion:
Analog voltage =((digital encoded number/2048)*10)-10=(digital encoded number/204.8)-10
To take a voltage and convert it back to a number ready for encoding we would do the reverse:
Digital encoded number = (Analog voltage + 10)*204.8
We also have written on our PC the following C program functions for the purposes of implementing digital filters:
int in(); /* returns an encoded value from the A/D . Usage: w = in(); */
void out(int y); /* outputs the encoded value in y to the D/A */
void sleep(int t) /* delays a total of t msec */
For purposes of this homework, assume that each C programming statement will take exactly 1 msec to execute on our PC. Thus, by counting the number of statements in a program and adding more delay through the sleep command, we can obtain a variety of sampling times for digital filter implementation
As an example, consider the following C program which inputs an encoded value from the A/D, stores it, then multiplies it by 5.0, then delays a total of 50 msec and outputs the correct encoded value to the D/A:
#include <stdio.h>
#include <math.h>
main(){
int wnew, w_old;
float gain, y;
y=0.0; /*Initialize values */
wk=0.0;
gain=5.0;
wold=0;
wnew=0;
while(1){
out(wold); /*Output old encoded value from previous loop*/
wnew=in(); /*Get new value from A/D*/
y=(float)(wnew/204.8)-10; /*Convert encoded input to a floating point number*/
y=gain*y; /*Multiply by the gain*/
wold=(int)204.8*(y+10) /*Convert back to encoded number and store in wold*/
sleep(45); /*We've used 5 statements so delay 45 msec more to get Ts=50 msec*/
}
}
e)
Use the above example program to complete (i.e., fill in the blanks) the following program which implements your bilinear digital filter design:#include <stdio.h>
#include <math.h>
main(){
int temp;
float a0,a1,b0,b1,yk,yk_minus_1,wk,wk_minus_1;
yk=0.0; /*Initialize values */
yk_minus_1=0.0;
wk=0.0;
wk_minus_1=0.0;
b0=________;
b1=________;
a0=________;
a1=________;
while(1){ /*Loop forever*/
temp=in(); /*Store A/D encoded value temporarily in temp*/
wk=(float)(wtemp/204.8)-10; /*Convert encoded input to floating pt. number*/
yk=________________________________; /*Form the equation for yk*/
temp=(int)204.8*(yk+10) /*Convert yk to encoded number and store in temp*/
out(temp); /*Output encoded value*/
wk_minus_1=__________; /*Store new values in old variables*/
yk_minus_1=__________; /*Store new values in old variables*/
sleep(___________); /*Ts=10 miliseconds*/
}
}