Question: matlab threshold effect in fm demodulation pll

Hi all

I want to simulate the threshold effect in FM modulation\ demodulation, in theory ,when the carrier to noise ratio (the modulated signal SNR)fall below a certain value ,then the signal to noise ratio(of the demodulated signal will fall dramatically and the signal will not demodulated , click sounds will be heard in the output of demodulator. I have tried first "slope detector" as a demodulator, but the threshold effect didn't appear at all when i decrease the C/N ratio to below 10 dB as theory, then I have tried PLL demodulator , but also the same problem . my main purpose is to demonstrate the threshold effect when the signal is sound wave , and also sinusoidal signal. here is the code for both slope detector demodulator and PLL demodulator,,

I have spent alot of time but no progress,

please help me with matlab and theoretical explanation :)

if true
% clear all;
% close all;
% clc;
% %%%%%% i have tried many values for the parameter ,, the problem is the
% %%%%%% same
% f=8000;%Carrier frequency
% fs=40000;%Sample frequency
% snr=100;
% fcu0=500; %cut off frequency for loop filter
% fcu=1000;   % cut off frequency for LPF for the output signal
% f1=100; % modulated signal frequency
% kf=1000; % frequency deviation in Hz
% wn0=2*fcu0/fs; % for loop filter
% wn=2*fcu/fs; % for LPF
% phi_hat(1)=10;
% e(1)=0;
% phd_output(1)=0;
% vco(1)=0;
% Ts=1/fs;
% Psig=1;
% %%%%%%%%%%%% for sound signal 
% % in_samp_rate=8000;
% % in_depth=16;
% % recObj = audiorecorder(in_samp_rate,in_depth,1);
% % recordblocking(recObj,3);
% % msg = getaudiodata(recObj);
% % N=length(msg);%Number of samples
% %%%%%%%%%%%%%
% N=8000; % for cos signal 
% t=(0:Ts:(N*Ts)- Ts);
% t=t(:);
% msg=cos(2*pi*f1*t);
% Signal1=cos(2*pi*f*t+2*pi*kf*cumsum(msg)/fs); %modulation
% Signal=Signal1 + sqrt(0.5*10^((Psig-snr)/10))*(randn(length(Signal1),1)); % add noise
% % Signal=channel_noise(Signal,snr); % add noise
% %%%%%%%%%%%%slope detector%%%%%%%%%%%
% yq = hilbert(Signal).*exp(-j*2*pi*f*t); 
% out = (1/(2*pi*kf))*[0; diff(unwrap(angle(yq)))*fs]; % demodulated signal
% %%%%%%%%%%%%%%%%%%%%
% for n=2:length(Signal)
%  vco_phase(n)=2*pi*n*f/fs+phi_hat(n-1);  % VCO 
%  if(vco_phase(n) > 2*pi)
%       vco_phase(n) = vco_phase(n) - 2*pi;
%         end;
%  vco(n)=cos(vco_phase(n));
% phd_output(n)=Signal(n)*vco(n); % phase detector
% 
% [b,a]=butter(1,wn0,'low');  %loop filter LPF
% e(n)=b(1)*phd_output(n)+b(2)*phd_output(n-1)-a(2)*e(n-1);
% phi_hat(n)=phi_hat(n-1)+e(n); %phase change
% end; 
% 
% [num,den] = butter(10,wn,'low'); %LPF 
% e1 = filtfilt(num, den, e) ;
% % [num,den] = butter(10,wn,'low');
% % msg1 = filter(num, den, msg) ;
% figure(100);
% subplot(2,1,1);plot_tsig(msg);
% subplot(2,1,2);plot_tsig(10*e1);
% % sound(15*e);
% 
Please Wait...