Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Demodulate FSK signal Matlab

Status
Not open for further replies.

lynx_z3

Newbie level 1
Newbie level 1
Joined
Feb 19, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
hi i need help in writing the demodulation code for the FSK system below any help would be appreciated. cause i have no idea how to move forward with this

Code:
function bfsk_project(g,f0,f1)
if nargin > 3
    error('Too many input arguments')
elseif nargin==1
    f0=1;
    f1=2;
elseif nargin==2
    f1=2;
end

val0=ceil(f0)-f0;
val1=ceil(f1)-f1;
if val0 ~=0 || val1 ~=0;
    error('Frequency must be an integer');
end

if f0<1 || f1<1;
    error('Frequency must be bigger than 1');
end

t=0:2*pi/99:2*pi;
cp=[];
cp1=[];
sp=[];
sp1=[];
mod=[];
mod1=[];
bit=[];
bit1=[];
noise_amp = 0.1;% set noise level 0.1~=6dB=SNR=Eb/No

%Channel Coding using repetition Code (3,1)
h = repmat(g,3,1); % to repeat the matrix
res = reshape(h, 1,3*(length(g)));% to resize the matrix

%Binary Pulse Shaping
for n=1:length(g);
    if g(n)==0;
        die1=ones(1,100);
        c1=sin(f0*t);
        se1=zeros(1,100);
    else g(n)=1;
        die1=ones(1,100);
        c1=sin(f1*t);
        se1=ones(1,100);
    end
    cp1=[cp1 die1];
    mod1=[mod1 c1];
    bit1=[bit1 se1];
end
    
%Binary Pulse Shaping for Encoded Signal
for n=1:length(res);
    if res(n)==0;
        die=ones(1,100);
        c=sin(f0*t);
        se=zeros(1,100);
    else res(n)=1;
        die=ones(1,100);
        c=sin(f1*t);
        se=ones(1,100);
    end
    cp=[cp die];
    mod=[mod c];
    bit=[bit se];
end



%FSK Modulation
fsk=cp.*mod;

% Add White Noise to Modulated FSK Signal
noise_awgn = noise_amp*randn(1,length(fsk));% noise generator
fsk_noise = fsk + noise_awgn;%modulated carrier plus noise

% Graphics
subplot(6,1,1);plot(bit1,'LineWidth',1.5);grid on;
title('Binary Signal');
axis([0 100*length(g) -2.5 2.5]);

subplot(6,1,2);plot(bit,'LineWidth',1.5);grid on;
title('Binary Signal w/ Error Correction (3,1) Repetition Code');
axis([0 100*length(res) -2.5 2.5]);

subplot(6,1,3);plot(fsk,'LineWidth',1.5);grid on;
title('FSK modulation');
axis([0 100*length(res) -2.5 2.5]);

subplot(6,1,4);plot(noise_awgn,'LineWidth',1.5);grid on;
title('Additive White Gaussian Noise');
axis([0 100*length(res) -2.5 2.5]);

subplot(6,2,7);plot(fsk_noise,'LineWidth',1.5);grid on;
title('FSK modulation w/ white noise');
axis([0 100*length(res) -2.5 2.5]);
 

see this post

i think it will help you
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top