activity 04
TRANSCRIPT
-
8/9/2019 Activity 04
1/14
Experiment No. 04ANALYSIS OF DISCRETE-TIME SYSTEMS: CONVOLUTION AND DIFFERENCE EQUATION
1. Objective(s):This activity aims to:
1. demonstrate how discrete-time systems are analyzed using the convolution and difference
equation; and
2. equip the students with the knowledge and skills in using the MathScript node or MATLAB in
generating discrete-time signals and implementing the convolution algorithm and determining the
output of a system described by constant-coefficient difference equation.
2. Intended Learning Outcomes (ILOs):At the end of this activit , the students shall be able to:
1.
generate elementary discrete-time signals and using these as inputs to systems; and2. analyze discrete-time system using the convolution algorithm or the difference equation.
3. DiscussionDiscrete-time systems can be analyzed and implemented in two ways: using the convolution sum and
through a recursive algorithm that can be expressed in terms of a difference equation.
The convolution sum is implemented through four operations: folding a signal in time, shifting the folded
signal by a number of sample, multiplying the signals and summing up the product sequence. The
algorithm for computing the convolution sum y(n)of the signals x(n)and h(n)is
y(n)= x(n) h(n)= x(k)h(n k)
For a finite-duration signal, this implementation is effective. However, for signals with infinite duration, a
recursive algorithm may be more effective since it is computationally more efficient and requires less
memory.
Recursive systems are those systems that use memory elements to store all past results of the
computations, use it when needed, and updates itself when new values arrive. This implementation is more
practical when the system is characterized by an infinite impulse response. The impulse response of a
discrete-time system is the response of the system for a unit sample input. This impulse response
characterizes the system and is used to generate the response of the system for any arbitrary input,through the convolution sum. Another important characterization of systems is the step response, which is
the output of the system for a step input.
Recursive systems are described by difference equations which have the general form
y(n)= ay(n k)
+ bx(n k)
-
8/9/2019 Activity 04
2/14
where the values aand bare the filter coefficients of y(n)(with a= 1) and (n)respectively. Thenumber Nis the order of the system.
In this activity, the MathScript module of LabVIEW will be used. The MathScript module of LabVIEW is
intended to increase compatibility with m-files, or programs created using MATLAB. Inside the MathScript
module, a source code with syntax and semantics similar to MATLAB is used. Thus, MATLAB programs
can be run on a LabVIEW environment using the MathScript node. This activity uses the MathScript node
to implement the convolution sum and the difference equation.
4. Resources:To perform this activity, a computer workstation with LabVIEW 8.6 or higher with MathScript module.
MATLAB can also be used by creating a program out of the code inside the MathScript node.
5. Procedure:
Activity 4.1 Generation of Elementary Discrete-time Signals Using the MathScript node.1. Create the VI act04-01_delta.vi. This will generate a unit sample sequence in which the user can
specify at what time index nwill the sequence start and finish, and also the number of samples kthis
signal will be delayed (for positive k) or advanced (for negativek).
2. Build the FP and BD as shown.
Insert a MathScript nodestructure. Right-click on the left edge of the structure and chooseAdd
Input, naming this input as k. This variable will be the number of samples the unit sample
sequence will be delayed or advanced. Add two more inputs. Name them as n1andn2. These will
be the starting and ending time-index of the sequence respectively. Create numeric controls for
each of the inputs.
-
8/9/2019 Activity 04
3/14
Type the following in the first line of the MathScript node:
n = [ n1: n2] ; x = [ ( n- k) == 0] ;
This will generate an array nwhich will have n1as the first element, increments by one and ends
up with n2as the last element. The array xwill be generated by testing each of the values of array
nminus the number of delay if it is equal to zero. It returns 1 when it is true.
Create the outputs nandx. Switch to FP. Create anAr rayindicator, naming this as n then place a
numeric indicator inside this array indicator. Insert another array indicator for x.
Switch to BD. Wire the nand xarray indicators to the nand xoutputs of the MathScript node to
the array nodes. Then right-click the nand xoutputs of the MathScript node and select Choose
Data Type > 1D Array > DBL 1D.
Switch back to FP. Insert an XY Chart. Name this as delta(n). Configure the chart as shown:
Wire the X inputterminal of the Build XY Graphto the noutput of the MathScript node and the Y
inputterminal to the xoutput of the MathScript node.
3. Save and run the VI. Test the VI for various values of k, n1andn2.
Q1.3(a): Generate the following sequences and plot the resulting waveform.
-
8/9/2019 Activity 04
4/14
Edit the icon of this VI as shown below. Then set the connections of this VI with k, n1and n2as inputs
and xand nas outputs. Save the VI.
4.
Replicate act04-01_delta.viand rename the VI asact04-01_step.viModify the FP and BD as shown.
5. Save and run the VI.
Q1.5(a): What is the functionality of the VI?
Q1.5(b): Complete the table below by p lotting the output signal fro m the XY chart.
6. Edit the icon of this VI as shown below. Then set the connections of this VI with k, n1and n2as inputs
and xand nas outputs. Save the VI.
-
8/9/2019 Activity 04
5/14
7. Replicate act04-01_step.vi and rename the VI as act04-01_realexp.viModify the FP and BD as
shown.
Configure the XY Graph. Under the Display Formatof the Properties of XY Graph, choose
Amplitude (Y-Ax is )and change theFormat stringto %0.1g.
8.
Edit the icon of this VI as shown below. Then set the connections of this VI with a, n1and n2as inputsand xand nas outputs. Save the VI.
-
8/9/2019 Activity 04
6/14
9. Run the VI.
Q1.9(a): What is the functionality of the VI? What can be said about the value of a with respect to
the form of the plot?
Q1.9(b): Generate the following sequences and complete the table below by plotting the output
waveform at the XY Graph.10.Create the VI act04-01.vi which will generate x(n)= 0.8u(n 4)for 20 n < 20using thepreviously created Vis as subVIs.
Q1.10(a): Plo t th e sign al generated above.
Activity 4.2 The Convolution Sum.
1. Create the VI act04-02.vi. This VI will compute the convolution sum of two signals x(n)= au(n)and x(n)= u(n) u(n N)and plot the results, as well as the individual signals on an XY chart.2. Build the BD and FP as shown. The XY charts are configured in the same manner as those used in the
previous sub-activity. This VI also uses the previously created Vis as subVIs to generate the signals to be
convolved
-
8/9/2019 Activity 04
7/14
3.
Save and run the VI.
Q2.3(a): Discuss the function ality of the VI. Include in the discussions the meaning of th e variables
N, n1, n2, a, y and n .
Q2.3(b): Evaluate the convolution sum of each of the pairs of signals for using theVI. Complete the table below. Verify the values obtained by using alternate methods (manual
calculation or a spreadsheet can be used for this purpose).
4. Modify act04-02.vito compute for the convolution sum of the pairs of sequences given in the table
below. The code inside the MathScript node may be modified, and new subVIs generating a sinusoidal
signal can be created.
Q2.4(a): Complete the table below by p lotting the convolution sum of the following pairs of signalsfrom .Activity 4.3 The Difference Equation
1. The difference equation can be implemented in the MathScript node as the function f i l t er . Create
the VI act04-03_impresp.vi. This VI generates the impulse response of a difference equation defined by
coefficientsbanda. The parametersn1andn2determine the duration of the impulse response.
-
8/9/2019 Activity 04
8/14
The subVI delta(n) is the VI act04-01_delta.viwhich generates an impulse sequence whose
duration is between n1andn2.
The function f i l t er implements the difference equation by specifying the coefficients of y(n)
and its delayed versions in the vector aand coefficients of x(n)and its delayed versions in the
vector b. The vectorxcontains the vector of the input signal x(n).
The graph in the FP is an XY Graph which have the same configuration as before.
2. Save and run the VI. Plot the impulse response of the difference equation y(n) y(n 1) +0.9y(n 2) = x(n).Q3.2(a): Plot the impulse response of the above given difference equation for
.
What can be said about the causality and stability of th is system?
Q3.2(b): Determine the impulse response of the system using hand calculations. Then p lot the few
values of the impulse response. Does this agree with the one obtained from the VI?
3. Replicate the VI and name the new VI as act04-03_stepresp.vi . This will plot the step response of a
system described by a difference equation.
Q3.3(a):Using this VI, plot the step response of the system () ( ) +.( ) =()for . Determine an equation fo r the step response of the system using handcalculations and plot the few values.
Q3.3(b): Compare the form of impulse and step responses. Observe the value to which each
response approach to as the time index grows larger, and the value for which each of the inputsthat generated the responses approach as time index grows larger.
Course: Experiment No.:
Group No.: Section:
Group Members: Date Performed:
Date Submitted:
Instructor:
6. Data and Results:Q1.3(a): Generate the following sequences and plot the resulting waveform.
-
8/9/2019 Activity 04
9/14
(n)for20 n 20
(n 5)for20 n 20
(n+5)for20 n 20
Q1.5(a): What is the functionality of the VI?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.5(b): Complete the table below by plotting the output signal from the XY chart.
u(n)
for20 n 20
u(n 5)for20 n 20
-
8/9/2019 Activity 04
10/14
u(n+5)
for20 n 20
Q1.9(a): What is the functionality of the VI? What can be said about the value of a with respect to
the form of the plot?
_____________________________________________________________________________________
_____________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.9(b): Generate the following sequences and complete the table below by plotting the output
waveform at the XY Graph.
0.8for10 n 10
1for10 n 10
1.2for10 n 10
Q1.10(a): Plot th e signal generated above.
-
8/9/2019 Activity 04
11/14
Q2.3(a): Discuss the functionality of the VI. Include in the discuss ions the meaning o f th e variables
N, n1, n2, a, y and n.
__________________________________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.3(b): Evaluate the convolution sum of each of the pairs of signals for using theVI. Complete the table below. Verify the values obtained by using alternate methods (manual
calculation or a spreadsheet can be used for this purpose).
Pair Of Signals Convolution Sum Plot
x(n)= 0.9u(n)
x(n)= u(n) u(n 3)
(n)= 1.1u(n)
x(n)= u(n) u(n 5)
-
8/9/2019 Activity 04
12/14
Q2.4(a): Complete the table below by p lotting the convolution sum of the following pairs o f signals
from .(n)= n[u(n+10) u(n 20)], (n)= (1.2)[u(n + 5) u(n 10)]
(n)= n[u(n+10) u(n 20)], (n)= cos(0.1n)[u(n) u(n 30)]
Q3.2(a): Plot the impulse response of the above given difference equation for .What can be said about the causality and stability of th is system?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q3.2(b): Determine the impu lse response of the system using hand calculations. Then plot the few
values of the impulse response. Does this agree with the one obtained from the VI?
-
8/9/2019 Activity 04
13/14
Impulse Response:
Plot:
Q3.3(a):Using this VI, plot the step response of the system () ( ) +.( ) =()for . Determine an equation for the step response of the system us ing handcalculations and plo t the few values.
Step Response:
Plot:
Q3.3(b): Compare the form of impulse and step responses. Observe the value to which each
response approach to as the time index grows larger, and the value for which each of the inputs
that generated the responses approach as time index grows larger._____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
7. Conclusion:
-
8/9/2019 Activity 04
14/14
8. Assessment:1. Implement a system that will generate the autocorrelation and crosscorrelation of signals using the
MathScript node of LabVIEW. Apply this system to a practical signal.
2.A simple digital differentiator is given by
y(n)= x(n) x(n 1)
which computes a backward first-order difference of the input sequence. Implement this differentiator using
the MathScript node. Do the following:
Plot the impulse and step response of this system. Investigate the causality and stability of this
system.
Implement this differentiator on the following sequences and plot the results.
o
x(n)= 5[u(n) u(n 20)]; a rectangular pulseo
x(n)= n[u(n) u(n 10)] + (20 n)[u(n 10) u(n 20)]; a triangularpulse.
o
x(n)= sin [u(n) u(n 10)]; a sinusoidal pulse. Comment on the appropriateness of the differentiator based on the observations drawn from the
results obtained above.
Assessment rubric for the conduct of laboratory experiments
Performance Indicators 1 2 3 Points
Conduct experiments inaccordance with g ood andsafe laborato ry practice.
Members do not followgood and safe laboratorypractice in the conduct
of experiments.
Members follow goodand safe laboratory
practice most of the timein the conduct of
experiments.
Members follow goodand safe laboratory
practice at all times inthe conduct ofexperiments.
Operate equipment andinstruments with ease
Members are unable tooperate the equipment
and instruments.
Members are able tooperate equipment and
instrument withsupervision.
Members are able tooperate the equipmentand instruments with
ease and with minimumsupervision.
Analyze data, validate
experimental values againsttheoretical values todetermine possible
experimental errors, andprovide valid conc lusions.
The group hasincomplete data.
The group has completedata but has no analysis
and valid conclusion.
The group has complete
data, validatesexperimental valuesagainst theoretical
values, and providesvalid conclusion.
Total Score
Mean Score = (Total Score /3)
Percentage Score = (Total Score / 9) x 100%