Sunteți pe pagina 1din 11

DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

LAB # 5:
“DSP USING SIMULINK”

Simulink:
Simulink software models, simulates, and analyzes dynamic systems. With Simulink,
we can easily build models from scratch, or modify existing models to meet our
needs.

Simulink Block:

Commonly Used Commonly used blocks


Continuous Define continuous states
Discontinuities Define discontinuous states
Discrete Perform logic and bit operations
Logic and Bit Operations Define discrete states
Lookup Tables Support lookup tables
Math Operations Provide additional math and discrete
support
Model Verification Support custom functions
Model-Wide Utilities Input to other blocks
Ports & Subsystems Receive output from other blocks
Signal Attributes Support signal routing
Signal Routing Support signal attributes
Sinks Support ports and subsystems
Sources Support model-wide operations
User-Defined Functions Perform model verification
Additional Math & Discrete Perform math operations

WALEED BASHIR, 26 Page 1


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

TASK 1:

1. Use Simulink to simulate the system shown in Figure 1. The system is


composed of a sampled sine wave of unity amplitude, frequency f1 = 1
kHz, and initial phase shift of π/3 radians. The signal will be displayed on
the scope. Assume that the sampling frequency (fsamp) is10 kHz.

Sine Wave - Generate sine wave, Scope and Floating Scope - Display
using simulation time as time signals generated during
source simulation
Library Library
Sources Sinks
Description Description

The Scope block displays its input with


The Sine Wave block provides a sinusoid. respect to simulation time.
The block can operate in time-based or
sample-based mode.

COMMAND WINDOW:
>> f1=1000;
>> fsamp=10000;
>> Tsamp=1/fsamp;

MODEL WINDOW:

Sine Wave 1
Scope

The second figure demonstrates the


“Sine wave 1” parameters which
appear by double clicking on the Sine
Wave 1 block.

WALEED BASHIR, 26 Page 2


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

SCOPE:

Time on x axis is in milliseconds.

Conclusion:
The figure above shows a sine wave in time domain. The wave has changed
from its usual shape because of sampling time which is 1/10000 or 0.1 msec.
In the figure it can be seen that for every 0.1 ms the graph remain flat and
after 0.1 ms, it changes its level.

2. (a) If f1 = 1 kHz, simulate the system with a time equivalent to 5


periods of the sine wave. Display the waveform on the scope and also
export the data of the output to the Matlab workspace to plot the
amplitude (discrete-time versus time in (msec). Also, plot the amplitude
versus the time index, n.

 The model for part 1 can be used for this part also. The only difference is that
we have to change the Final time of the simulation according to the give time i.e.

WALEED BASHIR, 26 Page 3


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

5 periods. For 5 periods set the time to 5*T, where T is 1/1000 and hence final
time is 5/1000.

SCOPE:

The figure shows 5 periods of the wave from 0 to 5 ms.

 To import data go to scope and then go to


parameters.
 Assign variable name and apply. Now simulate
again. The variable will be saved to work space.
 To plot the samples, go to command window
and follow the following steps.

>> stem(d(:,1),d(:,2))

 Also set Format to Array.

WALEED BASHIR, 26 Page 4


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

Amplitude vs Time Index


5

2
Amplitude

-1

-2

-3

-4

-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time index -3
x 10

(b) Change the f1 to 21 kHz and investigate the output signal. Compare to
part (a) and comment.

WALEED BASHIR, 26 Page 5


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

-1

-2

-3

-4

-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
x 10

Result:
For f1 = 21 kHz. The Scope graph remains the same n “Amplitude vs. Time
index “graph is also same as was for 1 kHz f1. This shows that 1 kHz and 21
kHz signals are aliases of each other.

(c) What is the apparent frequency of the output if f1 = 9 kHz? Compare to


part a) and comment.

WALEED BASHIR, 26 Page 6


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

-1

-2

-3

-4

-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
x 10

Result:

It can be seen that the figure in part (c) is anti-alias of part (a) because the
signals are opposite of each other. The sample at 5 in figure of part (c) is at 0
of figure of part (a) and vice versa.

(d) For the above cases, give the digital frequencies and indicate if they have
aliases in the range 0 ≤ f ≤ 5 kHz.

TASK 2:

Consider the digital filter given by the


y(n) = 1.7654y(n - 1) – 0.81y(n - 2) + 2x(n) + x(n - 1)

WALEED BASHIR, 26 Page 7


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

(a) Using Simulink, assuming fsamp = 10 kHz, and a simulation time of 10msec, find
the step response.

Step - Generate step function Discrete Transfer Fcn - Implement


Library discrete transfer function
Sources Library
Description Discrete
Description

The Step block provides a step between


two definable levels at a specified time. The Discrete Transfer Fcn block
implements the z-transform transfer
function

 The equation in the question


becomes
y(n)=1.7654y(n-1) - 0.81y(n-2) + 2x(n) +
x(n-1)
y(n) - 1.7654y(n-1) + 0.81y(n-2) = 2x(n)
+ x(n-1)
Y(Z) [1-1.7654z-1+0.81z-2] = X(Z)[2+z-1]
Y(z) / X(z)= [2+z-1] / [1-1.7654z-1+0.81z-2]
 Use these values of numerators and denominators to set the parameters
of Discrete Filter as shown in the figure below.

2+z-1
1-1.7654 z -1+0.81 z -2

Step Discrete Filter Scope

 The figure on scope is as shown below.

WALEED BASHIR, 26 Page 8


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

NOTE: The time is in seconds. Also I have set final time to 60 sec. because after 70 sec
there is no change in amplitude and it remains same.

 The Amplitude vs time index plot is shown in the figure below.


Amplitude vs time index n
80

70

60

50
amplitude

40

30

20

10

0
0 10 20 30 40 50 60
Time index n

(b) Determine the steady-state value, Go. Hence, plot the transient response,
ytran. (Hint : Use the model shown in Figure 2.)
The value of Go can be observed from the graph.

WALEED BASHIR, 26 Page 9


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

(c) If the input is a pulse equivalent to x(n) = u(n) - u(n - 25), find the pulse
duration in
msec, and hence determine the pulse response.
(Hint: Use the model shown in Figure 3).

2+z -1
Step 1+1.7654 z-1+0.81 z -2

Discrete Filter Scope

Step 1

Command Window:

Time=b2(:,1);
Fsamp=10000;
n=Time*Fsamp;
step_resp=b2(:,2);
subplot(2,1,1);
stem(Time*1e4,step_resp);
grid on;
xlabel('Time in msec');
ylabel('Amplitude');
title('Step Response');
subplot(2,1,2);
stem(n,step_resp);
grid on;
xlabel('Time_index,n');
ylabel('Amplitude');

WALEED BASHIR, 26 Page 10


DESCRETE TIME SYSTEMS LAB REPORT December 14, 2010

Scope:

PulseResponse
100

50
Amplitude

-50
0 0.5 1 1.5 2 2.5 3 3.5
Timein msec 5
x 10
PulseResponseVs TimeIndex n
100

50
Amplitude

-50
0 0.5 1 1.5 2 2.5 3 3.5
Timeindex,n 5
x 10

WALEED BASHIR, 26 Page 11

S-ar putea să vă placă și