You are on page 1of 8

Bài 2: TRUYỀN DẪN DỮ LIỆU SỐ

Mục tiêu
• Hiểu nguyên lý một số loại mã đường truyền trong truyền dẫn dữ liệu số:
NRZ-L, Bipolar-AMI, Manchester.
• Phân tích mật độ phổ các phương pháp mã đường truyền.

1.1. LÝ THUYẾT

1.1.1. Nguyên lý mã hóa đường dây

Trong các hệ thống truyền dẫn dữ liệu số với khoảng cách ngắn sử dụng dây
dẫn, người ta thường sử dụng kỹ thuật mã hóa đường dây. Khi đó, các dữ liệu số
được biểu diễn thông qua những tín hiệu có biên độ rời rạc. Có khá nhiều loại mã
đường dây đang đựơc sử dụng rộng rãi, mỗi loại đều có ưu và nhược điểm riêng.
Tùy vào yêu cầu của hệ thống mà ta chọn loại mã nào cho phù hợp. Hình dưới mô
tả một số mã đường dây phổ biến.

Trang 1
Mật độ phổ của các loại mã đường truyền khác nhau:

1.1.2. Một số hàm Matlab

try, catch:

Execute statements and catch resulting errors

try
statements
catch exception
statements
end
try statements, catch statements end executes the
statements in the try block and catches resulting errors in
the catch block. This approach allows you to override the
default error behavior for a set of program statements. If
any statement in a try block generates an error, program
control goes immediately to the catch block, which contains
your error handling statements.

set:
Set graphics object properties
set(H,Name,Value) specifies a value for the property
Name on the object identified by H. Use single quotes around
the property name, for example, set(H,'Color','red'). If H

Trang 2
is a vector of objects, then set sets the property for all
the objects.

gca:
gca returns the current axes or chart for the current
figure, which is typically the last one created or clicked
with the mouse. Graphics functions, such as title, target
the current axes or chart. Use ax to access and modify
properties of the axes or chart. If axes or charts do not
exist, then gca creates Cartesian axes.
1.1.3. Chương trình mẫu thực hiện mã hóa U NRZ-L

Tạo chuỗi dữ liệu nhị phân và thực hiện điều chế xung:

bitstream = [ 0 1 0 0 1 1 0 0 0 1 0]
pulse_high = 5;
pulse_low = 0;

for bit = 1:length(bitstream)


% set bit time
bt = bit-1:0.001:bit;

if bitstream(bit) == 0
% low level pulse
y = (bt<bit)*pulse_low;

else
% high level pulse
y = (bt<bit) * pulse_high;
end

try
if bitstream(bit+1) == 1
y(end) = pulse_high;
end
catch e
% assume next bit is 1
y(end) = pulse_high;
end

% draw pulse and label


plot(bt, y, 'LineWidth', 2);
text(bit-0.5,pulse_high+0.5,…
num2str(bitstream(bit)), 'FontWeight', 'bold')
hold on;
end

Trang 3
% draw grid
grid on;
axis([0 length(bitstream) pulse_low-1…
pulse_high+1]);
set(gca,'YTick', [pulse_low pulse_high])
set(gca,'XTick', 1:length(bitstream))
title('Unipolar Non-Return-to-Zero Level')

Quan sát tín hiệu sau điều chế:

1.1.4. Chương trình mẫu phân tích phổ của Polar NRZ-L

clear all, close all, clc


bitstream = randi([0 1], 1, 10000);
fb=100;

pulse_high = 1;
pulse_low = -1;
yy=[];

for bit = 1:length(bitstream)


% set bit time
bt = bit-1:0.25:(bit-0.25);

if bitstream(bit) == 0
% low level pulse
y = (bt<bit)*pulse_low;

else
% high level pulse
y = (bt<bit) * pulse_high;
end

Trang 4
yy=[yy y];

end
k=zeros(100,400);
for j=1:1:100
k(j,:)=yy(400*j-399:400*j);
sep(j,:)=fft(k(j,:),128);

end
n=size(sep,2);
fs=4*fb;
f = (0:n-1)*(fs/n); % frequency range

m_sep=mean((abs(sep).^2),1)/fs;
figure(1);
plot(f,m_sep);
% draw grid
grid on;
ylabel('Mean square voltage');
xlabel('Frequency');
title('Polar Non-Return-to-Zero Level');

1.2. THỰC HÀNH

1.2.1. Unipolar Nonreturn to Zero level

Câu 1: Phân tích đoạn chương trình mẫu ở mục 1.1.3 ?

Câu 2: Thay đổi chuỗi dữ liệu toàn bit “0” quan sát và vẽ tín hiệu sau điều
biến?

Câu 3: Thay đổi dữ liệu toàn bit “1” quan sát và vẽ tín hiệu sau điều biến?

1.2.2. Polar Nonreturn to Zero level

Câu 4: Từ chương trình mẫu 1.1.3, thay đổi “pulse_low = -5”, quan sát và
vẽ tín hiệu sau mã hóa?

Câu 5: Phân tích đoạn chương trình mẫu ở mục 1.1.4?

Trang 5
Câu 6: Xây dựng mô phỏng theo mô hình sau, so sánh kết quả phổ với câu
5?

1.2.3. Bipolar-AMI

Cho gợi ý đoạn chương trình gợi ý sau:

% pulse height
pulse = 5;

% assume that current pulse level is a "low" pulse


(binary 1)
% this is the pulse level for the bit before given
bitstream
current_level = -pulse;

for bit = 1:length(bitstream)


% set bit time
bt=bit-1:0.001:bit;

if bitstream(bit) == 0
% binary 0, set to zero
……………………………………
else
% each binary 1 has the opposite pulse level from the
previous
……………………………………
……………………………………
end

% assign last pulse point by inspecting the following bit


try
% we care only about ones as they use alternate levels
if bitstream(bit+1) == 1
y(end) = -current_level;

Trang 6
end
catch e
% bitstream end; assume next bit is 0
y(end) = -current_level;
end

Câu 7: Hoàn thiện chương trình thực hiện mã hóa Bipolar-AMI?

Câu 8: Vẽ phổ tín hiệu mã hóa Bipolar-AMI?

1.2.4. Manchester.

Cho gợi ý đoạn chương trình gợi ý sau:

% pulse height
pulse = 1;
yy=[];
for bit = 1:length(bitstream)
% set bit time
bt = bit-1:0.1:(bit-0.1);

if bitstream(bit) == 1
% low -> high
y = (bt<bit) * pulse …………………… * (bt < bit -
0.5);
% set last pulse point to high level
current_level = pulse;
else
% high -> low
y = -(bt<bit) * pulse + …………………… (bt < bit -
0.5);
% set last pulse point to low level
current_level = -pulse;
end

try
% if the next bit is the same as this one
change the level
if bitstream(bit+1) == bitstream(bit)
y(end) = -current_level;
else
y(end) = current_level;
end
catch e
% assume next bit is the same as the last one

Trang 7
y(end) = current_level;
end

Câu 9: Hoàn thiện chương trình thực hiện mã hóa Manchester?

Câu 10: Vẽ phổ tín hiệu mã hóa Manchester?

Trang 8

You might also like