Uploaded by ravikumar rayala

MASK-matlab code

advertisement
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
≡ MENU
My blog
MASK Modulation And Demodulation-Complete Matlab
Code With Explanation
by ADMIN
Binary Amplitude Shift Keying
Amplitude Shift Keying (ASK) is a type of digital modulation in which the amplitude of the
Tweet
Save
1 of 12
carrier is varied with respect to the digital message. If we send one bit/symbol, we call it as
Binary Amplitude Shift Keying (BASK), in which case the carrier amplitude is assumed to
have 2 values (one corresponding to 1 and other corresponding to 0). Figure below shows this
type of modulation.
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
2 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
This type of BASK is also called On-Off Keying (OOK) when one state is represented
by absence of the carrier (0 amplitude), the corresponding constellation diagram is shown in
Figure below, in which a signal is either present or absent.
A rather general case is shown in Figure below.
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
3 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
And the constellation Diagram is shown as:
Bit rate represents the No. of bits/sec whereas baud rate represents the No. of symbols sent
per second. Baud rate is less than or equal to the bit rate. Modulated symbol waveform are
represented as:
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
4 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
Multiple Amplitude Shift Keying
Multiple Amplitude Shift Keying (MASK) refers to the modulation technique in which M
different symbols are transmitted. Each of these symbols represents m bits of data where,
and the corresponding value of m is calculated as,
A MASK modulated carrier may in general look like,
Basis Function Representation of MASK
Any MASK symbol can be assumed as a function and can be represented in terms of one basis
function Ψ1(t). The basis function is given by,
The corresponding MASK symbols are:
Different symbols are differentiated from each other based on the value of Ek, as the phase
and frequency of the carrier remain same. Each symbol corresponds to a unique carrier
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
5 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
amplitude. The resulting Constellation diagram of MASK signal is shown as:
Here is the example of 4-ASK signal
MASK Modulation
A bit sequence is first converted to symbols, by a source encoder, based on the modulation
scheme (value of M). For M=8, we would be sending three bits per symbol. There would be 8
symbols (waveforms) having 8 different amplitude levels corresponding to each 000, 001,
010, 011, 100, 101, 110, 111. Similarly for M=16; there will be 16 different
waveforms corresponding to 0000 through 1111. This mapping of m bits to M voltage levels is
achieved by the Pulse Amplitude Modulator Modulation (PAM) block. This simulation
of MASK uses M=4 i.e., we are using 4-ASK signal. Here, we are sending 2 bits per symbol
and each of two bits can be mapped to any of 4 possible voltage levels. ’00’ bits is mapped to 0
volts, ’01’ bits is mapped to 1 volts, ’10’ bits is mapped to 2 volts, and ’11’ is mapped to 3 volts.
Then the signal is modulated by multiplying it with basis function.
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
6 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
MASK Demodulation
We employ a coherent MASK demodulator. We assume that we have perfect phase
information at the receiver for the sake of the simplicity. First the received signal is multiplied
with the carrier (orthonormal basis function). Then the signal is integrated over T symbol
duration T and sampled. After that the euclidean distance of this sample with all the possible
PAM voltage levels (4 voltage levels in case of 4-ASK, as on the transmitter side) is calculated.
And we choose the PAM voltage level having minimum euclidean distance. Then reverse
mapping of that PAM voltage levels to bits is done.
Matlab Code
The matlab code for modulation and demodulation of MASK (4ASK) is given below:
1
2
3
4
5
6
7
8
9
10
11
12
13
%_____________MASK Modulation and Demodulation Code________
clear all;
close all;
Nb=5;
Rb=1; %bps
T=1/Rb;
% Generate Nb bits randomly
%b =rand(1,Nb)>0.5;
b =[1 1 0 1 0 0 1 0 1 1];
%Rb is the bit rate in bits/second
bit_to_symbol=[];
for i=1:2:size(b,2)
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
7 of 12
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
a = [b(i) b(i+1)]
x = binaryVectorToDecimal(a)
switch(x)
case [0]
bit_to_symbol=[bit_to_symbol
case [1]
bit_to_symbol=[bit_to_symbol
case [2]
bit_to_symbol=[bit_to_symbol
case [3]
bit_to_symbol=[bit_to_symbol
end
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
0];
1];
2];
3];
end
NRZ_out=[];
RZ_out=[];
Manchester_out=[];
Vp=1;
for index=1:size(bit_to_symbol,2)
NRZ_out=[NRZ_out ones(1,200)*bit_to_symbol(index)];
end
figure;
stem(b, 'filled');
xlabel('Sequence Number')
ylabel ('Transmitted Bits [0/1]')
ylim ([0 2])
figure;
plot(NRZ_out, 'b', 'Linewidth', 2);
xlabel ('Time')
ylabel ('NRZ output')
ylim ([0 4])
grid on
t=0.005:0.005:5;
f=5;
Modulated=NRZ_out.*(sqrt(2/T)*sin(2*pi*f*t));
figure;
plot(Modulated);
xlabel ('Time')
ylabel ('Modulated Carrier')
ylim ([-6 6])
y=[];
received=[];
demodulated=Modulated.*(sqrt(2/T)*sin(2*pi*f*t));
for i=1:200:size(demodulated,2)
y=[y trapz(t(i:i+199),demodulated(i:i+199))];
end
for (i=1:1:size(y,2))
euclidean_dist=sqrt((y(i)-[0 1 2 3]).^2);
[val index]=min(euclidean_dist)
temp = [0 1 2 3];
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
8 of 12
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
index = temp (index);
switch(index)
case 0
received=[received 0 0];
case 1
received=[received 0 1];
case 2
received=[received 1 0];
case 3
received=[received 1 1];
end
end
%received=y>0;
figure;
stem(received,'filled', 'm')
xlabel('Sequence Number')
ylabel ('Received Bits [0/1]')
ylim ([0 2])
Bits To Be transmitted
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
9 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
Generated PAM Signals
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
10 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
Modulated 4 ASK Signal
Bits Received
Credit: Muhammad Adil helped me prepare this post.
{ 1 comment… add one }
Asim Zahid
November 20, 2018, 7:43 pm
I tried to understand but it didn’t helped me, theory was good but code is out of
reach of understanding capacity of my mind.
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
11 of 12
REPLY
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
LINK
Leave a Comment
Name
Email
Website
Comment
Submit
Notify me of follow-up comments by email.
Notify me of new posts by email.
Next post: Binary Frequency Shift Keying (BFSK) Modulation And Demodulation-Matlab
Code With Explanation
Previous post: BPSK Modulation And Demodulation- Complete Matlab Code With
Explanation
11-02-2020, 21:47
MASK Modulation And Demodulation-Complete Matlab Code With Ex...
12 of 12
https://drmoazzam.com/mask-modulation-and-demodulation-complete-m...
Moazzam Islam Tiwana received his M.A.Sc. degree in Digital Telecommunication Systems from ENST, Paris,
France in 2007 and a Ph.D. degree in Mobile Communications from Telecom SudParis Paris, France, in 2010. His
PHD work was with the R&D Group of Orange Labs of France Telecom. He has more than 10 years of industrial and
academic experience.
This site rocks the Classic Responsive Skin for Thesis.
WP Admin
11-02-2020, 21:47
Download