Download - Demodulation bpsk up

Transcript
Page 1: Demodulation bpsk up

function DemBPSK(x,fc,fs,br,N,Time)

Ts=1/fs;onebit=fs/br; %number of samples per bit (one sample is constituent of # bits)b=onebit;n=round((length(x)-1)/onebit); %the bits transmittedc=1;k=[];

for m=1:n; % iteration from 1 to number of bits(blocks)y=x(c:b); % take the part of the needed signal for one bit (eg. 1st block)q=sin(2*pi*((c:b)-1)*fc*Ts); %reference signal for Quadrature**Taking first part of cos x%figure;%plot(q);i=-sin(2*pi*((c:b)-1)*fc*Ts); % reference signal with -sin ->Inphasea=y.*q; % (received signal(1st block)) . (reference signal for Quadrature) ** cos(x)*m(t)d=y.*i; % (received signal(in phase, 1st block)) . (reference signal for Inphase)t= sum(a)-sum(d); % accumulative effect of first blockif t>0; p=ones(1); %ones (binary)else p=zeros(1); %zerosend

k=[k p]; %accumulate the value of output into kb=b+onebit; %update the value of b for the next input (next block)c=c+onebit; %update the value of c for the next input (2, next block)end

figure;subplot(3,1,1);plot(x);grid on;title('BPSK Data at Receiver');axis([0 length(x) -1 1]);

subplot(3,1,2) %plot the output (bpsk signal)nn=0:n-1;plot(nn,k,'LineWidth',1); xlabel('N');ylabel('Binary Data');title('BPSK DeModulated Data');axis([0 N+1 -0.5 1.5]);grid on;[r]=data_received(k,Ts);

subplot(3,1,3)stem(nn,r);xlabel('Samples');ylabel('Binary Data');axis([0 N -0.5 1.5]);title('Received Signal');receivedString=bin2str(r);disp(receivedString)