Feedback Systems

(Author: Jorge Finke)

Clear All;

Bode Diagrams

The first argument is a transfer function or a list of transfer functions, of which the frequency response is to be plotted.  The option LogRange defines the logarithmic limits for the angular frequency.  Further options are passed to the function Plot.

Magnitude and Phase Plot:

lsys[ω_]:=(TransferFunctionModel[((ω^2)/((ω^2)+2 ω s+(s^2))), ]);
BodePlot[Table[lsys[ω],{ω,0.1,1,0.1}],ImageSize->500]

Manipulate[BodePlot[lsys[ω] ,PlotRange->{{{0.01, 100},{-50, 20}},{{0.01, 100},{-175, 0}}} , GridLines->Automatic, ImageSize-> 500],{ω,0.1,2}]

Nyquist Diagrams

The argument is a transfer function or a list of transfer functions, of which the frequency response is to be plotted.  The logarithmic range for the angular frequency can be given with the option LogRange.  Further options are passed to the function ParametricPlot.

NyquistPlot[Table[tf[p], {p, 0.1, 1, 0.1}],
	AspectRatio->Automatic, Axes->True, GridLines->Automatic, ImageSize->300]

NyquistPlot[(s+2)/(s^2-1) ,AspectRatio->1, PlotStyle-> Thick, PlotLabel->Style["k= 1", 25], BaseStyle->{FontSize->Scaled[.05]}, ImageSize -> 300]

Manipulate[ NyquistPlot[k((s+1)/(s^2-1)),PlotRange->{{-5,5},{-5,5}}, PlotStyle-> Thick, PlotLabel->Style["L(s)", 25], BaseStyle->{FontSize->Scaled[.05]}],{k,5,-5}]

Manipulate[ NyquistPlot[k((s+1)/(s^2-1))(1/(s-1)),PlotRange->{{-5,5},{-5,5}}, PlotStyle-> Thick,  PlotLabel->Style["L(s)", 25], BaseStyle->{FontSize->Scaled[.05]}],{k,1,5}]

Manipulate[ NyquistPlot[((s+1)/(s^2-1))(k/(s-k)),PlotRange->{{-1,1},{-1,1}}, PlotStyle-> Thick,  PlotLabel->Style["L(s)", 25], BaseStyle->{FontSize->Scaled[.05]}],{k,-20,20}]

Stability Margins

The gain and phase margins of a system

tf=TransferFunctionModel[(10.0/((s+1) (s+2) (s+3))),s];
{gm, pm}=GainPhaseMargins[tf]

NyquistPlot[tf, StabilityMargins->{gm,pm},StabilityMarginsStyle->{Directive[Red,AbsoluteThickness[3]],Directive[Darker[Green],AbsoluteThickness[3]]}, ImageSize -> 300]

BodePlot[tf,StabilityMargins->{gm,pm},StabilityMarginsStyle->{Directive[Red,AbsoluteThickness[3]],Directive[Darker[Green],AbsoluteThickness[3]]}, GridLines->Automatic, ImageSize -> 300]