Search This Blog

Thursday 29 October 2015

BFSK


clc;
clear all;
close all;
fc1=input('Enter carrier frequency for binary 1: ');
fc2=input('Enter carrier frequency for binary 0: ');
fs=input('Enter sampling frequency: ');
bs=input('Enter bit sequence: ');
L1=length(bs);
I=[];
for i=1:L1
    I=[I bs(i)*ones(1,fs)];
end
L2=length(I);
t=(10/L2):(10/L2):10;
C1=sin(2*pi*fc1*t);
C2=sin(2*pi*fc2*t);
BFSK=[];
for i=1:L2
    if I(i)==1
        BFSK=[BFSK C1(i)];
    else
        BFSK=[BFSK C2(i)];
    end
end
R=[];
for l=1:length(BFSK)
    if BFSK(l)==C1(l)
        R=[R 0];
    elseif BFSK(l)==C2(l)
        R=[R 1];
    end
end
subplot(5,1,1); plot(t,I);
xlabel('Time'); ylabel('Levels'); title('Bit sequence');
subplot(5,1,2); plot(t,C1);
xlabel('Time'); ylabel('Amplitude'); title('Carrier wave for binary 1');
subplot(5,1,3); plot(t,C2);
xlabel('Time'); ylabel('Amplitude'); title('Carrier wave for binary 0');
subplot(5,1,4); plot(t,BFSK);
xlabel('Time'); ylabel('Amplitude'); title('BFSK signal');
subplot(5,1,5); plot(t,R);
xlabel('Time'); ylabel('Levels'); title('Demodulated signal'); 

No comments:

Post a Comment