实验原理
这是一种使用脉冲幅度调制技术的线路编码。PAM4信号有四个电压电平,每个幅度电平分别对应逻辑比特00、01、10和11。换言之,PAM4编码的每个符号由2个比特组成,它们对应一个电压电平,即幅度。
00对应-3,01对应-1,10对应1,11对应3
matlab代码
clear all;
close all;
clc;
%% 参数设置
N = 10;%码元个数
Fs = 500;%采样速率
Ts = 1/Fs;%采样间隔
Rs = 50;%码元速率
UpSampleRate = Fs/Rs;
RollOff = 0.25;
Span = 6;
Sps = UpSampleRate;
SNR = 20;
%%
%%发射端
sys = randi([0,3],1,N);%生成符号序列
sys_4pam = sys*2-3;%4-pam调制
figure(1);
subplot(2,1,1);
stem(sys);
title("原始符号序列");
subplot(2,1,2);
stem(sys_4pam);
title("4-pam调制后的结果");
%升采样
sys_4pam_upsmp = zeros(1,N*UpSampleRate);
sys_4pam_upsmp(1:UpSampleRate:end) = sys_4pam;
%脉冲成形(rcosdesign)
h = rcosdesign(RollOff,Span,Sps,'sqrt');
rcos_sys_4pam =conv(h,sys_4pam_upsmp);
sendSig = rcos_sys_4pam;
%脉冲成形(rectangle)
rectangle_h = ones(1,UpSampleRate);
rectangle_sys_4pam=conv(rectangle_h,sys_4pam_upsmp);
figure(2);
subplot(2,1,1);
plot(rectangle_sys_4pam);
title("方波脉冲成形");
subplot(2,1,2);
plot(rcos_sys_4pam);
title("升余弦滚降脉冲成形");
%%
%%信道
recvSig = awgn(sendSig,SNR);
%%
%%接收端
%匹配滤波
h1 = rcosdesign(RollOff,Span,Sps,'sqrt');
recvSig_MF =conv(h1,recvSig);
%抽样量化
delay = Sps*Span;
recvSig_MF_Option = recvSig_MF(delay:UpSampleRate:end);%recvSig_MF_Option向量前N个抽样值为有用值,后面的为无用值
[index,recvSig_MF_Option_judge]= quantiz(recvSig_MF_Option(1:N),[-2 0 2],[-3 -1 1 3]);%量化%4-pam解调
sys_4pam_demod = (recvSig_MF_Option_judge + 3)/2;
figure(3);
subplot(3,1,1);
stem(recvSig_MF_Option);
title("抽样后的结果");
subplot(3,1,2);
stem(recvSig_MF_Option_judge);
title("量化后的结果");
subplot(3,1,3);
stem(sys_4pam_demod);
title("4pam解调的结果");
运行结果
最后我们看一下误码率:
syserr_prob=sum(abs(sys - sys_4pam_demod)>0)/length(sys)