# how can use fmmod function for make a LFM signal

7 views (last 30 days)
mehdi parvizi on 18 Aug 2014
Commented: mehdi parvizi on 20 Aug 2014
i can make LFM signal with this function look my program , but when noise increase to modulated signal, the demodulator out put isn't desirable just for very high SNR such as 100dB!!!???
close all
clear all
clc
fd=1000; %doppler freq
fs=1e6; %frequency sampling
fc=1e3;
T=1e-2; % one period
B=2e4; %bandwidth
SNR_db=10;
f_dev=1;
%**************
snr=10^(SNR_db/10);
t=-T/4:1/fs:T/4;
x=B/2*tripuls(t,T/2);
figure
plot(t+T/4,x)
x2=fd+x;
y=fmmod(x2,fc,fs,f_dev);
pn=sum(y.^2)/snr;
y2=y+sqrt(pn).*randn(1,length(t));
z=fmdemod(y2,fc,fs,f_dev);
hold on
plot(t+T/4,z,'g')
figure
plot(t,y2);
to see the true output change line 11 to SNR_db=100
Salaheddin Hosseinzadeh on 18 Aug 2014
Hi Mehdi,
What is the problem exactly?
Is it like the demodolator works perfect and you're not happy about it?!
mehdi parvizi on 18 Aug 2014
no it's work truly for high SNR like 100dB but in 10db or 20db demodolator isn't work Correctly. i want demodulating a noisy modulated signal.

Salaheddin Hosseinzadeh on 18 Aug 2014
Hey Mehdi,
I ran your code, couldn't understand anything really.
Try this one, you may see some modulation taking place at least, and then lets try to discuss what the problem is.
Fs = 8000; % Sampling rate of signal
Fc = 30; % Carrier frequency
t = [0:Fs-1]'/Fs; % Sampling times
s1 = sin(2*pi*2*t); % Channel 1
x = s1; % Two-channel signal
dev = 20; % Frequency deviation in modulated signal
y = fmmod(x,Fc,Fs,dev); % Modulate both channels.
plot(t,y,'r')
hold on
z = fmdemod(y,Fc,Fs,dev); % Demodulate both channels.
plot(t,z);
legend('Modulated Signal','Demodulated Message');
##### 3 CommentsShow 1 older commentHide 1 older comment
Salaheddin Hosseinzadeh on 18 Aug 2014
Edited: Salaheddin Hosseinzadeh on 18 Aug 2014
You're welcome.
I'll have a look at what you've done to add noise, and see why id doesn't work.
I'll post something in 1 2 hours hopefully, as soon as I got home ;)
By looking at this image, my guess is that you're adding to much noise. But as I said, I'll have a precise look.
mehdi parvizi on 18 Aug 2014
tanks a lot , have a good time ;) . I'm waiting for your answer

Salaheddin Hosseinzadeh on 19 Aug 2014
Hi Mehdi,
It's always a pleasure for me to get involve telecom problems, besides, it's a good review and still a struggle for me. Hamvatan ham ke hasti, dige hanoz pleasuresh bishtare :D
To avoid any confusion I used awgn function. It's a built in MATLAB function, read about it in the MATLAB documentation for further info. (doc awgn)
clear
Fs = 800; % Sampling rate of signal
Fc = 30; % Carrier frequency
t = [0:Fs-1]'/Fs; % Sampling times
x = sin(2*pi*2*t); % Channel 1
dev = 20; % Frequency deviation in modulated signal
y = fmmod(x,Fc,Fs,dev); % Modulate both channels.
y2 = awgn(y,20,'measured'); % 20dB
figure
plot(t,y2,'r')
hold on
z = fmdemod(y2,Fc,Fs,dev); % Demodulate both channels.
plot(t,z);
legend('Modulated Signal','Demodulated Message');
Hope this solves the problem for now, but it would be a good practice I guess for both of us to perform what awgn function does. So Plz leave comment as soon as you got the same result without using awgn and explain for me how u did it. Thanks
Regards,
Salah
mehdi parvizi on 20 Aug 2014
hi, ghorbunet hamvatan ;) shoma eftekhare maee
i think an other wrong in my code was very high frequency sampling
sure :) if i get better Results share with you

Salaheddin Hosseinzadeh on 18 Aug 2014
Hey Mehdi,
Sorry, I guess it took me a bit more than 2 hours, I've been a bit busy.
Take a look the attached file and how I add noise to the signal.
Considering message is a sine wave, it's between -1 and 1, then for SNR = 10dB which means signal has an amplitude of 10 times greater than noise level adjusted to be between 0.1 and -0.1 , which gives SNR = 10dB, and then I add that to the modulated signal.
Anyway, hope your problem is solved.
Don't hesitate to write back.
Good Luck,
Salah
##### 3 CommentsShow 1 older commentHide 1 older comment
Salaheddin Hosseinzadeh on 19 Aug 2014
Edited: Salaheddin Hosseinzadeh on 19 Aug 2014
Hi Mehdi,
That's good, looks like you paid attention to what's happening!
You may be right also, I totally forgot the power 2, I assumed summation of the message signal(sine wave) is zero, the summation of a normal distribution (Gaussian Distribution) is also zero so that should not make a problem! Maybe I'm wrong!
I'll have a look at your code again. Don't doubt MATLAB functions plz, I've faith in MATLAB. It's probably you and I making small mistakes ;)
Regards,
Salah
mehdi parvizi on 19 Aug 2014
hi salah. I am totally confused. I've done everything . this codes are parts of my project and i can't continue until this issue is resolved :( . thanks for your time and attention to me