ELEC 456 CommunicationsJerry Johnson

Dr. Bernard HarrisDecember 12th, 2010

MATLAB HAND-IN #9

Simulation of the Noise Performance of a FM Communication System

Problem 6.17

In this problem, we will do this problem using the discriminator developed in problems 4.26, and 4.28 to construct the Matlab simulation system.

Matlab code for Problem 6.17

%--------------------------------------------------------------- % Problem 6.17, Call it mat9a in the program.

%--------------------------------------------------------------- function Ac = mat9a

%--------------------------------------------------------------- %-----Parameter------------------------------------------------- fc = 100; % Carrier frequency (kHz)

Fs = 1024; % Sampling rate (kHz)

fm = 0.5; % Modulating frequency (kHz)

Ts = 1/Fs; % Sample period (ms)

t = (0:Ts:10); % Observation period (ms)

C_N = 20; % channel SNR (dB)

Ac = 1;

Bt = 20; % (kHz)

W = 5; % (kHz)

SNRc = C_N+10*log10(Bt/W);

%--------------------------------------------------------------- %-----------Message Sisgnal------------------------------------- m = cos(2*pi*fm*t); % modulating signal

kf = 2.4; % modulator sensitivity index (Bt/2)(kHz)

%--------------------------------------------------------------- %-------------FM modulate--------------------------------------- FMsig = FMmod(fc,t,kf,m,Ts);

%--------------------------------------------------------------- %-----------Add narrowband noise-------------------------------- %-Create bandpass noise by low pass filtering complex noise----- P = 0.5;

N = P/10.^(SNRc/10);

sigma = sqrt(N);

noise = randn(size(FMsig)) + j*randn(size(FMsig));

LPFnoise = LPF(Fs,noise,0.05); % 0.01 =>Bt 50 kHz eq. Noise BW BPnoise = real(LPFnoise.*exp(j*2*pi*fc/Fs*(1:length(FMsig)))); scale = sigma / std(BPnoise);

%--------------------------------------------------------------- FMsign = FMsig + scale*BPnoise;

subplot(4,1,1), plot(t,FMsig), grid on

subplot(4,1,2), plot(t,FMsign), grid on

%------------------FM Receiver---------------------------------- Rx_c = FMdiscriminator(fc,FMsig,Ts);

Rx_n = FMdiscriminator(fc,FMsign,Ts);

t = t(round(1/Ts):end); %remove transient

subplot(4,1,3), plot(t,Rx_c); grid on

subplot(4,1,4), plot(t,Rx_n); grid on

%--------------------------------------------------------------- %----------------Plot Result------------------------------------ % FFTsize = 4096

% S = spectrum(FMsig,FFTsize);

% Freq = [0:Fs/FFTsize:Fs/2];

% subplot(2,1,1), plot(t,s);

% axis9[0 0.5 -1.5 1.5]), grid on

% subplot(2,1,2), stem(Freq,sqrt(S/682));

% axis([95 105 0 1]); grid on

%--------------------------------------------------------------- % FM modulator

%--------------------------------------------------------------- function s = FMmod(fc,t,kf,m,Ts)

theta = 2*pi*fc*t+2*pi*kf*cumsum(m)*Ts; % integrate signal

s = cos(theta);

%--------------------------------------------------------------- % FM discriminator

%--------------------------------------------------------------- function D3 = FMdiscriminator(fc,S,Ts)

t = (0:Ts:10*Ts); % for filter

%--------FIR differentiator(Fs = 1024 kHz, BT/2 = 10 kHz)------- FIRdiff = [1.60385 0.0 0.0 0.0 -0.0 0.0 0.0 -0.0 -0.0 -0.0 -1.60385]; BP_diff = real(FIRdiff.*exp(j*2*pi*fc*t));

%--------------------------------------------------------------- % Low Pass filter - Fs = 1024 kHz, f3dB = 5 kHz--------------- LPF_B = 1E-4*[0.0706 0.2117 0.2117 0.0706];

LPF_A = [1.0000 -2.9223 2.8476 -0.9252];

D1 = filter(BP_diff, 1, S); % Bandpass discriminator

D2 = EnvDetect(D1); % Envelope detection

D2 = D2 - mean(D2); % remove dc

D3 = filter(LPF_B,LPF_A,D2); % Low-pass filtering

D3 = D3(round(1/Ts):end); % remove transient (approx 1s) %--------------------------------------------------------------- %...