Spring 4 EE 445S Real-Time Digital Signal Proceing Laboratory Prof. Evan Homework # Solution on Review of Signal and Sytem Material Problem.. Continuou-Time Sinuoidal Generation. In practice, we cannot generate a two-ided inuoid co( f c, nor can we wait until the end of time to oberve a one-ided inuoid co( f c u(. In the lab, we can turn on a ignal generator for a hort time and oberve the output in the time domain on an ocillocope or in the frequency domain uing a pectrum analyzer. Conider a finite-duration coine that i on from ec to ec given by the equation where f c i the carrier frequency (in Hz). c( = co( f c rect(t ½) Part (a). Uing MATLAB, LabVIEW Mathcript or GNU Octave, plot c( for -.5 < t <.5 for fc = Hz. Turn in your code and plot. You may find the rectpul command ueful. Give a formula for the Fourier tranform of c( for a general value of fc. Solution: Ue MATLAB to plot the ignal c( = co( f rect(t - ½) for -.5 < t <.5. We ll need to pick a ampling rate f o that f > f max to obey the ampling theorem. The value of f max could be computed uing the anwer in part (d) but we know from the modulation property of the Fourier tranform that f max i f plu the bandwidth of rect(t - ½). Let overample: f = Hz. Part (b). Sketch by hand the magnitude of the Fourier tranform of c( for a general value of fc. Uing MATLAB, LabVIEW Mathcript or GNU Octave, plot the magnitude of the Fourier tranform of c( for fc = 8 Hz. Turn in your code and plot. Solution: Taking the Fourier tranform of c( we obtain MATLAB code T =.; t= -.5 : T :.5; f = ; x = co(*pi*f*; h = rectpul(t-.5); c = x.* h; figure plot(t,c) grid title('truncated Coine') xlabel('t') ylabel('c(') Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
C( ) F co trect t F co t* F rect t by uing the Fourier tranform property that multiplication in the time domain i convolution in the frequency domain. We then lookup the Fourier tranform of coine and rectangular pule: C ( ) j / π δ π δ * e inc where inc(x) = in( x) / ( x). Then, When plotting by hand, the firt term on the right hand ide of the equation i centered at f = /, and the econd i centered at f =- /. We can then take the abolute value: When plotting in Matlab, we can plot the full formula for the Fourier tranform magnitude. MATLAB code f=8; f=[-:.:]; C =.5*exp(-j*pi*(f-f)).*inc(f-f) +.5*exp(-j*pi*(f+f)).*inc(f+f); plot(f,ab(c)) grid title('plot of Magnitude of Fourier Tranform of c(') xlabel('f (Hz)') ylabel(' C(f) ') A pectrum analyzer would diplay the above magnitude pectrum plu noie. Part (c). Decribe the difference between the magnitude of the Fourier tranform of c( and a twoided coine of the ame frequency. What i the bandwidth of each ignal? Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
Solution: Bandwidth i the non-zero extent in poitive frequencie of the ignal' pectrum. Fourier tranform of the two-ided coine x( = co( f i X() = ((+ )+ (- )): () () Each Dirac delta ha width of zero and area of. Bandwidth i zero. From the plot in part (c), the bandwidth of C() i not zero. multiplication of the two-ided coine by rect(t - ½) in the time domain. Thi i becaue of the Each of the following i a valid method to etimate the bandwidth of bandpa ignal C(): Set amplitude threhold of magnitude pectrum at an arbitrary point below which amplitude are treated a if zero. If we ue.5 a the threhold for the plot in part (c), then we can eyeball the etimated bandwidth of C() to be.5 Hz. Meaure width of the mainlobe in the magnitude pectrum between the two zero croing on either ide of the carrier frequency. For the magnitude pectrum in part (c), we can eyeball the etimated bandwidth to be Hz. Etimate the power bandwidth to capture 9% of the area under the power pectrum. With a center frequency of 8 Hz, a bandwidth of Hz would only occupy 55% of the total area. Thi approach doe not work all that well in thi cae. More dicuion next. Firt, we define a function called myfun in file myfun.m to compute C(f) : function mag_c = myfun(f) f=8; mag_c = ab(.5*exp(-j*pi*(f-f)).*inc(f-f) +....5*exp(-j*pi*(f+f)).*inc(f+f)); Next, we can approximate the total area under the magnitude pectrum by uing Hz in place of and uing the numerical integration function quad: area = quad(@myfun,,); Finally, frequencie to Hz only contain 55% of the area: area = quad(@myfun,,); We are better off eyeballing the bandwidth from the plot of the magnitude pectrum. Problem.. Downconverion. A ignal x( i input to a mixer to produce the output y( where y( = x( co( and Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
= f and f = khz. A block diagram of the mixer i hown below on the left. The Fourier tranform of x( i hown below on the left. Part (a). Uing Fourier tranform propertie, derive an expreion for Y(f) in term of X(f). Solution: Fourier tranform of y( = x( co( i Y(ω) = Since co(ω Y(f) [co( ]* X(ω) [(ω ω ) + ( ω + ω )], Y ( ) ( X ( ) X ( )) Y f ) f f f f * X ( f ) ( X ( f f ) X ( f In a imilar way, )) Part (b). Sketch Y(f) v. f ( f f(khz) -5-4 -3-3 4 5 Part (c). What operation would you apply to the ignal y( in part (b) to obtain a baeband ignal? The proce of extracting the baeband ignal from a bandpa ignal i known a downconverion. Solution: Baeband ignal may be obtained by applying a lowpa filter to y( that pae frequencie in [-,] khz and attenuate frequencie at and above 3 khz in abolute value. Problem.3. Sampling in Continuou Time. Sampling the amplitude of an analog, continuou-time ignal f( every T econd can be modeled in continuou time a y( = f( p( where p( i the impule train defined by p( n t nt Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
T i known a the ampling duration. The Fourier erie expanion of the impule train i p( co( co(... T where = / T i the ampling rate in unit of radian per econd. Part (a). Plot the impule train. n Solution: Plot of the impule train p( t nt p (t ) () () t -T T The notation (A) mean that the area under the Dirac delta i A. Thi i important becaue the value of the Dirac delta at the origin i undefined. Part (b). Note that in part (a), p( i periodic. What i the period? Solution: A ignal x( i periodic with period T if x( = x(t T) for all t. The mallet value of T for which x( i periodic i called the fundamental period. The impule train p( i periodic with fundamental period T. The fundamental period i ued in the Fourier erie expanion of the impule train where the ampling rate in rad/ i = / T : Part (c). Uing the Fourier erie repreentation of p( given above, pleae give a formula for P(), which i the Fourier tranform of p(. Expre your anwer for P() a an impule train in the Fourier domain. Solution: We apply the Fourier tranform to p( given immediately above to compute P( ) ( ( ) ( ) ( ) ( ) ( )...) T p( co( co(... T by uing the tranform pair co(ω [(ω - ω ) + ( ω + ω )] and (ω) Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
Thu n P ( ) ( n ) Part (d). What i the pacing of adjacent impule in the impule train in P() with repect to frequency in rad/? Solution: The pacing of the impule train P() in i, which i the ditance between adjacent impule in the Fourier domain. Problem.4. Dicrete-Time Sinuoidal Generation. Conider a caual dicrete-time linear time-invariant ytem with input x[n] and output y[n] being governed by the following difference equation: y[n] = ( co ) y[n-] - y[n-] + (in ) x[n-] The impule repone of the above ytem i a caual inuoid with dicrete-time frequency in unit of rad/ample. The value of would normally be in the interval [-, ). You will be implementing the above difference equation in C in lab # on a programmable digital ignal proceor for real-time inuoidal generation. Part (a). Draw the block diagram for thi ytem uing add (or ummation), multiplication (or gain), and delay block. Pleae label delay block with the text z -M to denote a delay of M ample. Ue arrowhead to indicate direction of the flow of ignal. Solution: Block diagram of the given filter with input x[n] and output y[n] and with coefficient b = in and a = co : Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
Part (b). Pleae tate all initial condition. Pleae give value for the initial condition to atify the tated ytem propertie. Solution: Initial condition can be found by calculating the firt few output value: y[] = ( co ) y[-] - y[-] + (in ) x[-] y[] = ( co ) y[] - y[-] + (in ) x[] Hence, the initial condition are given by y[-], x[-] and y[-]. Thee value correpond to the initial value in the delay-by-one-ample block, which are denoted by z -. The impule repone i given a h[n] = in( n) u[n]. That i, for x[n] = [n], the output i y[n] = h[n], which give y[-] = h[-] = and y[-] = h[-] = and x[-] = [-] =, For the ytem to atify the linearity property, the initial condition mut be zero. Same goe for the ytem property of time-invariance. We will how thi on lide 3- and 3-. Part (c). Find the equation for the tranfer function in the z-domain, including the region of convergence. Solution: y[n] = ( co ) y[n-] - y[n-] + (in ) x[n-] Taking z-tranform of both ide, we get Y(z) = ( co ) z - Y(z) - z - Y(z) + (in ) z - X(z) => Y( z) X ( z) in z co z z => H in z co z z ( z) To find the region of convergence, we need to find the pole of thi tranfer function: - ( co ) z - + z - = By multiplying each ide by z (auming that z ): z - ( co ) z + = Root are located at ½ (-b qrt()). Here, Since <, there are two complex root: 4co 4 4in Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp
x co j in co j in co j in ; x co j in Both pole have a magnitude of. A a reult, they lie on the unit circle in the z-plane. Since the ytem i caual, the region of convergence will be outide of the circle of radiu equal to the magnitude of the pole with the greatet magnitude, i.e. z >. Part (d). Compute the invere z-tranform of the tranfer function in part (c) to find the impule repone of the ytem. Solution: By uing invere z-tranform table, the above H(z) with the given region of convergence will have an impule repone of h[n] = in( n) u[n]. Part (e). Uing MATLAB, LabVIEW Mathcript or GNU Octave, plot the impule repone obtained in part (d) for equal to, π, and a value in the interval (, π) of your chooing. Turn in your code and plot. Solution: i rad/ample (lef, π rad/ample (center), and π/4 rad/ample (righ: Sample MATLAB code for = π/4: w = pi/4; n = [:5]; u = tepfun(n,); x = in(w*n); h = x.*u; figure, tem(n,h); In the middle plot, which i for = π rad/ample, all amplitude value hould have been zero. Non-zero value are due to numerical error in computing in( n) for n 5 in floating-point arithmetic. The value are on the order of -5, which i very cloe to zero. Coure Web ite: http://www.ece.utexa.edu/~bevan/coure/rtdp