数字基带传输概念

基本结构图

二元信号接收方法

误码分析

符号同步-早迟门

代码模块
%% 基带数字信号传输仿真
clear
clc
close all;
format long
% 参数设置
N = 10^6; % 比特数
rolloff = 0.25; % 滚降系数
span = 4; % 滤波器的跨度
sps = 9; % 每个符号的采样点数
SNR = 10; % 信噪比(dB)
% 定义头序列的长度
len = 50;
% 生成头序列
sequence = double(repmat('01', 1, len/2)) - double('0');
% 贝努力随机数发生器
data = randi([0 1], 1, N);
% 添加头序列
data=[sequence,data];
% 双极型非归零调制
data_bipolar = 2 * data - 1;
% 平方根升余弦FIR滤波器
h = rcosdesign(rolloff, span, sps);
% 上采样
data_upsampled = upsample(data_bipolar, sps);
% 上采样信号绘图
figure
subplot(2,2,1)
plot(1:200,data_upsampled (sps*len+1:sps*len+200));
xlabel('采样点(不包含头序列)');
ylabel('幅值');
title('上采样信号');
% 脉冲整形
data_filtered = conv(data_upsampled, h,'same');
% 平方根升余弦FIR滤波器滤波信号绘图
subplot(2,2,2)
plot(1:200,data_filtered(sps*len+1:sps*len+200));
xlabel('采样点(不包含头序列)');
ylabel('幅值');
title('平方根升余弦FIR滤波器滤波信号');
% 添加高斯白噪声
data_noisy = awgn(data_filtered, SNR, 'measured');
% 添加高斯白噪声信号绘图
subplot(2,2,3)
plot(1:200,data_noisy(sps*len+1:sps*len+200));
xlabel('采样点(不包含头序列)');
ylabel('幅值');
title('添加高斯白噪声信号');
% 5点早迟门同步
% 初始化提取的采样点索引
select_sample = 5;
% 计算早迟门同步误差并得到索引
select_sample_add=0;
% 计算所有头序列符号采样点索引
for i = 1:len-1
% 符号取值范围
symbol = data_noisy((i-1)*sps+ceil(sps/2): i*sps-1+ceil(sps/2));
select_sample=earlyorlate(select_sample,sps,symbol,Inf,0);
select_sample_add=select_sample_add+select_sample;
end
% 采样时刻均值
select_sample=round(select_sample_add/(len-1));
% 匹配滤波
matched_output = conv(data_noisy, fliplr(h),'same');
% 匹配滤波结果绘图
subplot(2,2,4)
plot(1:200,matched_output(sps*len+1:sps*len+200));
xlabel('采样点(不包含头序列)');
ylabel('幅值');
title('匹配滤波信号');
% 提取采样点
data_sampled=matched_output(len*sps-floor(sps/2)+select_sample:sps:end-floor(sps/2));
% 判决
received_bits = data_sampled > 0;
% 计算误码率
ber = sum(received_bits ~= data(len+1:end)) / N;
fprintf('Bit Error Rate: %e\n', ber);
% 单符号早迟门采样点确定
% select_sample_ini:采样点,sps:符号长度,symbol:符号值
% threshold_ini:上一次早迟判断所用差值,num:上一次早迟判断结果
function select_sample=earlyorlate(select_sample_ini,sps,symbol,threshold_ini,num)
select_sample=select_sample_ini;
% 2个早采样点和2个迟采样点索引
early_samples = [select_sample-2,select_sample-1];
late_samples = [select_sample+1,select_sample+2];
% 符号内2个早采样点和2个迟采样点
early_values = symbol(early_samples);
late_values = symbol(late_samples);
% 计算早、迟门的幅值
early_energy = sum(early_values);
late_energy = sum(late_values);
% 计算同步差值
timing_error = early_energy - late_energy;
threshold=0.1*max(abs(early_energy),abs(late_energy));
% 判断是否移动
if threshold<threshold_ini% 差值未扩大
switch 1
case (timing_error>threshold)&&(select_sample>3)%左移
% 得到下一符号索引
select_sample=max(earlyorlate(select_sample-1,sps,symbol, threshold,-1),3);
case (timing_error<-threshold)&&(select_sample<sps-2)%右移
% 得到下一符号索引
select_sample=min(earlyorlate(select_sample+1,sps,symbol, threshold,1),sps-2);
otherwise %不变
end
else
select_sample=select_sample-num;% 差值扩大,返回上一次结果
end
end
结果展示
