Power content of angle modulation (FM and PM)

Manipulate[
If[typeOfModulation==FM,k=Max[Min[k,2],0],k=Max[Min[k,3.5],0]];

frequencyModulation[k,fc,fm,typeOfModulation,Am,Ac],

Grid[{
{
Item[Control[{{typeOfModulation,FM,"select type of modulation"},{FM->"FM",PM->"PM"},ControlType->SetterBar,ImageSize->Tiny}]
,Alignment->Left],

Item[Control[{{k,1.14,"k, deviation constant "},0,Dynamic[If[typeOfModulation==FM,2,3.5]],.01,Appearance->"Labeled",ImageSize->Tiny}]
,Alignment->Right]
},

{
Item[Control[{{Am,1,"(Subscript[A, m]), message amplitude "},0.5,1.5,.01,Appearance->"Labeled",ImageSize->Tiny}]
,Alignment->Right],

 Item[Control[{{fc,6.7,"\!\(\*SubscriptBox[\(f\), \(\(c\)\(,\)\(\\ \)\)]\)carrier frequency (hz)"},5,maxCarrierFreq,.01,Appearance->"Labeled",ImageSize->Tiny}]
,Alignment->Right]
},

{
Item[Control[{{Ac,1,"(Subscript[A, c]), carrier amplitude "},.5,1.5,.01,ImageSize->Tiny,Appearance->"Labeled"}]
,Alignment->Right],

Item[Control[ {{fm,0.88,"\!\(\*SubscriptBox[\(f\), \(\(m\)\(,\)\(\\ \)\)]\)message frequency (hz)"},.18,maxMessageFreq,.01,Appearance->"Labeled",ImageSize->Tiny}]
,Alignment->Right]
}
},
Spacings->{2,0},
Frame->None
],

ControlPlacement->Top,
SynchronousUpdating->False,
AutorunSequencing->Automatic,
Initialization:>
(
maxCarrierFreq=8;
maxMessageFreq=1;
tmax=4;
fontSizeForTitles=14;
fontSizeForSubTitles=11;
FM=1;
PM=-1;

(********************************************************)
(* This is the main function called by Manipulate[]     *)
(********************************************************)
frequencyModulation[k_,fc_,fm_,typeOfModulation_,Am_,Ac_]:=Module[{message,carrier, wm,wc,msg,β},

wm=2 Pi fm;
wc=2 Pi fc;
carrier=Ac Cos[wc t];

(*set β, the modulation index, depending on the modulation type*)
If[typeOfModulation==FM,{message= Am Cos[wm t],β=k Am/fm},{message=Am Sin[wm t],β=k Am}];

GraphicsGrid[{
{
msg=
Style["modulation index β = "<>ToString[ NumberForm[β ,{3,2}]],fontSizeForSubTitles];

plotLabel=Style[Column[{ Style[If[typeOfModulation==FM,"FM modulated carrier","PM modulated carrier"],fontSizeForTitles] ,
msg}
,Center]] ;

Plot[{Ac Cos[wc t+β   Sin[wm t] ],message},{t,0,tmax },
Ticks->{Automatic,Automatic},
AxesLabel->{Style[Row[{Style["t",Italic]," (sec)"}],Larger]},PlotLabel->plotLabel,
PlotStyle->{Red,Blue},
AspectRatio->1/4
],
SpanFromLeft
},
{
frequencyPlot[fm,fc,β,Ac,Am],SpanFromLeft
}
,
{
powerRatioPlot[fm,β],SpanFromLeft
}
},
Spacings->{Scaled[.1],Scaled[.1]},
Frame->{False,All},
Dividers->None,
AspectRatio->Full,
ImageSize->{520,390}]
];

(********************************************************)
(* This function generates the plot for the power ratio *)
(********************************************************)
powerRatioPlot[fm_,β_]:=Module[{bandwidth,nSideTermsToUse,data,bessel,tmp,n,xticks,p1,p2,colors,plotLabel},

bandwidth=2(β+1)fm;
nSideTermsToUse=Floor[bandwidth/(2*fm)]+1;
tmp=((BesselJ[0,β])^2);
bessel=Table[((BesselJ[n,β])^2),{n,1,nSideTermsToUse}];
data=Table[{n,tmp+2Total[bessel[[1;;n]]]},{n,1,nSideTermsToUse}];
data=Insert[data,{0,tmp},1];

xticks=Table[{n,ToString[2 n]},{n,0,nSideTermsToUse}];

(*I do not know how to make lines joined and also make filling*)
(*as vertical lines using the same options as they conflict    *)
(*so I make 2 plots one with vertical lines, and one joined   *)

colors=Table[If[n==0,{Red,PointSize[.015]},{Blue,PointSize[.015]}],{n,0,nSideTermsToUse}];

plotLabel=Style[Column[{ Style["power content (normalized) as a function of bandwidth",fontSizeForTitles] },
,Center]];

p1=Show[ListPlot[{#[[2]]},
PlotLabel->plotLabel ,
AspectRatio->1/4,
Ticks->{xticks,{0,0.25,0.5,0.75,1}},
AxesOrigin->{0,0},
Filling->Axis,
PlotStyle->#[[1]],
FillingStyle->#[[1,1]],
AxesLabel->{Style[Column[{"number of","sidbands"},Center],Larger] },
Frame->False,
Joined->False]&/@Transpose[{colors,data}],
PlotRange->All];

p2=ListPlot[data,
Joined->True,
PlotStyle->{Black,Dashed,Thin}];

Show[p1,p2]
];

(********************************************************)
(* This function generates the plot for the spectra     *)
(********************************************************)
frequencyPlot[fm_,fc_,β_,Ac_,Am_]:=Module[{nSideTermsToUse,yValues,xValues,g,plotLabel,gLabels,roundedYValues,bandwidth},

bandwidth=2(β+1)fm;
nSideTermsToUse=Round[bandwidth/(2*fm)]+1;

yValues= (Ac/2) BesselJ[Range[-nSideTermsToUse,nSideTermsToUse],β];

(*flip negative phase indicated by some BesselJ results will be nagtive*)
Table[If[yValues[[i]]<0,yValues[[i]]=yValues[[i]]*-1,yValues[[i]]],{i,1,Length[yValues]}];

xValues=Table[fc+n*fm,{n,-nSideTermsToUse,nSideTermsToUse}];

g=Table[{ If[n==nSideTermsToUse+1,  Red,Blue]   ,Line[{{xValues[[n]],0},{xValues[[n]],yValues[[n]]}}]},{n,1,Length[xValues]}];

roundedYValues=Round[yValues,0.01];

gLabels=Table[Text[ Style[ NumberForm[roundedYValues[[n]] ,{3,2}],Small],{xValues[[n]],yValues[[n]]+0.1 yValues[[n]]},{-1,0},{0,1}],{n,1,Length[xValues]}];

plotLabel=Column[{ Style["modulated carrier spectra (magnitude)",fontSizeForTitles] ,
Row[{Style["bandwidth (98% of power) = "<>ToString[ NumberForm[bandwidth,{3,2}]]<>" hz",fontSizeForSubTitles],
"     ",
Style["number of sidbands = "<>ToString[  2 nSideTermsToUse ],fontSizeForSubTitles]}]}
,Center] ;

Show[ListPlot[{{fc,0}},
PlotLabel->plotLabel,
AxesOrigin->{fc,0},
Axes->{True,False},
PlotRange->{Automatic,{-.1 Max[yValues],1.7*Max[yValues]}},
AspectRatio->1/4,
AxesLabel->{Style[Row[{Style["f",Italic]," (hz)"}],Larger]},
Ticks->{Automatic,None}
],
Graphics[g],Graphics[gLabels]]
]
)
]

This demonstration illustrates frequency modulation (FM) and phase modulation (PM) using one tone sinusoidal as the modulating signal.

For FM, the modulating signal m (t) is defined as m(t)=(Subscript[A, m]) cos(2π (Subscript[f, m])t) and for PM m(t)=(Subscript[A, m])sin(2π (Subscript[f, m])t) where (Subscript[f, m]) is the signal frequency in Hz and (Subscript[A, m]) is its amplitude. This definition for m (t) is used to simplify determining the spectra of the modulated carrier s (t) by the use of BesselJ functions.

With m( t) defined as above, the modulated carrier s (t) can now be defined as s( t)=(Subscript[A, c])cos(2π (Subscript[f, c])t+β  m(t)) where β is the modulation index, (Subscript[f, c]) is the carrier frequency in Hz and (Subscript[A, c]) is the carrier amplitude.

For FM modulation, β=((k (Subscript[A, m]))/(Subscript[f, m]))where K is the deviation constant in Hz per volt, and for PM modulation, β=k (Subscript[A, m]) where K is in radians per volt. (The above units for β assumes that the unit of m (t) is volts).

The bandwidth of the modulated carrier s (t) is defined as approximately 2(1+β)(Subscript[f, m]). This bandwidth contains 98% of the power. For a very small β the modulated carrier spectra become a narrow band and for a large β the spectra becomes wideband.

The parameters (Subscript[A, m]),(Subscript[A, c]),(Subscript[f, m,])(Subscript[f, c]),k can be adjusted and the effect on the spectra of the modulated carrier can be observed.

The demonstration also calculates and plots the power content (normalized) of the modulated carrier as a function of the bandwidth. This is also called the power ratio, and defined as ((BesselJ[0,β])^2)+2(∑_(n=1)^M)((BesselJ[n,β])^2) where BesselJ is Bessel function of the first kind, and M is the number of sidebands on each side of the carrier frequency (Subscript[f, c]). This plot is useful in the design of FM and PM modulators as it allows one to determine the size of the bandwidth needed for a given power ratio.

Contributed by: Nasser M. Abbasi