You are on page 1of 40

105

25/09/2012
Nguy n c Nhn
M ph ng tn hi u bng g c v thng d i:
Tn hi u bng g c (baseband): c ph t n t p trung quanh t n
s 0.
Tn hi u thng d i (passband): c ph t n t p trung quanh m t
t n s sng mang f
c
.
M ph ng tn hi u bng g c v thng d i:
Tn hi u bng g c (baseband): c ph t n t p trung quanh t n
s 0.
Tn hi u thng d i (passband): c ph t n t p trung quanh m t
t n s sng mang f
c
.
Tn hi u bng g c c th c chuy n i
thnh tn hi u thng d i qua qu trnh i
t n ln (up-conversion)
Tn hi u thng d i c th c chuy n i
thnh tn hi u bng g c qua qu trnh i
t n xu ng (down-conversion)
Tn hi u thng d i s
P
(t) c xy d ng t
hai tn hi u bng g c s
I
(t) v s
Q
(t) (trong
i u ch s )
25/09/2012
Nguy n c Nhn
106
M ph ng tn hi u bng g c v thng d i:
Tn hi u bng g c (baseband): c ph t n t p trung quanh t n
s 0.
Tn hi u thng d i (passband): c ph t n t p trung quanh m t
t n s sng mang f
c
.
Tn hi u bng g c c th c chuy n i
thnh tn hi u thng d i qua qu trnh i
t n ln (up-conversion)
Tn hi u thng d i c th c chuy n i
thnh tn hi u bng g c qua qu trnh i
t n xu ng (down-conversion)
Tn hi u thng d i s
P
(t) c xy d ng t
hai tn hi u bng g c s
I
(t) v s
Q
(t) (trong
i u ch s )
M ph ng tn hi u bng g c v thng d i:
Tn hi u thng d i c th c vi t:
nh ngha tn hi u s(t): tn hi u
s
P
(t) c th vi t l i
Tn hi u s(t):
c g i l tn hi u t ng ng bng g c ho c l p v ph c c a tn hi u
thng d i s
P
(t)
Ch a cng thng tin nh s
P
(t)
s(t) l tn hi u ph c
M ph ng tn hi u bng g c v thng d i:
Tn hi u thng d i c th c vi t:
nh ngha tn hi u s(t): tn hi u
s
P
(t) c th vi t l i
Tn hi u s(t):
c g i l tn hi u t ng ng bng g c ho c l p v ph c c a tn hi u
thng d i s
P
(t)
Ch a cng thng tin nh s
P
(t)
s(t) l tn hi u ph c
25/09/2012
Nguy n c Nhn
107
M ph ng tn hi u bng g c v thng d i:
Tn hi u thng d i c th c vi t:
nh ngha tn hi u s(t): tn hi u
s
P
(t) c th vi t l i
Tn hi u s(t):
c g i l tn hi u t ng ng bng g c ho c l p v ph c c a tn hi u
thng d i s
P
(t)
Ch a cng thng tin nh s
P
(t)
s(t) l tn hi u ph c
M ph ng tn hi u bng g c v thng d i:
Trong mi n t n s :
H s m b o c hai lo i tn hi u c cng m c cng su t.
M ph ng tn hi u bng g c v thng d i:
Trong mi n t n s :
H s m b o c hai lo i tn hi u c cng m c cng su t. 2
25/09/2012
Nguy n c Nhn
108
M ph ng tn hi u bng g c v thng d i:
M hnh thng d i:
M ph ng tn hi u bng g c v thng d i:
M hnh thng d i:
25/09/2012
Nguy n c Nhn
109
M ph ng tn hi u bng g c v thng d i:
M hnh t ng ng thng th p:
M ph ng tn hi u bng g c v thng d i:
M hnh t ng ng thng th p:
Thu c h th ng t ng ng bng g c:
s d ng cc tn hi u bng g c
Tn hi u pht t ng ng bng g c:
Knh t ng ng bng g c v i p ng xung kim
gi tr ph c h(t) v i
Tn hi u thu t ng ng bng g c: R(t)
Nhi u Gaussian c ng gi tr ph c: N(t)
25/09/2012
Nguy n c Nhn
110
Thu c h th ng t ng ng bng g c:
s d ng cc tn hi u bng g c
Tn hi u pht t ng ng bng g c:
Knh t ng ng bng g c v i p ng xung kim
gi tr ph c h(t) v i
Tn hi u thu t ng ng bng g c: R(t)
Nhi u Gaussian c ng gi tr ph c: N(t)
M ph ng tn hi u bng g c v thng d i:
M hnh thng d i:
Cc tn hi u l th c
St v i h th ng th c
T n s l y m u cao h n
M hnh t ng ng thng th p:
Cc tn hi u l ph c
M hnh g n v n gi n h n
T n s l y m u th p h n
Trong cc tr ng h p th c t , x l tn hi u s c th c hi n trn tn hi u
c chuy n i bng g c.
M hnh t ng ng bng g c l thu n ti n h n trong m
ph ng h th ng.
H th ng tuy n tnh:
M ph ng tn hi u bng g c v thng d i:
M hnh thng d i:
Cc tn hi u l th c
St v i h th ng th c
T n s l y m u cao h n
M hnh t ng ng thng th p:
Cc tn hi u l ph c
M hnh g n v n gi n h n
T n s l y m u th p h n
Trong cc tr ng h p th c t , x l tn hi u s c th c hi n trn tn hi u
c chuy n i bng g c.
M hnh t ng ng bng g c l thu n ti n h n trong m
ph ng h th ng.
H th ng tuy n tnh:
25/09/2012
Nguy n c Nhn
111
M ph ng tn hi u bng g c v thng d i:
M hnh thng d i:
Cc tn hi u l th c
St v i h th ng th c
T n s l y m u cao h n
M hnh t ng ng thng th p:
Cc tn hi u l ph c
M hnh g n v n gi n h n
T n s l y m u th p h n
Trong cc tr ng h p th c t , x l tn hi u s c th c hi n trn tn hi u
c chuy n i bng g c.
M hnh t ng ng bng g c l thu n ti n h n trong m
ph ng h th ng.
H th ng tuy n tnh:
Qu trnh l y m u v n i suy:
Trong m ph ng h th ng truy n tin trn h th ng my tnh s
i h i s chuy n i m hnh th i gian lin t c thnh m hnh
r i r c v th i gian.
Theo nh l l y m u Nyquist (ho c Shannon): n u B
s
l r ng
bng t n c a tn hi u bng g c s(t) t n s l y m u f
s
> 2B
s
.
Qu trnh l y m u: s(t) s
s
(t) = s(nT
s
)
v i
trong : T
s
chu k l y m u, f
s
= 1/T
s
t n s l y m u
T n s l y m u c l a ch n ph h p gi m thi u l i ch ng
ph m trnh tng th i gian m ph ng.
Qu trnh l y m u v n i suy:
Trong m ph ng h th ng truy n tin trn h th ng my tnh s
i h i s chuy n i m hnh th i gian lin t c thnh m hnh
r i r c v th i gian.
Theo nh l l y m u Nyquist (ho c Shannon): n u B
s
l r ng
bng t n c a tn hi u bng g c s(t) t n s l y m u f
s
> 2B
s
.
Qu trnh l y m u: s(t) s
s
(t) = s(nT
s
)
v i
trong : T
s
chu k l y m u, f
s
= 1/T
s
t n s l y m u
T n s l y m u c l a ch n ph h p gi m thi u l i ch ng
ph m trnh tng th i gian m ph ng.
( ) ( ) ( )
s
s t s t p t =
( ) ( )
s
n
p t t nT

=
=

( ) ( ) ( )
s s s
n
s t s nT t nT

=
=

25/09/2012
Nguy n c Nhn
112
Qu trnh l y m u v n i suy:
Trong m ph ng h th ng truy n tin trn h th ng my tnh s
i h i s chuy n i m hnh th i gian lin t c thnh m hnh
r i r c v th i gian.
Theo nh l l y m u Nyquist (ho c Shannon): n u B
s
l r ng
bng t n c a tn hi u bng g c s(t) t n s l y m u f
s
> 2B
s
.
Qu trnh l y m u: s(t) s
s
(t) = s(nT
s
)
v i
trong : T
s
chu k l y m u, f
s
= 1/T
s
t n s l y m u
T n s l y m u c l a ch n ph h p gi m thi u l i ch ng
ph m trnh tng th i gian m ph ng.
Qu trnh l y m u v n i suy:
Trong m t s tr ng h p m ph ng h th ng trn cc r ng
bng t n khc nhau chuy n i t c m u
Tng m u (upsampling): t i bin gi a ph n tn hi u bng h p v bng r ng
s(kT
s
) s(kT
u
) = s(kT
s
/M)
Gi m m u (downsampling): t i bin gi a ph n tn hi u bng r ng v bng
h p s(kT
s
) s(kT
d
) = s(kMT
s
)
Qu trnh n i suy: quan tr ng trong k thu t a t c
B n i suy hm sinc
B n i suy tuy n tnh
Trong MATLAB s d ng hm interp:
y = interp(x,r) th c hi n l y l i m u gi tr trong vect x t i r
l n t c l y m u ban u.
Qu trnh l y m u v n i suy:
Trong m t s tr ng h p m ph ng h th ng trn cc r ng
bng t n khc nhau chuy n i t c m u
Tng m u (upsampling): t i bin gi a ph n tn hi u bng h p v bng r ng
s(kT
s
) s(kT
u
) = s(kT
s
/M)
Gi m m u (downsampling): t i bin gi a ph n tn hi u bng r ng v bng
h p s(kT
s
) s(kT
d
) = s(kMT
s
)
Qu trnh n i suy: quan tr ng trong k thu t a t c
B n i suy hm sinc
B n i suy tuy n tnh
Trong MATLAB s d ng hm interp:
y = interp(x,r) th c hi n l y l i m u gi tr trong vect x t i r
l n t c l y m u ban u.
25/09/2012
Nguy n c Nhn
113
Qu trnh l y m u v n i suy:
Trong m t s tr ng h p m ph ng h th ng trn cc r ng
bng t n khc nhau chuy n i t c m u
Tng m u (upsampling): t i bin gi a ph n tn hi u bng h p v bng r ng
s(kT
s
) s(kT
u
) = s(kT
s
/M)
Gi m m u (downsampling): t i bin gi a ph n tn hi u bng r ng v bng
h p s(kT
s
) s(kT
d
) = s(kMT
s
)
Qu trnh n i suy: quan tr ng trong k thu t a t c
B n i suy hm sinc
B n i suy tuy n tnh
Trong MATLAB s d ng hm interp:
y = interp(x,r) th c hi n l y l i m u gi tr trong vect x t i r
l n t c l y m u ban u.
Ngu n tn hi u t ng t :
Tn hi u n t n:
ho c
Tn hi u a t n: v i
0
( ) cos(2 )
k k
x t A f t = + 0
( ) exp(2 / )exp( )
s
x k A jkf f j =
Ngu n tn hi u t ng t :
Tn hi u n t n:
ho c
Tn hi u a t n: v i
0
( ) cos(2 )
k k
x t A f t = + 0
( ) exp(2 / )exp( )
s
x k A jkf f j =
1
( ) ( )
M
k n k
n
x t x t
=
=

( ) cos(2 )
n k n n k n
x t A f t = +
1
( ) exp(2 / )exp( )
M
n n s n
n
x k A jkf f j
=
=

25/09/2012
Nguy n c Nhn
114
Ngu n tn hi u t ng t :
Tn hi u n t n:
ho c
Tn hi u a t n: v i
Ngu n tn hi u s :
Ngu n thng tin r i r c th ng c gi tr trong b ng alphabet.
Tn hi u s : l d ng sng mang thng tin s .
C 3 tham s chnh:
Ki u ngu n (alphabet): danh sch cc k hi u thng tin c th m ngu n t o
ra.
VD: A = {0,1}; cc k hi u c g i l bit
V i M k hi u (M = 2
n
): A = {0, 1,..., M-1} ho c A = {1, 3, ..., (M-1)}
Cc symbol c th c gi tr ph c: A = {1, j}
Xc su t u tin pht: t n s xu t hi n t ng i c a m i k hi u m ngu n
t o ra.
VD: ngu n sinh ra cc bt 0 v 1 c xc su t bng nhau
T c k hi u (symbol rate): s l ng k hi u thng tin m ngu n sinh ra
trong m t n v th i gian (baud rate)
Ngu n tn hi u s :
Ngu n thng tin r i r c th ng c gi tr trong b ng alphabet.
Tn hi u s : l d ng sng mang thng tin s .
C 3 tham s chnh:
Ki u ngu n (alphabet): danh sch cc k hi u thng tin c th m ngu n t o
ra.
VD: A = {0,1}; cc k hi u c g i l bit
V i M k hi u (M = 2
n
): A = {0, 1,..., M-1} ho c A = {1, 3, ..., (M-1)}
Cc symbol c th c gi tr ph c: A = {1, j}
Xc su t u tin pht: t n s xu t hi n t ng i c a m i k hi u m ngu n
t o ra.
VD: ngu n sinh ra cc bt 0 v 1 c xc su t bng nhau
T c k hi u (symbol rate): s l ng k hi u thng tin m ngu n sinh ra
trong m t n v th i gian (baud rate)
25/09/2012
Nguy n c Nhn
115
Ngu n tn hi u s :
Ngu n thng tin r i r c th ng c gi tr trong b ng alphabet.
Tn hi u s : l d ng sng mang thng tin s .
C 3 tham s chnh:
Ki u ngu n (alphabet): danh sch cc k hi u thng tin c th m ngu n t o
ra.
VD: A = {0,1}; cc k hi u c g i l bit
V i M k hi u (M = 2
n
): A = {0, 1,..., M-1} ho c A = {1, 3, ..., (M-1)}
Cc symbol c th c gi tr ph c: A = {1, j}
Xc su t u tin pht: t n s xu t hi n t ng i c a m i k hi u m ngu n
t o ra.
VD: ngu n sinh ra cc bt 0 v 1 c xc su t bng nhau
T c k hi u (symbol rate): s l ng k hi u thng tin m ngu n sinh ra
trong m t n v th i gian (baud rate)
Ngu n tn hi u ng u nhin:
Cc ngu n tin trong th c t l ng u nhin t o cc tn hi u
ng u nhin trong m ph ng.
T o bi n ng u nhin phn b u: .
S d ng hm rand trong MATLAB
Ngu n tn hi u ng u nhin:
Cc ngu n tin trong th c t l ng u nhin t o cc tn hi u
ng u nhin trong m ph ng.
T o bi n ng u nhin phn b u: .
S d ng hm rand trong MATLAB
25/09/2012
Nguy n c Nhn
116
Ngu n tn hi u ng u nhin:
Cc ngu n tin trong th c t l ng u nhin t o cc tn hi u
ng u nhin trong m ph ng.
T o bi n ng u nhin phn b u: .
S d ng hm rand trong MATLAB
>> x = rand(5,10) - T o ma tr n 5x10 cc s ng u nhin phn b u trong kho ng [0,1]
T o cc s ng u nhin phn b u trong kho ng [a, b] :
>> x = a + (b-a) * rand(m,n)
T o cc s nguyn ng u nhin phn b u trn t p 1:n :
>> x = ceil(n.*rand(100,1));
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b u: .
V d : T o vect hng 1000 s ng u nhin phn b u trong kho ng [0,1], hi n th 10 s u tin
>> x = rand(1,1000);
>> x(1:10)
ans =
0.4330 0.8424 0.1845 0.5082 0.4522 0.3256 0.3801 0.8865 0.7613 0.8838
>> hist(x,10)
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b u: .
V d : T o vect hng 1000 s ng u nhin phn b u trong kho ng [0,1], hi n th 10 s u tin
>> x = rand(1,1000);
>> x(1:10)
ans =
0.4330 0.8424 0.1845 0.5082 0.4522 0.3256 0.3801 0.8865 0.7613 0.8838
>> hist(x,10)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
20
40
60
80
100
120
25/09/2012
Nguy n c Nhn
117
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
20
40
60
80
100
120
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
S d ng hm randn trong MATLAB .
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
S d ng hm randn trong MATLAB .
25/09/2012
Nguy n c Nhn
118
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
S d ng hm randn trong MATLAB .
T o cc s ng u nhin phn b chu n c trung bnh b ng 0 v l ch chu n b ng 1 :
>> x = randn(m,n)
T o cc s ng u nhin phn b chu n c trung bnh b ng m v ph ng sai v :
>> x = m + sqrt(v) * randn(m,n)
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
V d : T o vect hng 1000 s ng u nhin phn b chu n c trung bnh 0 v l ch chu n b ng 1, hi n
th 10 s u tin
>> x = randn(1,1000);
>> x(1:10)
ans =
-0.6028 -0.9934 1.1889 2.3880 2.2655 2.3011 -0.2701 0.5028 -0.1192 -0.0019
>> hist(x,10)
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
V d : T o vect hng 1000 s ng u nhin phn b chu n c trung bnh 0 v l ch chu n b ng 1, hi n
th 10 s u tin
>> x = randn(1,1000);
>> x(1:10)
ans =
-0.6028 -0.9934 1.1889 2.3880 2.2655 2.3011 -0.2701 0.5028 -0.1192 -0.0019
>> hist(x,10)
-4 -3 -2 -1 0 1 2 3 4
0
50
100
150
200
250
300
25/09/2012
Nguy n c Nhn
119
Ngu n tn hi u ng u nhin:
T o bi n ng u nhin phn b chu n:
-4 -3 -2 -1 0 1 2 3 4
0
50
100
150
200
250
300
Ngu n tn hi u ng u nhin:
T o s nguyn ng u nhin phn b u:
S d ng hm randint trong MATLAB:
Ngu n tn hi u ng u nhin:
T o s nguyn ng u nhin phn b u:
S d ng hm randint trong MATLAB:
T o ma tr n mxn cc s 0 v 1 c xc su t b ng nhau
>> x = randint(m,n);
V d :
>> x = randint(1,10)
x =
0 0 1 1 1 0 1 1 0 0
T o ma tr n mxn c cc gi tr phn b u trong d i t 0 n 7
>> x = randint(m, n, [0, 7]); ho c
>> x = randint(m,n, 8);
25/09/2012
Nguy n c Nhn
120
Ngu n tn hi u ng u nhin:
T o s nguyn ng u nhin phn b u:
S d ng hm randint trong MATLAB:
T o ma tr n mxn cc s 0 v 1 c xc su t b ng nhau
>> x = randint(m,n);
V d :
>> x = randint(1,10)
x =
0 0 1 1 1 0 1 1 0 0
T o ma tr n mxn c cc gi tr phn b u trong d i t 0 n 7
>> x = randint(m, n, [0, 7]); ho c
>> x = randint(m,n, 8);
Ngu n tn hi u ng u nhin:
T o symbol ng u nhin theo danh sch alphabet nh tr c:
S d ng hm randsrc trong MATLAB:
T o ngu n l i ng u nhin:
S d ng hm randerr trong MATLAB
Ngu n tn hi u ng u nhin:
T o symbol ng u nhin theo danh sch alphabet nh tr c:
S d ng hm randsrc trong MATLAB:
T o ngu n l i ng u nhin:
S d ng hm randerr trong MATLAB
T o ma tr n mxn cc s -1 v 1 c xc su t b ng nhau
>> x = randsrc(m,n);
V d :
>> x = randsrc(1,10)
x =
-1 1 1 -1 -1 -1 -1 1 1 1
T o ma tr n mxn c cc gi tr phn b u trong t p {-3,-1,1,3}
>> x = randsrc(10,10,[-3 -1 1 3]); ho c
>> x = randsrc(10,10,[-3 -1 1 3; .25 .25 .25 .25]);
25/09/2012
Nguy n c Nhn
121
Ngu n tn hi u ng u nhin:
T o symbol ng u nhin theo danh sch alphabet nh tr c:
S d ng hm randsrc trong MATLAB:
T o ngu n l i ng u nhin:
S d ng hm randerr trong MATLAB
T o ma tr n mxn cc s -1 v 1 c xc su t b ng nhau
>> x = randsrc(m,n);
V d :
>> x = randsrc(1,10)
x =
-1 1 1 -1 -1 -1 -1 1 1 1
T o ma tr n mxn c cc gi tr phn b u trong t p {-3,-1,1,3}
>> x = randsrc(10,10,[-3 -1 1 3]); ho c
>> x = randsrc(10,10,[-3 -1 1 3; .25 .25 .25 .25]);
M ha ngu n:
Qu trnh chuy n i A/D:
Qu trnh PCM:
L ng t ha u
L ng t ha khng u
Analog
signal
Digital
signal
M ha ngu n:
Qu trnh chuy n i A/D:
Qu trnh PCM:
L ng t ha u
L ng t ha khng u
Sampler Quantizer Coder
Analog
signal
Digital
signal
sampling quantization coding
25/09/2012
Nguy n c Nhn
122
M ha ngu n:
Qu trnh chuy n i A/D:
Qu trnh PCM:
L ng t ha u
L ng t ha khng u
M ha ngu n:
MATLAB code cho qu trnh PCM l ng t ha u:
function [code,xq,sqnr] = uniform_pcm(x,M)
% Uniform PCM encoding of a sequence
% x = input sequence
% M = number of quantization levels
% code = the encoded output
% xq = quantized sequence before encoding
% sqnr = signal to quantization noise ratio in dB
% Written by Nguyen Duc Nhan - 2012
Nb = log2(M);
Amax = max(abs(x));
delta = 2*Amax/(M-1);
Mq = -Amax:delta:Amax;
Ml = 0:M-1;
xq = zeros(size(x));
xcode = xq;
for k = 1:M
ind = find(x > Mq(k)-delta/2 & x <= Mq(k)+delta/2);
xq(ind) = Mq(k);
xcode(ind) = Ml(k);
end
sqnr = 20*log10(norm(x)/norm(x-xq));
code = de2bi(xcode,Nb,'left-msb');
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve qua trinh PCM luong tu hoa deu
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
M ha ngu n:
MATLAB code cho qu trnh PCM l ng t ha u:
function [code,xq,sqnr] = uniform_pcm(x,M)
% Uniform PCM encoding of a sequence
% x = input sequence
% M = number of quantization levels
% code = the encoded output
% xq = quantized sequence before encoding
% sqnr = signal to quantization noise ratio in dB
% Written by Nguyen Duc Nhan - 2012
Nb = log2(M);
Amax = max(abs(x));
delta = 2*Amax/(M-1);
Mq = -Amax:delta:Amax;
Ml = 0:M-1;
xq = zeros(size(x));
xcode = xq;
for k = 1:M
ind = find(x > Mq(k)-delta/2 & x <= Mq(k)+delta/2);
xq(ind) = Mq(k);
xcode(ind) = Ml(k);
end
sqnr = 20*log10(norm(x)/norm(x-xq));
code = de2bi(xcode,Nb,'left-msb');
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve qua trinh PCM luong tu hoa deu
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
25/09/2012
Nguy n c Nhn
123
function [code,xq,sqnr] = uniform_pcm(x,M)
% Uniform PCM encoding of a sequence
% x = input sequence
% M = number of quantization levels
% code = the encoded output
% xq = quantized sequence before encoding
% sqnr = signal to quantization noise ratio in dB
% Written by Nguyen Duc Nhan - 2012
Nb = log2(M);
Amax = max(abs(x));
delta = 2*Amax/(M-1);
Mq = -Amax:delta:Amax;
Ml = 0:M-1;
xq = zeros(size(x));
xcode = xq;
for k = 1:M
ind = find(x > Mq(k)-delta/2 & x <= Mq(k)+delta/2);
xq(ind) = Mq(k);
xcode(ind) = Ml(k);
end
sqnr = 20*log10(norm(x)/norm(x-xq));
code = de2bi(xcode,Nb,'left-msb');
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve qua trinh PCM luong tu hoa deu
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
code =
1 1 0 1
1 1 1 0
1 1 1 1
1 1 1 1
1 1 1 1
sqnr = 25.4136 dB
M ha ngu n:
Qu trnh PCM l ng t ha khng u: V d theo lu t
%%nonuniform PCM process
mu = 255;
M = 32; % number of quantization levels
[y,amax] = mulaw(x,mu); % compress the signal
[code,yq,sqnr] = uniform_pcm(y,M); % coding
xq = invmulaw(yq,mu); % expand the signal
xq = xq*amax;
sqnr = 20*log10(norm(x)/norm(x-xq)); % in dB
M ha ngu n:
Qu trnh PCM l ng t ha khng u: V d theo lu t
%%nonuniform PCM process
mu = 255;
M = 32; % number of quantization levels
[y,amax] = mulaw(x,mu); % compress the signal
[code,yq,sqnr] = uniform_pcm(y,M); % coding
xq = invmulaw(yq,mu); % expand the signal
xq = xq*amax;
sqnr = 20*log10(norm(x)/norm(x-xq)); % in dB
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve nonuniform PCM
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve nonuniform PCM
L ng t ha khng u
Tn hi u l ng t ha sau khi nn
25/09/2012
Nguy n c Nhn
124
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve nonuniform PCM
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-1
-0.5
0
0.5
1
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve nonuniform PCM
L ng t ha u
L ng t ha khng u
M ng:
Ki u m ha t o d ng ph v m t s c tnh xc nh c a
xung tn hi u h tr cho qu trnh ng b .
G m 2 b c:
S p x p logic
Chuy n i thnh d ng sng
V d :
M ng:
Ki u m ha t o d ng ph v m t s c tnh xc nh c a
xung tn hi u h tr cho qu trnh ng b .
G m 2 b c:
S p x p logic
Chuy n i thnh d ng sng
V d :
25/09/2012
Nguy n c Nhn
125
M ng:
Ki u m ha t o d ng ph v m t s c tnh xc nh c a
xung tn hi u h tr cho qu trnh ng b .
G m 2 b c:
S p x p logic
Chuy n i thnh d ng sng
V d :
M non-return-to-zero (NRZ)
M Manchester
M NRZ-AMI
M ng:
T o chu i xung vung:
Trong m i chu k xung, hm xung
vung c nh ngha nh sau:
function [t,y] = rectpulse(Tw,Rp,Ns,Np)
% Chuong trinh vi du tao chuoi xung vuong
%Tw - the pulsewidth
% Rp - the repetition rate of pulse Tp < 1/Rp
% Ns - the number of samples
% Np - the number of pulses (the length of pulse train)
% t - the time vector output
% y - the vector output of the pulse samples
% written by Nguyen Duc Nhan
Tp = 1/Rp; % pulse period
Timewindow = Np*Tp; % time window
ts = Timewindow/(Ns-1); % sampling time
t = 0:ts:Timewindow; % time vector
Nsp = round(Tp/ts); % number of samples within Tp
y = zeros(size(t));
for k = 1:Ns
if mod(t(k),Nsp*ts) <= Tw
y(k) = 1;
else
y(k) = 0;
end
end
M ng:
T o chu i xung vung:
Trong m i chu k xung, hm xung
vung c nh ngha nh sau:
1,
( )
0,
p
p
t T
u t
t T
s
=

>

function [t,y] = rectpulse(Tw,Rp,Ns,Np)


% Chuong trinh vi du tao chuoi xung vuong
%Tw - the pulsewidth
% Rp - the repetition rate of pulse Tp < 1/Rp
% Ns - the number of samples
% Np - the number of pulses (the length of pulse train)
% t - the time vector output
% y - the vector output of the pulse samples
% written by Nguyen Duc Nhan
Tp = 1/Rp; % pulse period
Timewindow = Np*Tp; % time window
ts = Timewindow/(Ns-1); % sampling time
t = 0:ts:Timewindow; % time vector
Nsp = round(Tp/ts); % number of samples within Tp
y = zeros(size(t));
for k = 1:Ns
if mod(t(k),Nsp*ts) <= Tw
y(k) = 1;
else
y(k) = 0;
end
end
0 1 2 3 4 5 6 7 8
x 10
-6
0
0.2
0.4
0.6
0.8
1
Time (s)
A
m
p
l
i
t
u
d
e
>> [t,y]=rectpulse(0.5e-6,1e6,256,8);
>> plot(t,y);
25/09/2012
Nguy n c Nhn
126
M ng:
T o chu i xung vung:
Trong m i chu k xung, hm xung
vung c nh ngha nh sau:
function [t,y] = rectpulse(Tw,Rp,Ns,Np)
% Chuong trinh vi du tao chuoi xung vuong
%Tw - the pulsewidth
% Rp - the repetition rate of pulse Tp < 1/Rp
% Ns - the number of samples
% Np - the number of pulses (the length of pulse train)
% t - the time vector output
% y - the vector output of the pulse samples
% written by Nguyen Duc Nhan
Tp = 1/Rp; % pulse period
Timewindow = Np*Tp; % time window
ts = Timewindow/(Ns-1); % sampling time
t = 0:ts:Timewindow; % time vector
Nsp = round(Tp/ts); % number of samples within Tp
y = zeros(size(t));
for k = 1:Ns
if mod(t(k),Nsp*ts) <= Tw
y(k) = 1;
else
y(k) = 0;
end
end
0 1 2 3 4 5 6 7 8
x 10
-6
0
0.2
0.4
0.6
0.8
1
Time (s)
A
m
p
l
i
t
u
d
e
M ng:
M NRZ:
function [t,y,code] = nrzcode(d,R,Ns,type)
% Chuong trinh vi du ve ma duong truyen NRZ
% d - the data sequence
% R - the data rate
% Ns - the number of samples
% t - the time vector output
% y - the vector output of the pulse samples
% type - the type of code (unipolar - 'unipol' or polar - 'pol')
% written by Nguyen Duc Nhan
Tb = 1/R; % bit period
Nb = length(d); % number of bits
Timewindow = Nb*Tb; % time window
ts = Timewindow/(Ns-1); % sampling time
t = 0:ts:Timewindow; % time vector
y = zeros(size(t));
code = [];
if nargin <=3
type = 'unipol';
end
for k = 1:Ns
n = fix(t(k)/Tb)+1;
if n >= Nb
n = Nb;
end
switch (type)
case 'unipol'
y(k) = d(n);
code(n) = d(n);
case 'pol'
y(k) = 2*d(n)-1;
code(n) = 2*d(n)-1;
end
end
M ng:
M NRZ:
function [t,y,code] = nrzcode(d,R,Ns,type)
% Chuong trinh vi du ve ma duong truyen NRZ
% d - the data sequence
% R - the data rate
% Ns - the number of samples
% t - the time vector output
% y - the vector output of the pulse samples
% type - the type of code (unipolar - 'unipol' or polar - 'pol')
% written by Nguyen Duc Nhan
Tb = 1/R; % bit period
Nb = length(d); % number of bits
Timewindow = Nb*Tb; % time window
ts = Timewindow/(Ns-1); % sampling time
t = 0:ts:Timewindow; % time vector
y = zeros(size(t));
code = [];
if nargin <=3
type = 'unipol';
end
for k = 1:Ns
n = fix(t(k)/Tb)+1;
if n >= Nb
n = Nb;
end
switch (type)
case 'unipol'
y(k) = d(n);
code(n) = d(n);
case 'pol'
y(k) = 2*d(n)-1;
code(n) = 2*d(n)-1;
end
end
0 20 40 60 80 100 120 140 160
0
0.2
0.4
0.6
0.8
1
1.2
Time (ps)
A
m
p
lit
u
d
e
h = [ 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1]
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ps)
A
m
p
lit
u
d
e
25/09/2012
Nguy n c Nhn
127
0 20 40 60 80 100 120 140 160
0
0.2
0.4
0.6
0.8
1
1.2
Time (ps)
A
m
p
lit
u
d
e
h = [ 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1]
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ps)
A
m
p
lit
u
d
e
M ng:
M AMI:
function [t,y,code] = amicode(d,R,Ns,type)
% Chuong trinh vi du ve ma AMI
% d - the data sequence
% R - the data rate
% Ns - the number of samples
% t - the time vector output
% y - the vector output of the pulse samples
% type - the type of code (NRZ - 'NRZ' or RZ - 'RZ')
% written by Nguyen Duc Nhan
...
y = zeros(size(t));
code = [];
...
s = 1;
for k = 1:Nb
if d(k) == 0
code(k) = 0;
else
s = s+1;
if mod(s,2)==0
code(k) = 1;
else
code(k) = -1;
end
end
end
...
M ng:
M AMI:
function [t,y,code] = amicode(d,R,Ns,type)
% Chuong trinh vi du ve ma AMI
% d - the data sequence
% R - the data rate
% Ns - the number of samples
% t - the time vector output
% y - the vector output of the pulse samples
% type - the type of code (NRZ - 'NRZ' or RZ - 'RZ')
% written by Nguyen Duc Nhan
...
y = zeros(size(t));
code = [];
...
s = 1;
for k = 1:Nb
if d(k) == 0
code(k) = 0;
else
s = s+1;
if mod(s,2)==0
code(k) = 1;
else
code(k) = -1;
end
end
end
...
code = 0 0 1 -1 0 0 1 -1 1 -1 1 -1 0 1 0 -1
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
25/09/2012
Nguy n c Nhn
128
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
0 20 40 60 80 100 120 140 160
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
M ha knh:
Tng hi u nng c a knh truy n:
Pht hi n l i
S a l i
G m 2 lo i chnh:
M kh i
M xo n
V d m kh i:
M ha: T m
Kho ng cch Hamming t i thi u:
i v i m kh i tuy n tnh: kho ng cch t i thi u b ng v i tr ng s nh nh t
c a m
M ha knh:
Tng hi u nng c a knh truy n:
Pht hi n l i
S a l i
G m 2 lo i chnh:
M kh i
M xo n
V d m kh i:
M ha: T m
Kho ng cch Hamming t i thi u:
i v i m kh i tuy n tnh: kho ng cch t i thi u b ng v i tr ng s nh nh t
c a m
Trong : u chu i d li u c k bit, G ma tr n t o m c kxn, c t m c m ha c n bit (n>k)
25/09/2012
Nguy n c Nhn
129
M ha knh:
Tng hi u nng c a knh truy n:
Pht hi n l i
S a l i
G m 2 lo i chnh:
M kh i
M xo n
V d m kh i:
M ha: T m
Kho ng cch Hamming t i thi u:
i v i m kh i tuy n tnh: kho ng cch t i thi u b ng v i tr ng s nh nh t
c a m
Trong : u chu i d li u c k bit, G ma tr n t o m c kxn, c t m c m ha c n bit (n>k)
M ha knh:
V d m kh i:
% Chuong trinh vi du ve ma hoa kenh
% Block coding
k = 4;
for i=1:2^4
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
% Define G, the generator matrix
g = [1 0 0 1 1 1 0 1 1 1;
1 1 1 0 0 0 1 1 1 0;
0 1 1 0 1 1 0 1 0 1;
1 1 0 1 1 1 1 0 0 1];
% generate codewords
c = rem(u*g,2);
% find the minimum distance
w_min = min(sum((c(2:2^k,:))'));
M ha knh:
V d m kh i:
% Chuong trinh vi du ve ma hoa kenh
% Block coding
k = 4;
for i=1:2^4
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
% Define G, the generator matrix
g = [1 0 0 1 1 1 0 1 1 1;
1 1 1 0 0 0 1 1 1 0;
0 1 1 0 1 1 0 1 0 1;
1 1 0 1 1 1 1 0 0 1];
% generate codewords
c = rem(u*g,2);
% find the minimum distance
w_min = min(sum((c(2:2^k,:))'));
c =
0 0 0 0 0 0 0 0 0 0
1 1 0 1 1 1 1 0 0 1
0 1 1 0 1 1 0 1 0 1
1 0 1 1 0 0 1 1 0 0
1 1 1 0 0 0 1 1 1 0
0 0 1 1 1 1 0 1 1 1
1 0 0 0 1 1 1 0 1 1
0 1 0 1 0 0 0 0 1 0
1 0 0 1 1 1 0 1 1 1
0 1 0 0 0 0 1 1 1 0
1 1 1 1 0 0 0 0 1 0
0 0 1 0 1 1 1 0 1 1
0 1 1 1 1 1 1 0 0 1
1 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 1 1 0 0
1 1 0 0 1 1 0 1 0 1
u =
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
25/09/2012
Nguy n c Nhn
130
% Chuong trinh vi du ve ma hoa kenh
% Block coding
k = 4;
for i=1:2^4
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end
end
end
% Define G, the generator matrix
g = [1 0 0 1 1 1 0 1 1 1;
1 1 1 0 0 0 1 1 1 0;
0 1 1 0 1 1 0 1 0 1;
1 1 0 1 1 1 1 0 0 1];
% generate codewords
c = rem(u*g,2);
% find the minimum distance
w_min = min(sum((c(2:2^k,:))'));
c =
0 0 0 0 0 0 0 0 0 0
1 1 0 1 1 1 1 0 0 1
0 1 1 0 1 1 0 1 0 1
1 0 1 1 0 0 1 1 0 0
1 1 1 0 0 0 1 1 1 0
0 0 1 1 1 1 0 1 1 1
1 0 0 0 1 1 1 0 1 1
0 1 0 1 0 0 0 0 1 0
1 0 0 1 1 1 0 1 1 1
0 1 0 0 0 0 1 1 1 0
1 1 1 1 0 0 0 0 1 0
0 0 1 0 1 1 1 0 1 1
0 1 1 1 1 1 1 0 0 1
1 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 1 1 0 0
1 1 0 0 1 1 0 1 0 1
u =
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
i u ch tn hi u t ng t :
i u ch bin AM:
Tn hi u b n tin:
Tn hi u sng mang:
Qu trnh i u ch : l m t qu trnh nhn
su i u ch (modulation index):
i u ch tn hi u t ng t :
i u ch bin AM:
Tn hi u b n tin:
Tn hi u sng mang:
Qu trnh i u ch : l m t qu trnh nhn
su i u ch (modulation index):
25/09/2012
Nguy n c Nhn
131
i u ch tn hi u t ng t :
i u ch bin AM:
Tn hi u b n tin:
Tn hi u sng mang:
Qu trnh i u ch : l m t qu trnh nhn
su i u ch (modulation index):
i u ch tn hi u t ng t :
i u ch bin AM:
% Chuong trinh vi du ve dieu che AM
%% Set parameters
% Message
A = 1; % amplitude
f = 440; % frequency [Hz]
phi = -pi/4; % Phase [rad]
% Carrier
m = 0.5; % modulation index
Ac = A/m; % amplitude
fc = 5e3; % frequency [Hz]
phi_c = 0; % Phase [rad]
N = 2^9; % number of samples
T0 = 0; % start time [s]
Tf = 5e-3; % end time [s]
Ts = (Tf-T0)/(N-1); % sampling period
fs = 1/Ts; % sampling frequency [Hz]
%% Amplitude Modulation
% Generate sinusoid
t = T0:Ts:Tf; % time vector
x = A*cos(2*pi*f*t+phi); % message signal
xc = Ac*cos(2*pi*fc*t+phi_c); % carrier signal
% Modulation
y = (1+x/Ac).*xc;
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
-2
-1
0
1
2
3
Time (ms)
A
m
p
lit
u
d
e
Vi du ve dieu che AM
i u ch tn hi u t ng t :
i u ch bin AM:
% Chuong trinh vi du ve dieu che AM
%% Set parameters
% Message
A = 1; % amplitude
f = 440; % frequency [Hz]
phi = -pi/4; % Phase [rad]
% Carrier
m = 0.5; % modulation index
Ac = A/m; % amplitude
fc = 5e3; % frequency [Hz]
phi_c = 0; % Phase [rad]
N = 2^9; % number of samples
T0 = 0; % start time [s]
Tf = 5e-3; % end time [s]
Ts = (Tf-T0)/(N-1); % sampling period
fs = 1/Ts; % sampling frequency [Hz]
%% Amplitude Modulation
% Generate sinusoid
t = T0:Ts:Tf; % time vector
x = A*cos(2*pi*f*t+phi); % message signal
xc = Ac*cos(2*pi*fc*t+phi_c); % carrier signal
% Modulation
y = (1+x/Ac).*xc;
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
-2
-1
0
1
2
3
Time (ms)
A
m
p
lit
u
d
e
Vi du ve dieu che AM
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Time (ms)
A
m
p
lit
u
d
e
Vi du ve dieu che AM
M = 50%
25/09/2012
Nguy n c Nhn
132
% Chuong trinh vi du ve dieu che AM
%% Set parameters
% Message
A = 1; % amplitude
f = 440; % frequency [Hz]
phi = -pi/4; % Phase [rad]
% Carrier
m = 0.5; % modulation index
Ac = A/m; % amplitude
fc = 5e3; % frequency [Hz]
phi_c = 0; % Phase [rad]
N = 2^9; % number of samples
T0 = 0; % start time [s]
Tf = 5e-3; % end time [s]
Ts = (Tf-T0)/(N-1); % sampling period
fs = 1/Ts; % sampling frequency [Hz]
%% Amplitude Modulation
% Generate sinusoid
t = T0:Ts:Tf; % time vector
x = A*cos(2*pi*f*t+phi); % message signal
xc = Ac*cos(2*pi*fc*t+phi_c); % carrier signal
% Modulation
y = (1+x/Ac).*xc; 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Time (ms)
A
m
p
lit
u
d
e
Vi du ve dieu che AM
M = 100%
i u ch tn hi u t ng t :
i u ch bin AM:
i u ch SSB (Single side band): S d ng b l c ho c dng khai tri n
Hilbert
i u ch tn hi u t ng t :
i u ch bin AM:
i u ch SSB (Single side band): S d ng b l c ho c dng khai tri n
Hilbert
%% SSB Modulation
% Generate sinusoid
t = T0:Ts:Tf;
x = A*cos(2*pi*f*t+phi);
% Modulation
y = ssbmod(x,fc,fs,phic);
% Demodulation
xr = ssbdemod(y,fc,fs,phic);
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-1.5
-1
-0.5
0
0.5
1
1.5
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve dieu che SSB
25/09/2012
Nguy n c Nhn
133
%% SSB Modulation
% Generate sinusoid
t = T0:Ts:Tf;
x = A*cos(2*pi*f*t+phi);
% Modulation
y = ssbmod(x,fc,fs,phic);
% Demodulation
xr = ssbdemod(y,fc,fs,phic);
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-1.5
-1
-0.5
0
0.5
1
1.5
Time (ms)
A
m
p
l
i
t
u
d
e
Vi du ve dieu che SSB
i u ch tn hi u t ng t :
i u ch t n s FM:
Trong MATLAB: s d ng hm fmmod v
fmdemod cho i u ch FM
i u ch tn hi u t ng t :
i u ch t n s FM:
Trong MATLAB: s d ng hm fmmod v
fmdemod cho i u ch FM
Ch s i u ch :
r ng bng t n:
i u ch tn hi u t ng t :
i u ch t n s FM:
Trong MATLAB: s d ng hm fmmod v
fmdemod cho i u ch FM
25/09/2012
Nguy n c Nhn
134
r ng bng t n:
% Modulation
y = pmmod(x,fc,fs,phic);
% Demodulation
xr = pmdemod(y,fc,fs,phic);
i u ch tn hi u t ng t :
i u ch pha PM:
Sng mang:
Tn hi u i u ch :
Trong MATLAB s d ng cc hm pmmod v
pmdemod cho i u ch PM.
i u ch tn hi u t ng t :
i u ch pha PM:
Sng mang:
Tn hi u i u ch :
Trong MATLAB s d ng cc hm pmmod v
pmdemod cho i u ch PM.
25/09/2012
Nguy n c Nhn
135
i u ch tn hi u t ng t :
i u ch pha PM:
Sng mang:
Tn hi u i u ch :
Trong MATLAB s d ng cc hm pmmod v
pmdemod cho i u ch PM.
%% Phase Modulation
t = T0:Ts:Tf;
x = A*cos(2*pi*f*t+phi);
% Modulation
y = pmmod(x,fc,fs,phic);
% Demodulation
xr = pmdemod(y,fc,fs,phic);
i u ch tn hi u s :
i u ch tuy n tnh:
c bi u di n b i:
s(t) l tuy n tnh v i b
n
Cc nh d ng i u ch khc nhau c xy d ng b ng vi c ch n
cc danh sch alphabet ph h p
Hm p(t) xc nh d ng xung u ra tn hi u c i u ch
p(t) c th l hm xung vung ho c hm xung sinc
i u ch tn hi u s :
i u ch tuy n tnh:
c bi u di n b i:
s(t) l tuy n tnh v i b
n
Cc nh d ng i u ch khc nhau c xy d ng b ng vi c ch n
cc danh sch alphabet ph h p
Hm p(t) xc nh d ng xung u ra tn hi u c i u ch
p(t) c th l hm xung vung ho c hm xung sinc
25/09/2012
Nguy n c Nhn
136
i u ch tn hi u s :
i u ch tuy n tnh:
c bi u di n b i:
s(t) l tuy n tnh v i b
n
Cc nh d ng i u ch khc nhau c xy d ng b ng vi c ch n
cc danh sch alphabet ph h p
Hm p(t) xc nh d ng xung u ra tn hi u c i u ch
p(t) c th l hm xung vung ho c hm xung sinc
i u ch tn hi u s :
i u ch pha ASK:
S d ng hm pammod v pamdemod trong MATLAB t o ra k hi u ph c
t ng ng bng g c.
bi u di n d ng sng i u ch c sng mang c th s d ng hm ammod
trong i u ch AM v i cc m c c l y m u:
i u ch tn hi u s :
i u ch pha ASK:
S d ng hm pammod v pamdemod trong MATLAB t o ra k hi u ph c
t ng ng bng g c.
bi u di n d ng sng i u ch c sng mang c th s d ng hm ammod
trong i u ch AM v i cc m c c l y m u:
% Signal generator
dm = randint(1,1000,4);
% PAM modulation
s = pammod(dm,4);
% PAM demodulation
r = pamdemod(s,4);
% Data sequence
h = [0 1 0 1];
% NRZ modulation
[t,y,code]=nrzcode(h,1e6,512);
% AM demodulation
ts = t(2)-t(1); % sampling time
fs = 1/ts; % sampling freq.
fc = 10e6; % carrier freq.
yd = ammod(y,fc,fs);
0 5 10 15 20 25 30 35 40
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
Vi du ve dieu che ASK
25/09/2012
Nguy n c Nhn
137
i u ch tn hi u s :
i u ch pha ASK:
S d ng hm pammod v pamdemod trong MATLAB t o ra k hi u ph c
t ng ng bng g c.
bi u di n d ng sng i u ch c sng mang c th s d ng hm ammod
trong i u ch AM v i cc m c c l y m u:
% Data sequence
h = [0 1 0 1];
% NRZ modulation
[t,y,code]=nrzcode(h,1e6,512);
% AM demodulation
ts = t(2)-t(1); % sampling time
fs = 1/ts; % sampling freq.
fc = 10e6; % carrier freq.
yd = ammod(y,fc,fs);
0 5 10 15 20 25 30 35 40
-1
-0.5
0
0.5
1
Time (ns)
A
m
p
l
i
t
u
d
e
Vi du ve dieu che ASK
i u ch tn hi u s :
i u ch pha PSK:
i u ch M-PSK:
i u ch tn hi u s :
i u ch pha PSK:
i u ch M-PSK:
BPSK
QPSK
B i u ch
B gi i i u ch
Tn hi u BPSK:
25/09/2012
Nguy n c Nhn
138
Tn hi u BPSK:
Tn hi u QPSK:
D ng sng QPSK:
i u ch tn hi u s :
i u ch pha PSK:
Trong MATLAB s d ng hm pskmod
v pskdemod cho i u ch PSK k t
h p v i modem xy d ng object
c a b i u ch v gi i i u ch :
% Create a random digital message
M = 4; %Alphabet size
x = randint(5000,1,M); % Message generator
% Use QPSK modulation to produce y.
h = modem.pskmod(M,pi/4);
h.symbolorder = 'gray';
y = modulate(h,x);
% Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');
% Create scatter plot from noisy data.
h = scatterplot(ynoisy,1,0,'xb');
hold on;
scatterplot(y,1,0,'or',h);
% Demodulate ynoisy to recover the message.
h = modem.pskdemod(M,pi/4);
h.symbolorder = 'gray';
z=demodulate(h,ynoisy);
i u ch tn hi u s :
i u ch pha PSK:
Trong MATLAB s d ng hm pskmod
v pskdemod cho i u ch PSK k t
h p v i modem xy d ng object
c a b i u ch v gi i i u ch :
% Create a random digital message
M = 4; %Alphabet size
x = randint(5000,1,M); % Message generator
% Use QPSK modulation to produce y.
h = modem.pskmod(M,pi/4);
h.symbolorder = 'gray';
y = modulate(h,x);
% Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');
% Create scatter plot from noisy data.
h = scatterplot(ynoisy,1,0,'xb');
hold on;
scatterplot(y,1,0,'or',h);
% Demodulate ynoisy to recover the message.
h = modem.pskdemod(M,pi/4);
h.symbolorder = 'gray';
z=demodulate(h,ynoisy);
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
-1.5 -1 -0.5 0 0.5 1 1.5
-1.5
-1
-0.5
0
0.5
1
1.5
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
t/4 - QPSK
25/09/2012
Nguy n c Nhn
139
% Create a random digital message
M = 4; %Alphabet size
x = randint(5000,1,M); % Message generator
% Use QPSK modulation to produce y.
h = modem.pskmod(M,pi/4);
h.symbolorder = 'gray';
y = modulate(h,x);
% Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');
% Create scatter plot from noisy data.
h = scatterplot(ynoisy,1,0,'xb');
hold on;
scatterplot(y,1,0,'or',h);
% Demodulate ynoisy to recover the message.
h = modem.pskdemod(M,pi/4);
h.symbolorder = 'gray';
z=demodulate(h,ynoisy);
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
-1.5 -1 -0.5 0 0.5 1 1.5
-1.5
-1
-0.5
0
0.5
1
1.5
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
QPSK
i u ch tn hi u s :
i u ch pha PSK:
i u ch PSK m ha vi sai: s d ng hm dpskmod v dpskdemod
i u ch tn hi u s :
i u ch pha PSK:
i u ch PSK m ha vi sai: s d ng hm dpskmod v dpskdemod
% Create a random digital message
M = 2; %Alphabet size
x = randint(5000,1,M); % Message
% Use DPSK modulation to produce y.
y = dpskmod(x,M);
% Demodulate to recover the message.
z = dpskdemod(y,M);
-1.5 -1 -0.5 0 0.5 1 1.5
-1.5
-1
-0.5
0
0.5
1
1.5
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
x = 0 1 1 0 0 0 1 0 0 0 0 1 0 1 1 1 0 1 0 1
0 2 4 6 8 10 12 14 16 18 20
0
0.5
1
1.5
2
Symbol index
A
m
p
l
i
t
u
d
e
Bieu dien bien do cua tin hieu dieu che DPSK
0 2 4 6 8 10 12 14 16 18 20
-1
0
1
2
3
4
Symbol index
P
h
a
s
e

(
r
a
d
)
Bieu dien bien do cua tin hieu dieu che DPSK
25/09/2012
Nguy n c Nhn
140
% Create a random digital message
M = 2; %Alphabet size
x = randint(5000,1,M); % Message
% Use DPSK modulation to produce y.
y = dpskmod(x,M);
% Demodulate to recover the message.
z = dpskdemod(y,M);
-1.5 -1 -0.5 0 0.5 1 1.5
-1.5
-1
-0.5
0
0.5
1
1.5
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
0 2 4 6 8 10 12 14 16 18 20
0
0.5
1
1.5
2
Symbol index
A
m
p
l
i
t
u
d
e
Bieu dien bien do cua tin hieu dieu che DPSK
0 2 4 6 8 10 12 14 16 18 20
-1
0
1
2
3
4
Symbol index
P
h
a
s
e

(
r
a
d
)
Bieu dien bien do cua tin hieu dieu che DPSK
i u ch tn hi u s :
i u ch QAM: k t h p gi a ASK v PSK
i u ch tn hi u s :
i u ch QAM: k t h p gi a ASK v PSK
B i u ch B gi i i u ch
25/09/2012
Nguy n c Nhn
141
Rectangular QAM
Circular QAM
i u ch tn hi u s :
i u ch QAM:
S d ng hm qammod v qamdemod trong MATLAB
i u ch tn hi u s :
i u ch QAM:
S d ng hm qammod v qamdemod trong MATLAB
close all;
% Create a random digital message
M = 16; % Alphabet size
x = randint(5000,1,M);
% Use 16-QAM modulation to produce y.
y=modulate(modem.qammod(M),x);
%Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');
% Create scatter plot from noisy data.
h = scatterplot(ynoisy,1,0,'xb');
hold on;
scatterplot(y,1,0,'or',h); hold off;
0 2 4 6 8 10 12 14 16 18 20
2
3
4
Symbol index
A
m
p
l
i
t
u
d
e
Bieu dien bien do cua tin hieu dieu che 16-QAM
5 10 15 20
-2
0
2
Symbol index
P
h
a
s
e

(
r
a
d
)
Bieu dien bien do cua tin hieu dieu che 16-QAM
-4 -2 0 2 4
-4
-3
-2
-1
0
1
2
3
4
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
25/09/2012
Nguy n c Nhn
142
close all;
% Create a random digital message
M = 16; % Alphabet size
x = randint(5000,1,M);
% Use 16-QAM modulation to produce y.
y=modulate(modem.qammod(M),x);
%Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');
% Create scatter plot from noisy data.
h = scatterplot(ynoisy,1,0,'xb');
hold on;
scatterplot(y,1,0,'or',h); hold off;
0 2 4 6 8 10 12 14 16 18 20
2
3
4
Symbol index
A
m
p
l
i
t
u
d
e
Bieu dien bien do cua tin hieu dieu che 16-QAM
5 10 15 20
-2
0
2
Symbol index
P
h
a
s
e

(
r
a
d
)
Bieu dien bien do cua tin hieu dieu che 16-QAM
i u ch tn hi u s :
i u ch FSK:
i u ch FSK
i u ch FSK pha lin t c (CPFSK)
i u ch MSK: m t ki u CPFSK
i u ch tn hi u s :
i u ch FSK:
i u ch FSK
i u ch FSK pha lin t c (CPFSK)
i u ch MSK: m t ki u CPFSK
25/09/2012
Nguy n c Nhn
143
S d ng hm fskmod v fskdemod cho i u ch FSK
S d ng hm mskmod v fskdemod cho i u ch MSK
i u ch tn hi u s :
i u ch FSK:
% Chuong trinh vi du ve MSK
close all;
% Parameters
Ns = 8; % number of samples per symbol
x = randint(1000,1); % Random signal
% Use MSK modulation to produce y.
y = mskmod(x,Ns,[],pi/2);
h = scatterplot(y,1,0,'xb');
hold on;
scatterplot(y,Ns,0,'or',h); hold off;
% Transmit signal through an AWGN channel.
yn = awgn(y,25,'measured');
% Plot eyediagram
eyediagram(yn,16);
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for In-Phase Signal
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for Quadrature Signal
% Chuong trinh vi du ve MSK
close all;
% Parameters
Ns = 8; % number of samples per symbol
x = randint(1000,1); % Random signal
% Use MSK modulation to produce y.
y = mskmod(x,Ns,[],pi/2);
h = scatterplot(y,1,0,'xb');
hold on;
scatterplot(y,Ns,0,'or',h); hold off;
% Transmit signal through an AWGN channel.
yn = awgn(y,25,'measured');
% Plot eyediagram
eyediagram(yn,16);
-1 -0.5 0 0.5 1
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for In-Phase Signal
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for Quadrature Signal
25/09/2012
Nguy n c Nhn
144
% Chuong trinh vi du ve MSK
close all;
% Parameters
Ns = 8; % number of samples per symbol
x = randint(1000,1); % Random signal
% Use MSK modulation to produce y.
y = mskmod(x,Ns,[],pi/2);
h = scatterplot(y,1,0,'xb');
hold on;
scatterplot(y,Ns,0,'or',h); hold off;
% Transmit signal through an AWGN channel.
yn = awgn(y,25,'measured');
% Plot eyediagram
eyediagram(yn,16);
-1 -0.5 0 0.5 1
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Q
u
a
d
r
a
t
u
r
e
In-Phase
Scatter plot
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for In-Phase Signal
-0.5 0 0.5
-1.5
-1
-0.5
0
0.5
1
1.5
Time
A
m
p
l
i
t
u
d
e
Eye Diagram for Quadrature Signal