通信原理实验五:数字基带系统
所花时间:3.5h
一、题目:
搭建一个实用的 2PSK 通信系统,要求其码元速率 1kHz,载波频率 5kHz,信 号带宽不超过 1.5kHz,并采用相干接收机对信号进行解调。
- 选择合适的传输波形,并确定收发滤波器的参数。
- 绘制发送信号波形及功率谱,以及无噪声条件下判决前的眼图。
- 在 AWGN 信道下对以上系统进行仿真,获得其误码率曲线(SNR=-3dB…8dB)。
二、题目解析
带通传输系统的系统模型:
可以看作基带传输系统+调制解调过程
因为之前的实验中已经完成了基带传输系统的仿真,2PSK的传输只需增加上调制解调过程即可,但有一些小细节需要注意。
三、需注意的细节
1、fs的选取:此时的fs>fc+B/2,则即一个码元长度采样点数应当改变
2、抽样判决点
因为滤波器一定会有系统延时,带通传输系统的系统模型有三个滤波器,所以初始采样点必须加上三个系统延时
decision_idx = (1+(flt_delay+flt_delay+group_delay)):sa_per_sym:length(r_match_t);
group_delay——解调时的系统延时
2个flt_delay——2个根升余弦滤波器的系统延时
四、完整的代码
clear all;
close all;
clc;
%2PSK成型滤波器调制解调和误码率分析
%%
RB = 1e3;
fc = 5e3;
B = 1.5e3;
rolloff = B/RB - 1;
sa_per_sym = 20;% 即一个码元长度有多少个采样点 % 采样率
N = 10000;% 比特数据长度
fs = RB * sa_per_sym;
% 设计根升余弦滤波器,阶数为span*sa_per_sym, % 滤波器延迟为 span*sa_per_sym/2 个样点
span = 20;
flt_b = rcosdesign(rolloff, span, sa_per_sym, 'sqrt');
flt_delay = span*sa_per_sym/2;
% 发送filter
bits = randi(2,N,1); % 信源产生随机
bb_ori = -2*bits + 3; % 码型变换(注意是一个bit对应一个点)
bb_pulse = upsample(bb_ori, sa_per_sym); % 插0获得冲激序列
m_t = filter(flt_b, 1, bb_pulse); % 冲激序列通过成形滤波器获得发送波形
%调制
t = (0:N*sa_per_sym-1)'/fs;
c_t = cos(2*pi*fc*t);
s_t = m_t .*c_t;
pow_s = 1/sa_per_sym/2; % 频带发送信号的功率
%接收-无噪声
recv_t = s_t;
[remod_t,remod_bits,group_delay] = BPSK_remodulate(recv_t,RB,fc,fs,N);%解调
r_match_t = filter(flt_b, 1, remod_t); % 匹配滤波器
%抽样判决
decision_idx = (1+(flt_delay+flt_delay+group_delay)):sa_per_sym:length(r_match_t);
%群延时:3个滤波器:2个根升余弦滤波器和一个LPF的群延时
r_sampled = r_match_t(decision_idx);
recv_bits = zeros(length(r_sampled),1);
%判决
recv_bits(r_sampled < 0) = 1;
%误码率计算
[number,ratio] = symerr(bits(1:length(recv_bits)) -1,recv_bits);
%%
%绘制发射信号时域波形、功率谱及接收信号眼图。
figure(1),plot((0:length(s_t)-1)/RB/sa_per_sym,s_t);axis([0,0.1,-0.6,0.6]);title('发射信号时域波形');
P = abs(fft(s_t)).^2;
figure(2),plot(P);title('功率谱');axis([0,8e4,0,6e5]);
eyediagram(r_match_t,4*sa_per_sym),title('rolloff = 0.5无噪声判决前的眼图');
%%
%在 AWGN 信道下仿真
SNR=(-3:1:8)';
N = length(s_t);
SimuRat = zeros(length(SNR),1);
for i = 1:length(SNR)
snr = SNR(i);
n_pow = pow_s/10^(0.1*snr);
n_t = bandlimit_noise(N,fs,fc,B,n_pow);
r_t = n_t + s_t; %信号+信道的噪声
%接收-噪声
[remod_t,remod_bits,group_delay] = BPSK_remodulate(r_t,RB,fc,fs,N/sa_per_sym);%解调
r_match_t = filter(flt_b, 1, remod_t); % 匹配滤波器
%抽样判决
decision_idx = (1+(flt_delay+flt_delay+group_delay)):sa_per_sym:length(r_match_t);
%群延时:3个滤波器:2个根升余弦滤波器和一个LPF的群延时
r_sampled = r_match_t(decision_idx);
recv_bits = zeros(length(r_sampled),1);
%判决
recv_bits(r_sampled < 0) = 1;
%误码率计算
[number,ratio] = symerr(bits(1:length(recv_bits)) -1,recv_bits);
SimuRat(i) = ratio;
clear all;
close all;
clc;
%2PSK成型滤波器调制解调和误码率分析
%%
RB = 1e3;
fc = 5e3;
B = 1.5e3;
rolloff = B/RB - 1;
sa_per_sym = 20;% 即一个码元长度有多少个采样点 % 采样率
N = 10000;% 比特数据长度
fs = RB * sa_per_sym;
% 设计根升余弦滤波器,阶数为span*sa_per_sym, % 滤波器延迟为 span*sa_per_sym/2 个样点
span = 20;
flt_b = rcosdesign(rolloff, span, sa_per_sym, 'sqrt');
flt_delay = span*sa_per_sym/2;
% 发送filter
bits = randi(2,N,1); % 信源产生随机
bb_ori = -2*bits + 3; % 码型变换(注意是一个bit对应一个点)
bb_pulse = upsample(bb_ori, sa_per_sym); % 插0获得冲激序列
m_t = filter(flt_b, 1, bb_pulse); % 冲激序列通过成形滤波器获得发送波形
%调制
t = (0:N*sa_per_sym-1)'/fs;
c_t = cos(2*pi*fc*t);
s_t = m_t .*c_t;
pow_s = 1/sa_per_sym/2; % 频带发送信号的功率
%接收-无噪声
recv_t = s_t;
[remod_t,remod_bits,group_delay] = BPSK_remodulate(recv_t,RB,fc,fs,N);%解调
r_match_t = filter(flt_b, 1, remod_t); % 匹配滤波器
%抽样判决
decision_idx = (1+(flt_delay+flt_delay+group_delay)):sa_per_sym:length(r_match_t);
%群延时:3个滤波器:2个根升余弦滤波器和一个LPF的群延时
r_sampled = r_match_t(decision_idx);
recv_bits = zeros(length(r_sampled),1);
%判决
recv_bits(r_sampled < 0) = 1;
%误码率计算
[number,ratio] = symerr(bits(1:length(recv_bits)) -1,recv_bits);
%%
%绘制发射信号时域波形、功率谱及接收信号眼图。
figure(1),plot((0:length(s_t)-1)/RB/sa_per_sym,s_t);axis([0,0.1,-0.6,0.6]);title('发射信号时域波形');
P = abs(fft(s_t)).^2;
figure(2),plot(P);title('功率谱');axis([0,8e4,0,6e5]);
eyediagram(r_match_t,4*sa_per_sym),title('rolloff = 0.5无噪声判决前的眼图');
%%
%在 AWGN 信道下仿真
SNR=(-3:1:8)';
N = length(s_t);
SimuRat = zeros(length(SNR),1);
for i = 1:length(SNR)
snr = SNR(i);
n_pow = pow_s/10^(0.1*snr);
n_t = bandlimit_noise(N,fs,fc,B,n_pow);
r_t = n_t + s_t; %信号+信道的噪声
%接收-噪声
[remod_t,remod_bits,group_delay] = BPSK_remodulate(r_t,RB,fc,fs,N/sa_per_sym);%解调
r_match_t = filter(flt_b, 1, remod_t); % 匹配滤波器
%抽样判决
decision_idx = (1+(flt_delay+flt_delay+group_delay)):sa_per_sym:length(r_match_t);
%群延时:3个滤波器:2个根升余弦滤波器和一个LPF的群延时
r_sampled = r_match_t(decision_idx);
recv_bits = zeros(length(r_sampled),1);
%判决
recv_bits(r_sampled < 0) = 1;
%误码率计算
[number,ratio] = symerr(bits(1:length(recv_bits)) -1,recv_bits);
SimuRat(i) = ratio; ```
function n_t = bandlimit_noise(N,fs,fc,B,n_pow)
% 产生特定功率的带限高斯白噪声
% 输入: N - 产生的噪声的长度
% fs - 仿真采样率
% fc - 带限噪声中心频率
% B - 带限噪声的带宽
% n_pow - 带限噪声的功率
% 输出: n_t - 带限噪声
%带通滤波器
filter_b_L = 4000;
filter_b = fir1(filter_b_L, [(fc-B/2)/(fs/2), (fc+B/2)/(fs/2)]);
n_fullband_pow = n_pow/(B/(fs/2));
noise_t = sqrt(n_fullband_pow)*randn(N+filter_b_L,1);
n_t = filter(filter_b,1,noise_t);
n_t = n_t(end-N+1:end);
end
来源:CSDN
作者:weixin_43599963
链接:https://blog.csdn.net/weixin_43599963/article/details/103608584