%**************************************************************************
%※ 星上数据接收端 ※%
%**************************************************************************
clc;
clear all;
close all;
load send_data2;
Rb=800000;%码元速率819.2k
k=1; %一个码元间隔包括1个载波周期/2
k2=8; %采样率
fc=k*Rb; % 载波频率,
fs=fc*k2; % 信号采样率
x_size=k*k2;
%正交下变频
%A/D模数变换
% [recievdataI,recievdataQ]=QPSK_demodu(upsenddata);
datalength=length(upsenddata);
recievdataI=upsenddataI;
recievdataQ=upsenddataQ;
%FFT分路
%*******解扩不解调************%
%产生本地载波恢复
carry_I(1:datalength)=cos(2*pi*fc*(1:datalength)/fs+pi/4);
carry_Q(1:datalength)=sin(2*pi*fc*(1:datalength)/fs+pi/4);
firstdemoduQ=recievdataQ.*carry_Q;
%产生15位扩频短码
shortPNcode=shortcode(datalength/k2);
% for var=1:channel
%产生42位扩频长码
longPNcode(1,:)=longcode1(datalength/k2,1);
%DSSoutdataI=mod(walshdata96I+longPNcode,2);
%DSSoutdataQ=mod(walshdata96Q+longPNcode,2);
%长短码进行摸2加,生成本地扰码
despreadcodeI(1,:)=mod(longPNcode(1,:)+shortPNcode(1,:),2);
despreadcodeQ(1,:)=mod(longPNcode(1,:)+shortPNcode(2,:),2);
%变为双极性码,0->1,1->-1
despreadcode1I(1,:)=-2*(despreadcodeI(1,:)-0.5);
despreadcode1Q(1,:)=-2*(despreadcodeQ(1,:)-0.5);
%对本地扰码进行8倍采样
for i=1:datalength/k2
despreadcode2I(1,1+(i-1)*k2:i*k2)=despreadcode1I(1,i);
despreadcode2Q(1,1+(i-1)*k2:i*k2)=despreadcode1Q(1,i);
end
%解扩
despreadout1I(1,:)=recievdataI.*despreadcode2I(1,:);
despreadout1Q(1,:)=recievdataQ.*despreadcode2Q(1,:);
firdemdespreQ=firstdemoduQ.*despreadcode2Q(1,:);
%%
%解调
N=9;
Wn=1/4;
B = fir1(N,Wn);
demoduoutI(1,:)=despreadout1I(1,:).*carry_I;
demoduoutQ(1,:)=despreadout1Q(1,:).*carry_Q;
demodudadaI(1,:)=filter2(B,demoduoutI(1,:));%filter2滤波器无延时,filter有延时
demodudataQ(1,:)=filter2(B,demoduoutQ(1,:));
demodudataI(1,k2/2+1:datalength)=demodudadaI(1,1:datalength-k2/2);
%[demodudataI(var,:),demodudataQ(var,:)]=QPSK_demodu2(despreadout1I(var,:),despreadout1Q(var,:));
% demodudata1I(var,:)=filter2(B,demodudataI(var,:));
% demodudata1Q(var,:)=filter2(B,demodudataQ(var,:));
%8:1下采样,spreadtimes=24;
k3=spreadtimes*k2;
for i=1:datalength/k3
demodudata2I(1,i)=demodudataI(1,k3/2+1+k3*(i-1));
demodudata2Q(1,i)=demodudataQ(1,k3/2+1+k3*(i-1));
end
% end
%% *******************************%
demodudata3I=-(sign(demodudata2I)-1)/2;
demodudata3Q=-(sign(demodudata2Q)-1)/2;
%*************星上交换**********%
%CWTDM复接,去下行调制器
%% *******************************%
figure(2)
subplot(4,1,1)
plot(despreadout1Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([0 k3 -2 2])
title('输入解调信号')
grid on
subplot(4,1,2)
plot(carry_Q(1,:))
axis([0 k3 -1 1])
title('载波信号')
grid on
subplot(4,1,3)
plot(demoduoutQ(1,:))
axis([0 k3 -1 1])
title('解调输出信号')
grid on
subplot(4,1,4)
plot(demodudataQ(1,:))
axis([0 k3 -1 1])
title('滤波输出信号')
grid on
figure(3)
subplot(3,1,1)
stairs(despreadcode1Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([1 k3/8+1 -1.2 1.2])
title('despreadcode1Q')
grid on
subplot(3,1,2)
plot(despreadcode2Q(1,:))
axis([0 k3 -2 2])
title('despreadcode2Q')
grid on
subplot(3,1,3)
plot(recievdataQ(1,:))
axis([0 k3 -1.2 1.2])
title('recievdataQ')
grid on
figure(4)
subplot(3,1,1)
plot(despreadcode2Q(1,:))
%axis([0 k3*8 -1.5 1.5])
axis([0 k3 -2 2])
title('despreadcode1Q')
grid on
subplot(3,1,2)
plot(firstdemoduQ(1,:))
axis([0 k3 -2 2])
title('firstdemoduQ')
grid on
subplot(3,1,3)
plot(firdemdespreQ)
axis([0 k3 -1.2 1.2])
title('firdemdespreQ')
grid on
% subplot(4,1,4)
% plot(carry_Q(1,:))
% axis([0 k3*2 -1 1])
% title('解调输出信号')
% grid on
% %%
% figure(4)
% subplot(3,1,1)
% plot(demoduoutQ(1,:))
% %axis([0 k3*8 -1.5 1.5])
% axis([0 k3*2 -1.2 1.2])
% title('解调输出信号demoduoutQ')
% grid on
% subplot(3,1,2)
% plot(demodudataQ(1,:))
% axis([0 k3*2 -1 1])
% title('滤波输出信号demodudataQ')
% grid on
% subplot(3,1,3)
% plot(demodudata2Q(1,:))
% axis([1 k3/4 -1 1])
% title('下采样输出信号demodudata2Q')
% grid on
% %% *******************************%
% figure(3)
% subplot(2,1,1)
% % stairs(despreadout2I(1,:))
% % axis([1 k3/4 -1.2 1.2])
% % title('原始发送信号')
% % grid on
% % subplot(3,1,2)
% stairs(demodudata3I(1,:))
% %axis([0 k3*8 -1.5 1.5])
% axis([1 k3/4 -0.2 1.2])
% title('解扩输出信号')
% grid on
% subplot(2,1,2)
% stairs(walshdataI(1,:))
% axis([1 k3/4 -0.2 1.2])
% title('原始发送信号')
% grid on
评论0