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.

Frequency Modulation code

Status
Not open for further replies.

madelman

Newbie level 4
Joined
Jun 26, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,335
Hi all,

I wrote a code for frequency modulation in matlab.
I'm getting weird results at frequency domain, if you please look at the code and comment where i did wrong.

By saying weird, i get wrong number of harmonics vs. beta. Also, for small values of Kp I don't get any modulation (maybe very small deviation?).

Does these values of Kp are normal (acceptable)?

the code:

Fs = 100e3; %
dt = 1/Fs; %
%
T = 1;
%t = 0:dt:T/2;
t = (0:Fs-1)/Fs;
df = 1/T;
Fmax = 1/2/dt;
f = -Fmax:df:Fmax-1;
% Carrier
fc = 10e3;
% Information - Time domain
fm = 200; %in Hz
Am = 1; % in Volts
Kp = 3000;
ym = Am*sin(2*pi*fm.*t);
deltaF = Kp*Am;
% Modulation
beta = deltaF/(fm);
y = 4*cos(2*pi*fc.*t+beta*sin(2*pi*fm.*t));
% Frequency domain
Y = fftshift(fft(y))/length(y);
% Plots - Time domain
figure(1);
subplot(211), plot(t,cos(2*pi*fm.*t)),axis([0.21 0.221 -1.5 1.5]), grid on;
subplot(212), plot(t,y), axis([0.21 0.221 -5 5]), grid on;
% Plots - frequency domain
figure(2);
plot(f,10*log10(abs(Y))), grid on;


Thanks,
 

guys, it's really important. please help.

If I was unclear, please don't hesitate to ask.

thanks,
 

I can't see anything wrong with your code. I tried it, making minor modifications, in Scilab and it seems to me woking properly. I don't know why you said that for low Kp there is no modulation: I can see a modulated spectrum at least down to a Kp of 1.
Take into account that armonic content will follows the Bessel "J" function, in fact:

Yfm = A*cos[wc*t+beta*sin(wm*t)] = A*Σ{Jn(beta)*cos[(wc+n*wm)*t]}

with sum over "n" going from -∞ to ∞
 

hello albbg, thanks for your comment.

When you looked at modulated spectrum, did number of harmonics was according Bessel "J" function? take this table as a reference: https://en.wikipedia.org/wiki/Frequency_modulation#Bessel_functions
can you please simulate that code at matlab (if you have it installed) to see that you get similar results as in Scilab.
can you please specify what minor modification you did?
 

In FM modulation there isn't a limited number of harmonics. They are (theoretically) infinite as per the equation I posted. I think wikipedia only shows those higher than 0.01 (or 0.02).
You can plot abs(Y) instead of log10(abs(Y)) and compare your levels with those reported in the table of wikipedia. Of course, due to the "abs", you will have all positive numbers.
When in Matlab you plot the log(Y) you can see a finite number of harmonics due to the finite math accuracy.
Minor modification are really minor as f.i. the variable pi in Scilab is %pi, comments are // instead of % an so on.
 

Do you have other Bessel table that you can recommend (with much more accuracy), to verify that suggestion? I'll run a simulation and report.

In other forum I was told that I need to adjust (it is too small for the given frequency) time vector according frequency of the information or to be more precise BW of the information.
It seems very reasonable suggestion but I cannot see how in this specific code it might be relevant.

Can you comment on this?

In fact, what considerations should be for time vector according BW of the signal?
 

the correct time domain should have been like this:

t = 0:K*fs/fm -1
t = t*dt

K is in order to increase the FFT input vector and by that increase its frequency resolution. K must power of 2.

Df = Fs / (K*Ffs/fm)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top