Frequency Response of Passive Circuit
Overview
This demonstration shows how to generate the frequency response of a non-switched network. In this example, a Bode plot is produced for a first-order RC network. For PLECS Standalone a Simulation Script is included where a parameter sweep can be executed for various values of the passive components.
Simulation
For PLECS Standalone and PLECS Blockset there are different simulation setups that can be used with this demo model. Since PLECS 5.0, PLECS Standalone offers a new Frequency Response Analysis which is not available in PLECS Blockset.
PLECS Blockset
To run the AC-Sweep double-click on the AC Sweep Analysis block to open the dialog and click on the Start analysis button. The progress of the analysis is displayed in the MATLAB Command Window. When the analysis has finished a new Bode plot will be displayed showing the corresponding transfer function.
PLECS Standalone
To run the scripted simulation demonstration select Simulation scripts… from the Simulation menu and run the “Sweep filter configuration with small-signal analysis” script. Note that an existing AC Sweep or Frequency Response Analysis are required to run the script and both have already been setup for this model. Additionally, the Analysis Tools window should be open prior to executing the script (select Analysis Tools… from the Simulation menu) in order to view the resulting plots. Also note that for the AC Sweep the “Operating point” analysis setting is set to “non-periodic (DC)” as the system contains no switches or discrete blocks. An alternative option is to use a “System period” of 0, which is equivalent to defining the system as non-periodic.
The variable ANALYSIS is used to choose with analysis is executed from the simulation script. The options are the name of the anylises defined in the Analysis Tools menu, which are Frequency Response or AC Sweep.
The script requires a value for the resistance and a cutoff frequency for the filter network. The capacitance is then calculated for each combination and an analysis is performed. The frequency response result of each simulation is displayed as a new trace in the plot window.
% parameter definitions, create simStruct with field 'ModelVars'
mdlVars = struct('R', 1, 'C', 100e-6, 'fc', 10e3);
simStruct = struct('ModelVars', mdlVars);
ANALYSIS = 'Frequency Response'; % options are 'Frequency Response' or 'AC Sweep'
path = ['./Analyses/' ANALYSIS];
% clear all traces in frequency response plot window in the current model
plecs('scope', path, 'ClearTraces');
fcValues = [10e2, 10e3, 10e4]; % cutoff frequencies
for ix = 1:length(fcValues)
fc = 10e3; % RC filter cutoff frequency
simStruct.ModelVars.C = 1/(2*pi*simStruct.ModelVars.R*fcValues(ix)); % RC filter capacitance
plecs('analyze', ANALYSIS, simStruct); % start AC Sweep analysis
plecs('scope', path, 'HoldTrace', ...
['fc=' mat2str(fcValues(ix)/1000) 'kHz']); % hold and label trace
end