Professional Documents
Culture Documents
ملزمة سميولنك-ماتلاب النهرين
ملزمة سميولنك-ماتلاب النهرين
ملزمة سميولنك-ماتلاب النهرين
1 Communication Lab
Exp.1
Getting Started with MATLAB
Objectives: To be familiar with building communication systems using Simulink library and script,
make analysis and numerical or graphical outputs.
Procedure:
A- How to use Simulink model
There are 3 ways to write or draw a simulation system.
1. Press New Simulink model untitled
Fig. 1
Stop
Run
Simulink Library
Browser
Fig.2
Page1
Exp.1 Communication Lab
Fig. 3
2. Write commands in the MATLAB Command window
Example:
>>simulink press enter, the Simulink library will be shown. Drag & drop a block to
the model file.
>>commlib press enter after each command. This opens the communication block
set within main library.
3. Press Simulink library button in the main MATLAB Window, see Fig.4, is the easiest way to
get access and simulate a communication system.
Note: You can connect between blocks in the model by simply, positioning the pointer of the
mouse over the first block's output port and drag the pointer to the second block's input port.
Fig. 4
Page2
Exp.1 Communication Lab
Simulating this model integrates a sine wave signal to a cosine signal and then displays the result,
along with the original signal, in a scope window.
Page3
Exp.1 Communication Lab
2. In the Simulink Library Browser, select View > Stay on Top to keep the Library Browser on top
of the other windows on your desktop.
2. Search for a block. In the search box, enter a block name or part of a block name. For example,
enter sine, and then click the Search button .
3. Get detailed information about a block. Select the block, and then from the menu bar,
select Help > Help for the Selected Block. The Help browser opens with the reference page for
that block.
4. View block parameters. Right-click a block, and then select Block Parameters. The block
parameters dialog box opens.
Page4
Exp.1 Communication Lab
Page5
Exp.1 Communication Lab
3. Release the mouse button when the pointer is over the output port.
Page6
Exp.1 Communication Lab
Simulink connects the blocks with a line and an arrow indicating the direction of signal flow.
4. Connect the output port of the Integrator block to the bottom input port on the Bus block using
this alternative procedure:
a. Select the Integrator block.
b. Press and hold the Ctrl key.
c. Click the Bus block.
The Integrator block connects to the Bus block with a signal line.
Note: The Ctrl+click shortcut is useful when you are connecting widely separated blocks
or when working with complex models.
Connect the Bus block output port to the Scope block.
Page7
Exp.1 Communication Lab
3. Drag the cursor to the Integrator input port, and then release the mouse button.
4. Drag line segments to straighten and align with blocks. Your model is now complete.
Page8
Exp.1 Communication Lab
3. Click OK.
Run Simulation
After you define Model Configuration Parameters, you are ready to simulate your model.
1. From the Simulink Editor menu bar, select Simulation > Run.
The simulation runs, and then stops when it reaches the stop time specified in the Model
Configuration Parameters dialog box.
Tip Alternatively, you can control a simulation by clicking the Run simulation button
and Pause simulation button on the Simulink Editor toolbar.
2. From the Scope block toolbar, click the Parameters button . Select the Style tab. The Scope
Parameters dialog box displays figure editing options.
Page9
Exp.1 Communication Lab
3. Change the appearance of the figure. For example, select white for the Figure color and Axes
background color (icons with a pitcher) and black for the Ticks, labels and grid colors (icon with
a paintbrush). Change the signal line colors for signal 1 to blue and for signal 2 to green. To see
your changes, click OK.
4. Select File > Close > Close Model. The Simulink Editor closes with changes to your model and
the model configuration parameters.
Lab Work
1- Having sine block to obtain and draw cosine.
2- Apply the derivative on the output at the previous step. What is the output?
3- Apply the integral and derivative on the sine.
Page10
Exp.1 Communication Lab
t=(0:1/100:1); %time
f=1; %freq. f = 1/T
z=sin(2*pi*f*t); % pi = 180
plot(t,z); % To plot x-axis and y-axis
grid on;
Lab Work
1- Draw the cosine.
2- Use subplot(2,1,1) to sketch the sine and cosine at the same figure.
Page11
Exp.1 Communication Lab
Page12
Exp.2 Communications Lab
Exp.2
Mathematical Operations with Simulink
Objectives: The objective of this lab is to perform some mathematical operations using Simulink
models. Also, observing the signals outputs using logging and recording features.
Procedure:
A)
1. Connect the block diagram shown in Figure 1.
2. Set the Gain blocks as: Gain1=3; Gain2=2; and the Sine Wave1 block as: f =100 Hz.
3. Plot the output Signals and compare between the two types.
4. Adjust the parameters of the Sine Wave2 so that the output signals are identical in terms of
both frequency and amplitude. (You may use x-axes zoom to display outputs properly)
5. Verify the frequency parameter you set by comparing it with the frequency output.
B)
Page1
Exp.2 Communications Lab
Page2
Exp.2 Communications Lab
C)
1. Connect the block diagram shown in the figure below.
2. After setting sample time in impulse1 at 3 , and impulse2 at 1, find the output.
Page3
Exp.2 Communications Lab
Tasks:
5. Having Discrete Impulse, Find the block diagram for the following output (3 M)
Page4
Exp.3 Wireless Communications Lab
Exp.3
Spectrum Representation and Mathematical Operations
Procedure:
A)
1. The spectrum (frequency representaion) of sinusoidal signals is given as follow:
Page1
Exp.3 Wireless Communications Lab
Example:
Page2
Exp.3 Wireless Communications Lab
3. Now, model the figure 1, and set the frequencies to 100, 200, 300 Hz; amplitudes to 1, 0.5,
0.25 and the sample time at 0.001s. show the spectrum before and after the addition
operation.
2. Set the Gain blocks as: Gain1=3; Gain2=2; and the Sine Wave1 block as: f =100 Hz.
3. Plot the output signals and compare between the two types.
4. Adjust the parameters of the Sine Wave2 so that the output signals are identical in terms of
both frequency and amplitude. (You may use x-axes zoom to display outputs properly)
5. Show the spectrum of the figure shown above.
Tasks:
Give an example in how to use fft block to find the spectrum of signal.
Page3
Exp.4 Wireless Communications Lab
Exp.4
Amplitude Modulation AM
Objectives:
The goal of this lab is to explore amplitude modulation AM and demodulation. Two
amplitude modulation schemes are simulated: double side band suppressed carrier
(DSB-SC) , DSB-LC and single side band (SSB).
Theory:
Modulation is defined as the process by which a property of a signal is varied in
proportion to a second signal. Amplitude modulation is characterized by the fact that
the amplitude of a carrier is varied in proportion to the baseband (message) signal, the
modulating signal.
Refer to your lecture notes for the theoretical part for further details in terms of
modulation and demodulation techniques.
Procedure:
Page1
Exp.4 Wireless Communications Lab
Task 1:
a) Calculate the frequency and the no. of samples/cycle of the modulated signal from
the output plot.
b) From the spectrum analyzer, find the bandwidth and sketch (single-sided band)
both the modulating and modulated signals with their values.
Page2
Exp.4 Wireless Communications Lab
Task 2:
From the spectrum analyzer, find the bandwidth and sketch both the modulating and
modulated signals with their values.
Page3
Exp.4 Wireless Communications Lab
Page4
Exp.4 Wireless Communications Lab
Task 3:
Consider the following:
Input signal: 4 sin 𝜋 𝑡
Carrier signal: cos 60 𝜋 𝑡
LPF: 4 order, cutoff frequency = carrier frequency
Signal offset: 1
Modulate the signals shown above using the DSB-LC and sketch the
frequency response for modulating and modulated signals.
Page5
Exp.5 Wireless Communications Lab
Exp.5
Additive White Gaussian Noise AWGN
Objectives:
The objective of this lab is to simulate noisy channel using Gaussian uniform distribution.
Simulink is used to model the system.
Theory:
Signal to Noise Ratio SNR
Signal-to-noise ratio (abbreviated SNR or S/N) is a measure used in science and engineering that
compares the level of a desired signal to the level of background noise. SNR is defined as the ratio of
signal power to the noise power, often expressed in decibels. A ratio higher than 1:1 (greater than 0
dB) indicates more signal than noise.
or
SNR is not actually a ratio but the difference in decibels between the received signal and the
background noise level (noise floor). For example, if a radio (client device) receives a signal of
-75 dBm and the noise floor is measured at -90 dBm, the SNR is 15 dB. Data corruption and
therefore re-transmissions will occur if the received signal is too close to the noise floor.
Page1
Exp.5 Wireless Communications Lab
- Symbol period
• Signal to noise ratio (SNR), where the block calculates the variance from these quantities
that you specify in the dialog box:
- SNR, the ratio of signal power to noise power
- Input signal power, the actual power of the samples at the input of the block
where
Es = Signal energy (Joules)
Eb = Bit energy (Joules)
N0 = Noise power spectral density (Watts/Hz)
Tsym is the Symbol period parameter of the block in Es/No mode
k is the number of information bits per input symbol
Tsamp is the inherited sample time of the block, in seconds
For real signal inputs, the AWGN Channel block relates Es/N0 and SNR according to the
following equation:
Note that the equation for the real case differs from the corresponding equation for the complex
case by a factor of 2. This is so because the block uses a noise power spectral density of N0/2
Watts/Hz for real input signals, versus N0 Watts/Hz for complex signals.
In our lab, we will deal with real input signals.
Procedure:
1. Open a new model and add to it each of one AWGN Channel block, one discrete Sine Wave
block, one Scope and two Spectrum Analyzer blocks (found at DSP System Toolbox/Sinks)
2. Apply the discrete sine wave signal to the AWGN channel
3. Set the signal amplitude as 1 volt, frequency as 100 Hz and 1ms as sample time.
4. Set the AWGN channel mode to signal to noise ratio (SNR) and the input signal power to
1 Watt.
5. Plot the signals before and after adding the noise by using:
- The scope (with two inputs) to display signals in time domain
- The spectrum analyzers to display signals in frequency domain
Page3
Exp.5 Wireless Communications Lab
6. Change the SNR of AWGN channel in the range of (-30 to 120) dB in steps of 30 dB.
7. In time and frequency domain, draw the input signal once and the output signal in each step
change.
8. Let the SNR stick at 10 dB and adjust the amplitude of input signal as 1, 5 then 25 and
notice the change in time domain, draw the three output signals simultaneously using
Simulation Data Inspector by recording the output.
Tasks:
Page4
Exp.6 Wireless Communications Lab
Exp.6
Frequency Division Multiplexing
Objectives:
The goal of this lab is to simulate frequency division multiplexing (FDM) system.
Theory:
FDM is a mode of transmission by which several signals may be send simultaneously
by positioning their spectra such that each signal spectrum can be separated out from all
others by filtering.
Theory:
Page1
Exp.6 Wireless Communications Lab
At the receiving end, the signal is applied to a bank of band-pass filters, which separates
individual frequency channels. The band pass filter outputs are then demodulated and
distributed to different output channels as shown in Figure 3. If the channels are very
close to one other, it leads to inter-channel cross talk. Channels must be separated by
strips of unused bandwidth to prevent inter-channel cross talk. These unused channels
between each successive channel are known as guard bands. FDM are commonly used
in radio broadcasts and TV networks. Since, the frequency band used for voice
transmission in a telephone network is 4000 Hz, for a particular cable of 48 KHz
bandwidth, in the 70 to 108 KHz range, twelve separate 4 KHz sub channels could be
Page2
Exp.6 Wireless Communications Lab
used for transmitting twelve different messages simultaneously. Each radio and TV
station, in a certain broadcast area, is allotted a specific broadcast frequency, so that
independent channels can be sent simultaneously in different broadcast area. For
example, the AM radio uses 540 to 1600 KHz frequency bands while the FM radio uses
88 to 108 MHz frequency bands.
Procedure:
1. Consider the two following discrete sine wave messages: -
𝑚1(𝑡) = 2 𝑆𝑖𝑛 20 𝜋 𝑡
𝑚2(𝑡) = 2 𝑆𝑖𝑛 40 𝜋 𝑡
2. Modulate the two signals using AM-DSBSC modulator: the first signal with a
subcarrier frequency of 50 Hz and the second signal with 100 Hz.
3. Add the two modulated signals using adder block.
4. Plot the spectrum of the modulated signals for m1(t), m2(t) and added signal.
5. Modulate the signal output from adder block using AM-DSBSC modulator with a
main-carrier frequency of 300 Hz and plot the spectrum of output signal.
Tasks:
Page3
Exp.7 Communications Lab
Exp.7
Frequency Modulation FM
Objectives:
The goal of this lab is to model Frequency modulation and demodulation using Matlab
Simulink. The behavior of the modulated FM signal will be investigated in terms of frequency
deviations for different message baseband signal types.
Theory:
The Frequency modulation is a modulation scheme in which the carrier varies in accordance
with the change in the message baseband signal.
For more theoretical details of the FM generation and demodulation techniques, refer to your
lecture notes of Communication Systems module.
Procedure:
A)
1. Create a new Simulink model to simulate the frequency modulation and demodulation.
2. Use FM Modulator and Demodulator blocks with the following parameters:
FM Modulator FM Demodulator
• Carrier Frequency: 35 Hz • Carrier Frequency: 35 Hz
• Initial phase: 0 • Initial phase: 0
• Frequency Deviation: 10 Hz • Frequency Deviation: 10 Hz
• Hilbert transform filter order: 100
3. Use signal generator to feed the FM modulator with a sinewave message signal with
amplitude of 0.5 and frequency of 5 Hz. The message should be discretized at sampling
rate of 0.002 sec before being fed to the modulator.
4. Use two spectrum analyzers to show the FM modulated and demodulated signals in
frequency domain.
5. Use one scope with four axes to show each of the message, carrier, modulated and
demodulated signals in time domain.
6. Verify the frequency of the message and carrier from the plots.
7. Calculate the number of samples/cycle in the carrier signal by pen and paper, then
verity it from the time domain plot.
Page1
Exp.7 Communications Lab
Task 1: Calculate the frequencies that appear in the modulated signal and verify them from
the spectrum.
B)
1. Change the message signal type to a square wave with amplitude of 0.5 and frequency
of 5 Hz.
Task 2:
2. Keep the rest of model parameters as they are except changing one single parameter to
show the modulated signal with a minimum frequency appears at 20 Hz.
3. Plot all signals in time and frequency domains.
Task 3: How can you make the bandwidth limited to maximum frequency at 40 Hz, select an
appropriate parameter and plot the spectrum.
Page2
Exp.8 Communications Lab
Exp.8
Analogue to Digital Converter ADC
Theory:
A digital system can be implemented as a combination of digital hardware and software,
each of which performs its own set of specified operations.
Page1
Exp.8 Communications Lab
A) Sampling stage
Clearly we have two sinusoids whose samples are identical and so the ADC will not
be able to distinguish one from the other. What sinusoid do you think will actually
be reconstructed at the DAC from the samples? Why do we call the second example
ALIASING?
Hence, we apply Nyquist Theorem (fs ≥ 2fmax) to avoid Aliasing.
Page2
Exp.8 Communications Lab
Page3
Exp.8 Communications Lab
Procedure:
A)
1. Connect the block diagram shown in the figure below.
B)
To easily noticing the change in output while changing some parameters, we remove the To
Workspace blocks from the models (as below), then we do signals logging and recording as
follow:
Page4
Exp.8 Communications Lab
Tasks:
1. Model the figure in procedure (A), and set the quantization interval to 0.5. Add
an appropriate block to the model to simulate the quantization error (noise).
2. Model the quantization of (5 Sin 4𝜋) using three levels only, then calculate and
graph the quantization error.
Page5
Exp.9 Communications Systems Lab
Exp.9
Digital Modulation
Objectives:
The goal of this lab is to simulate digital modulation mechanisms namely FSK, ASK
and PSK using Simulink MATLAB.
Theory:
Digital-to-analog conversion is the process of changing one of the characteristics of an
analog signal based on the information in digital data. The figure below shows the
relationship between the digital information, the digital-to-analog modulating process,
and the resultant analog signal.
A sine wave is defined by three characteristics: amplitude, frequency, and phase. When
we vary any one of these characteristics, we create a different version of that wave. So,
by changing one characteristic of a simple electric signal, we can use it to represent
digital data. Any of the three characteristics can be altered in this way, giving us at least
three mechanisms for modulating digital data into an analog signal: amplitude shift
keying (ASK), frequency shift keying (FSK), and phase shift keying (PSK). In
addition, there is a fourth (and better) mechanism that combines changing both the
amplitude and phase, called quadrature amplitude modulation (QAM). QAM is the
most efficient of these options and is the mechanism commonly used today.
Page1
Exp.9 Communications Systems Lab
where N is the data rate (bps) and r is the number of data elements carried in one signal
element. The value of r in analog transmission is r = log2 L, where L is the number of
different signal elements. The same nomenclature is used to simplify the comparisons.
An analogy is used to demonstrate the bit rate and baud rate. In transportation, a baud
is analogous to a vehicle, and a bit is analogous to a passenger. We need to maximize
the number of people per car to reduce the traffic.
Example:
An analog signal carries 4 bits per signal element. If 1000 signal elements are sent per
second, find the bit rate.
Solution
In this case, r = 4, S = 1000, and N is unknown. We can find the value of N from
Page2
Exp.9 Communications Systems Lab
ASK
In amplitude shift keying, the amplitude of the carrier signal is varied to create signal
elements. Both frequency and phase remain constant while the amplitude changes.
FSK
In frequency shift keying, the frequency of the carrier signal is varied to represent
data. The frequency of the modulated signal is constant for the duration of one signal
element, but changes for the next signal element if the data element changes. Both
peak amplitude and phase remain constant for all signal elements.
PSK
In phase shift keying, the phase of the carrier is varied to represent two or more different
signal elements. Both peak amplitude and frequency remain constant as the phase
changes. Today, PSK is more common than ASK or FSK. However, QAM, which
combines ASK and PSK, is the dominant method of digital-to-analog modulation.
Page3
Exp.9 Communications Systems Lab
Procedure:
A) ASK
1. Use Simulink to model the system as below to apply ASK modulation scheme.
2. The Sine Wave block represents the carrier signal with (amp.=1; freq.=2Hz; Ts=0.01).
3. The Pulse Generator represents the message digital signal with (amp.=1; period=2sec;
pulse width=50%).
4. Draw the outputs simultaneously (message, carrier, modulated signals).
B) PSK
1. Re-model the system above but now to simulate PSK modulation scheme.
2. Plot the output signals simultaneously.
Page4
Exp.9 Communications Systems Lab
C) FSK
2. Sine Wave3 represents the carrier signal with frequency (𝑓𝑐 = 10 𝐻𝑧)
3. In the FSK signal, we have two frequencies:
- 𝑓1 = 𝑓𝑐 + ∆𝑓 (the higher frequency at digital 1)
- 𝑓0 = 𝑓𝑐 − ∆𝑓 (the lower frequency at digital 0)
where 𝑓𝑐 is the carrier frequency, ∆𝑓 is the frequency deviation,
4. Use ∆𝑓 = 4 𝐻𝑧 to be applied to calculate 𝑓1 and 𝑓0, then set them in the Sine Wave1
and Sine Wave2 blocks in the model above.
5. Draw all output signals simultaneously.
Tasks:
1. Compare between ASK, FSK and PSK in terms of bandwidth usage.
2. We used in the lab BPSK. Why is it called so? is there other types of PSK?
compare between them briefly.
3. We implemented PSK in procedure (B) using a digital message as
(10101010....etc.). Reform the message signal to show the PSK output responds
to (1001 1001 1001 ...etc.)
4. We applied FSK in procedure (C) using direct values of 𝑓1 and 𝑓0 set in the blocks.
Now, re-build the model again to implement FSK modulation scheme but using
Product block, i.e. the carrier signal is multiplied by something to produce two
frequencies in the output as FSK signal.
Page5