fm modulation without using fmmod

205 views (last 30 days)
how do I write this in matlab ! < I have been running FM modulation using fmmod , everything went great but i have been asked to do it using as shown in the picture ! can you help ?

Accepted Answer

John BG
John BG on 5 Jan 2017
Edited: Walter Roberson on 7 Jan 2017
Tariq
If you open fmmod.m the key lines are
t = (0:1/Fs:((size(x,1)-1)/Fs))';
t = t(:,ones(1,size(x,2)));
int_x = cumsum(x)/Fs;
y = cos(2*pi*Fc*t + 2*pi*freqdev*int_x + ini_phase);
so xfm would be
int_x = cumsum(x)/Fs;
xfm = cos(2*pi*Fc*t).*cos(2*pi*freqdev*int_x)-sin(2*pi*Fc*t).*sin(2*pi*freqdev*int_x)
xi=cos(2*pi*freqdev*int_x)
xq=sin(2*pi*freqdev*int_x)
the fmmod example available from MATLAB help are:
fs = 1000;
fc = 200;
t = (0:1/fs:0.2)';
x = sin(2*pi*30*t)+2*sin(2*pi*60*t);
fDev = 50;
y = fmmod(x,fc,fs,fDev);
z = fmdemod(y,fc,fs,fDev); % Demodulate both channels.
figure(1);plot(t,x,'c',t,z,'b--');xlabel('Time (s)');ylabel('Amplitude');
legend('Original Signal','Demodulated Signal');grid on
applying the key lines directly
int_x = cumsum(x)/fs;
xfm = cos(2*pi*fc*t).*cos(2*pi*fDev*int_x)-sin(2*pi*fc*t).*sin(2*pi*fDev*int_x) ;
xi=cos(2*pi*fDev*int_x);
xq=sin(2*pi*fDev*int_x) ;
IMPORTANT COMMENT:
  • I Q decomposition only applies a single frequencies.
  • FM signals have variable BW, unless working with digital FM, for instance FSK, there is not a unique way to define I Q.,
  • One may consider breaking down the largest BW down into smaller bands, fixed sub-bands, but even then, the nature of the FM signal will render void many of such defined sub-bands.
  • I suggest you avoid defining I Q components for a generic FM signal unless clearly detailing how you obtain them: the way you have xi and xq are not really In phase and Quadrature components.
in demodulation the key lines of fmdemod.m are
t = (0:1/Fs:((size(y,1)-1)/Fs))';
t = t(:,ones(1,size(y,2)));
yq = hilbert(y).*exp(-j*2*pi*Fc*t-ini_phase);
z = (1/(2*pi*freqdev))*[zeros(1,size(yq,2)); diff(unwrap(angle(yq)))*Fs];
so
t2 = (0:1/fs:((size(xfm,1)-1)/fs))';
t2 = t2(:,ones(1,size(xfm,2)));
xfmq = hilbert(xfm).*exp(-j*2*pi*fc*t2);
z = (1/(2*pi*fDev))*[zeros(1,size(xfmq,2)); diff(unwrap(angle(xfmq)))*fs];
figure(2);plot(t,x,'c',t2,z,'b--');xlabel('time ');ylabel('amplitude');
legend('Original Signal','Demodulated Signal');grid on
the example lines put all together are:
fs = 1000;
fc = 200;
t = (0:1/fs:0.2)';
x = sin(2*pi*30*t)+2*sin(2*pi*60*t);
fDev = 50;
int_x = cumsum(x)/fs;
xfm = cos(2*pi*fc*t).*cos(2*pi*fDev*int_x)-sin(2*pi*fc*t).*sin(2*pi*fDev*int_x) ;
xi=cos(2*pi*fDev*int_x);
xq=sin(2*pi*fDev*int_x) ;
t2 = (0:1/fs:((size(xfm,1)-1)/fs))';
t2 = t2(:,ones(1,size(xfm,2)));
xfmq = hilbert(xfm).*exp(-j*2*pi*fc*t2);
z = (1/(2*pi*fDev))*[zeros(1,size(xfmq,2)); diff(unwrap(angle(xfmq)))*fs];
figure(2);plot(t,x,'c',t2,z,'b--');xlabel('time ');ylabel('amplitude');
legend('Original Signal','Demodulated Signal');grid on
the resulting graph is as expected the same of the MATLAB example
.
you can also use SIMULINK
.
.
.
let me know if you would like this basic example, attached to my answer (fm_mod1.slx compressed into fm_mod1.zip this forum does not allow attaching Simulink files), to be developed a bit more, or you only want MATLAB code.
.
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
  24 Comments
Atul Dwivedi
Atul Dwivedi on 12 Mar 2019
How we can demodulate the fm signal if given carrier is: xc=cos(2*pi*200*t)+cos(2*pi*500*t)?
nima nabavi
nima nabavi on 28 Aug 2020
Thank you man. Really thanks.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!