%- 2DPSK 调制与解调
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Initial_Part>>>>>>>>>>>>>>>>>>>>> %--------------------------------------------------- function y=dpsk2() fs = 30000;
Time_Hold_On = 0.1;
Num_Unit = fs * Time_Hold_On; High_Level = ones ( 1, Num_Unit ); Low_Level = zeros ( 1, Num_Unit ); w = 300; A = 1;
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Initial_The_Signal>>>>>>>>>>>>>>> %--------------------------------------------------- Sign_Set = [0,1,1,0,1,0,0,1]
Lenth_Of_Sign = length ( Sign_Set );
st = zeros ( 1, Num_Unit * Lenth_Of_Sign );
sign_orign = zeros ( 1, Num_Unit * Lenth_Of_Sign ); sign_result = zeros ( 1, Num_Unit * Lenth_Of_Sign ); t = 0 : 1/fs : Time_Hold_On * Lenth_Of_Sign - 1/fs;
%---------------------------------------------------
%>>>>>>>>>>>Generate_The_Original_Signal>>>>>>>>>>>> %--------------------------------------------------- for I = 1 : Lenth_Of_Sign if Sign_Set(I) == 1 sign_orign( (I-1)*Num_Unit + 1 : I*Num_Unit) = High_Level; else sign_orign( (I-1)*Num_Unit + 1 : I*Num_Unit) = Low_Level; end end
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Modulation_Part>>>>>>>>>>>>>>>>>> %--------------------------------------------------- for I = 1 : Lenth_Of_Sign if Sign_Set(I) == 1 st( (I-1)*Num_Unit + 1 : I*Num_Unit) = A * cos ( 2 * pi * w * t( (I-1)*Num_Unit + 1 : I*Num_Unit ) + ( pi / 2 ) ); else st( (I-1)*Num_Unit + 1 : I*Num_Unit) = A * cos ( 2 * pi * w * t( (I-1)*Num_Unit + 1 : I*Num_Unit ) ); end end
8
figure
subplot ( 2, 1, 1 ) plot(t, sign_orign);
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - (A / 2), A + (A / 2) ] ); title ( '原始信号' ); grid
subplot ( 2, 1, 2 ); plot ( t, st );
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - 3*(A / 2), 3*(A / 2) ] ); title ( '调制后的信号' ); grid
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>相乘>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %--------------------------------------------------- dt = st .* cos ( 2 * pi * w * t );
figure
subplot(2,1,1) plot ( t, dt );
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - 3*(A / 2), 3*(A / 2) ] ); title ( '相乘后的波形' ); grid
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>>低通滤波部分>>>>>>>>>>>>>>>>>>>> %---------------------------------------------------
[N,Wn] = buttord( 2*pi*50, 2*pi*150,3,25,'s'); %临界频率采用角频率表示 [b,a]=butter(N,Wn,'s');
[bz,az]=impinvar(b,a,fs); %映射为数字的
dt = filter(bz,az,dt);
subplot(2,1,2) plot ( t, dt );
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - 3*(A / 2), 3*(A / 2) ] ); title ( '低通滤波后的波形' ); grid
%---------------------------------------------------
%>>>>>>>>>>>>>抽样判决 & 逆码变换部分>>>>>>>>>>>>>>> %--------------------------------------------------- for I = 1 : Lenth_Of_Sign
if dt((2*I-1)*Num_Unit/2) < 0.25
9
sign_result( (I-1)*Num_Unit + 1 : I*Num_Unit) = High_Level; else sign_result( (I-1)*Num_Unit + 1 : I*Num_Unit) = Low_Level; end end
figure
plot ( t, sign_result );
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - 3*(A / 2), 3*(A / 2) ] ); title ( '逆码变换后的波形' ); grid
3.2 2DPSK模拟调制和差分相干解调法仿真图
10
图2.1 2DPSK模拟调制和差分相干解调法仿真图
3.2调试过程及结论
2DPSK信号经相关模块调试后的波形图如下:
11
调制过后加入高斯白噪声,连接到带通滤波器,去除调制信号以外的在信道中混入的噪声,再连接到相乘器。此相乘器是一路延时一个码元时间后与另一路信号相乘。作用是去除调制信号中的载波成分。
信号经过低通滤波器后,去除高频成分,得到包含基带信号的低频信号。经过抽样判决,便还原成原始信号。
12