1. Trang chủ
  2. » Cao đẳng - Đại học

Bài tập môn học Kỹ Thuật truyền dẫn

15 739 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 15
Dung lượng 273 KB

Nội dung

Bài tập môn học Kỹ Thuật truyền dẫnBài I: Biểu diễn tín hiệu của một số mã đường dây và vẽ phổ của chúng.

Trang 1

Bài tập môn học Kỹ Thuật truyền dẫn

Bài I: Biểu diễn tín hiệu của một số mã đường dây và vẽ phổ

của chúng.

I.1 Mã nguồn chương trình Matlab:

1.Mã NRZ: file nrz_l.m

function y=nrz_l(x)

for i=1:length(x)

if x(i)==0

temp(i) = -1;

else

temp(i) = +1;

end;

end

y=temp;

2.Mã CMI: file cmi_1.m

function y = cmi(x);

polar = +1; %chon cuc tinh cua bit 1 dau tien la duong

for i=1:length(x)

if x(i)==1

temp(2*i-1) = polar;

temp(2*i) = polar;

polar = -polar; %xac dinh cuc tinh cho bit 1 tiep theo

else

temp(2*i-1) = -1;

temp(2*i) = +1;

end

end

y = temp;

Trang 2

3.Mã HDB3: File hdb3.m

function y = hdb3(x)

next_polar = +1;

b=0; %so bit B giua 2 bit V

i=1;

while i<= length(x)

if x(i)==1

temp(i)=next_polar;

next_polar = -next_polar;

b=b+1;

i=i+1;

else

if (i<=length(x)-3)&(x(i+1)==0) & (x(i+2)==0) & (x(i+3)==0)

%truong hop 4 bit 0 lien tiep

if mod(b,2)==1

temp(i) = 0; %bit 0

temp(i+1) = 0; %bit 0

temp(i+2) = 0; %bit 0

temp(i+3) = -next_polar;%bit V

next_polar = -next_polar;

b=0;

i=i+4;

else

temp(i) = next_polar; %bit B

temp(i+1) = 0; %bit 0

temp(i+2) = 0; %bit 0

temp(i+3) = next_polar; %bit V

next_polar = -next_polar;

b=0;

i=i+4;

end

else

temp(i)=0; %truong hop 3 bit ke tiep khac 000

i=i+1;

end

end

Trang 3

end

y=temp;

4 Mã AMI: File ami.m

function y=ami(x)

b=+1;

for i=1: length(x)

if x(i)==1

temp(i)=b;

b=-b;

else

temp(i)=0;

end

end

y=temp;

5 Mã Manchester: File manchester.m

function y= manchester(x)

for i=1 : length(x)

if x(i)==1

temp(2*i-1) = +1;

temp(2*i) = -1;

else

temp(2*i-1) = -1;

temp(2*i) = +1;

end

end

y=temp;

6 Mã Polar RZ: File polar_RZ

function y = polar_RZ(x)

for i=1:length(x)

if x(i)==1

temp(2*i-1) = 1;

temp(2*i) = 0;

else

temp(2*i-1) = -1;

temp(2*i) = 0;

end;

Trang 4

y=temp;

7 Mã Unipolar RZ: File unipolar_RZ.m

function y=unipolar_RZ(x)

for i=1:length(x)

if x(i)==1

temp(2*i-1) =1;

temp(2*i) =0;

else

temp(2*i-1) =0;

temp(2*i) =0;

end

end

y=temp;

I.2.Chương trình vẽ và phân tích phổ của tín hiệu ở dạng mã đường dây

 File maduongday.m

clear; %Xoa cac bien hien co

bits = 30; %so bit se khao sat

t = 1:30;

data2 = round(rand(1, bits));

%Ma hoa chuoi du lieu goc%

%hdb3 la mot ham duoc dinh nghia o file hdb3.m

%ami la mot ham duoc dinh nghia o file ami.m

%unipolar_RZ la mot ham duoc dinh nghia o file unipolar_RZ.m

disp('chon dang ma duong day');

disp('1: ma NRZ');

disp('2: ma HDB3');

disp('3: ma AMI');

disp('4: ma NRZ_L');

disp(' ');

disp('10: RZ');

disp('20: ma polar_RZ');

Trang 5

disp('30: ma Manchester');

disp('40: ma CMI');

linecode = input('chon dang ma se phan tich: ');

switch linecode

%%Truong hop cac ma don bit day du

case {1}

data3 = data2;

TenDoThi='NRZ';

case {2}

data3 = hdb3(data2);

TenDoThi='HDB3';

case {3}

data3=ami(data2);

TenDoThi='AMI';

case {4}

data3=nrz_l(data2);

TenDoThi='NRZ-L';

%Truong hop cac ma co ve khong hay nua bit

case {10}

data3=RZ(data2);

data2=reshape([data2; data2],1,length(data2)*2);

t=0.5:0.5:30;

TenDoThi='RZ';

case {20}

data3=polar_RZ(data2);

data2=reshape([data2; data2],1,length(data2)*2);

TenDoThi='polar_RZ';

t=0.5:0.5:30;

case {30}

data3=manchester(data2);

data2=reshape([data2; data2],1,length(data2)*2);

TenDoThi='Manchester';

t=0.5:0.5:30;

case {40}

data3=cmi(data2);

data2=reshape([data2; data2],1,length(data2)*2);

Trang 6

TenDoThi='CMI';

t=0.5:0.5:30;

otherwise

error('nhap gia tri sai');

end

%Do thi thoi gian cua du lieu goc

subplot(3, 1, 1);

stairs(t,data2)

ylabel('Bien do');

title(TenDoThi);

axis([0 bits+1 -1.2 1.2]);

grid off;

%Do thi thoi gian cua du lieu da ma hoa

subplot(3, 1, 2);

stairs(t,data3);

ylabel(['Bien do']);

axis([0 bits+1 -1.2 1.2]);

grid off;

%Enconding using NRZ-L%

%Mo rong khong gian lay mau%

sampleRate = 2;

if mod(linecode,10)==0

Y1 = reshape(ones(sampleRate, 1)*data3, 1, sampleRate*bits*2);

else

Y1 = reshape(ones(sampleRate, 1)*data3, 1, sampleRate*bits);

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%tinh FFT va ve do thi pho cong suat%

N=sampleRate*bits;

if mod(linecode,10) == 0

FFT_Y1 = abs(fft(Y1, N*2))/N/2;

FFT_Y1 = fftshift(FFT_Y1);

subplot(3, 1, 3);

F = [-N:N-1]./N;

plot(F, FFT_Y1);

Trang 7

xlabel('frequency/F_s voi F_s = 4/T_b= 4*f_C_L_K' )

else

FFT_Y1 = abs(fft(Y1, N))/N;

FFT_Y1 = fftshift(FFT_Y1);

F = [-N/2:N/2-1]./N*2;

subplot(3, 1, 3);

axis([0 1 0 1]);

plot(F, FFT_Y1);

xlabel('frequency/F_s voi F_s = 2/T_b= 2*f_C_L_K' )

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

shg;

%Ket thuc chuong trinh

Một số kết quả cho các trường hợp:

Trang 10

Bài II: Biểu diễn tín hiệu điều chế số

II.1.Mã nguồn chương trình

%ve tin hieu dieu che so bang goc va phan tich pho cua cac tin hieu nay

%cac loai dieu che duoc minh hoa o doan chuong trinh nay bao gom

% 1: ask

% 2: fsk

% 3: psk

% 4: qask

%voi so muc tin hieu la 8

clear;

%thiet lap cac thong so co ban

M=8; %moi muc ung voi 3 bit tin hieu lien tiep

Fc=20;

Fd=10;

Fs=50;

% lua chon dang dieu che so%

disp('chon mot trong cac phuong thuc dieu che sau');

disp('1: ask (8 muc)');

disp('2: fsk (8 muc)');

disp('3: psk (8 muc)');

disp('4: qask (8 muc)');

cach_dieu_che = input('chon phuong thuc dieu che ');

%Tao day tin hieu ban dau la mot chuoi bit ngau nhien

symbols=5;

bits = symbols*3; % so luong bit trong day tin hieu se dieu che

% 3 bit tin hieu tao ra mot muc tuong ung

data= round(rand(1,bits)); % tao chuoi bit ban dau

%ve do thi tin hieu goc ban dau%

subplot(3,1,1);

stairs([1:bits],data);

Trang 11

axis([1 bits -0.2 1.2] );

subplot(2,1,2)

%tinh toan va chuyen 3 bit lien tiep thanh cac muc tin hieu tuong ung

for i=1:symbols

temp(i)=data(3*i-2)*4+data(3*i-1)*2+data(3*i);

end;

data1= temp;

subplot(3,1,2);

stairs([0:symbols-1],data1);

axis([0 symbols -0.2 M] );

%mo rong khong gian lay mau%

data1= reshape(ones(Fd,1)*data1, 1, Fd*symbols);

%ve do thi tin hieu sau khi dieu che%

switch cach_dieu_che

case {1}

subplot(3,1,3);

[y,t]=dmod(data1,Fc,Fd,Fs,'ask',M);

plot(t,y);

case {2}

subplot(3,1,3)

[y,t]=dmod(data1,Fc,Fd,Fs,'fsk',M);

plot(t,y);

case {3}

subplot(3,1,3)

[y,t]=dmod(data1,Fc,Fd,Fs,'psk',M);

plot(t,y);

case {4}

subplot(3,1,3)

[y,t]=dmod(data1,Fc,Fd,Fs,'qask',M);

plot(t,y);

otherwise

error('nhap sai gia tri yeu cau');

Trang 12

%%%%%%%%%xem ket qua duoi dang do thi%%%%%%%%%%%%

shg

II.2 Kết quả mô phỏng thu được

ASK

Trang 13

QASK

Trang 14

PSK

Trang 15

FSK

Ngày đăng: 22/06/2015, 12:51

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w