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.

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 Filter Frequency Response Sweep script. Note that an existing AC Sweep Analysis is required to run the script and one has 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 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 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 AC Sweep 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);

% clear all traces in frequency response plot window in the current model
plecs('scope', './Analyses/AC Sweep', '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', 'AC Sweep', simStruct); % start AC Sweep analysis
  plecs('scope', './Analyses/AC Sweep', 'HoldTrace',
        ['fc=' mat2str(fcValues(ix)/1000) 'kHz']); % hold and label trace
end