Usage in PLECS Blockset
In PLECS Blockset, you configure analyses by copying the appropriate blocks from the Analysis Tools library in PLECS Extras into your model.
Steady-State Analysis
To perform a steady-state analysis, copy the Steady-State Analysis block into your model. An analysis can be run interactively from the block dialog or via a MATLAB command. The calling syntax is
plsteadystate(block);
where block is the Simulink handle or the full block path of the Steady-State Analysis block. The block handle or path can be followed by parameter/value pairs. Otherwise, the settings specified in the block dialog are used.
The following table lists the parameters of the Steady-State Analysis block. The Parameter column shows the parameter names to be used with the plsteadystate command. The Description column indicates whether and where you can set the value in the dialog box. Parameters that are not accessible in the dialog box can be modified using the set_param command.
Parameter |
Description |
|---|---|
|
For a fixed system period, the period length; this is the least common multiple of the periods of independent sources in the system. For a variable system period, the maximum time span during which to look for a trigger event marking the end of a period. Set by the System period length/Max simulation time span field. |
|
Simulation start time. Set by the Simulation start time field. |
|
Relative error tolerance used in the convergence criterion. Set by the Termination tolerance field. |
|
Maximum number of iterations allowed. Set by the Max number of iterations field. |
|
Specifies the level of detail of the diagnostic messages displayed in the command window ( |
|
Hide all Simulink scope windows during an analysis in order to save time. |
|
Specifies how to handle Simulink blocks with ‘hidden’ states, i.e. states that are not stored in the state vector ( |
|
Name of a MATLAB variable used to store the steady-state vector at the end of an analysis. Set by the Steady-state variable field. |
|
Number of steady-state cycles that should be simulated at the end of an analysis. Set by the Show steady-state cycles field. |
|
Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
|
Controls the way the Jacobian matrix is calculated ( |
|
Number of cycle-by-cycle simulations that should be performed before the actual steady-state analysis. This parameter can be used to provide the algorithm with a better starting point. The default is |
These examples show how to run analyses for the block Steady State in the model mymodel:
Start an analysis using the parameters specified in the dialog box:
plsteadystate('mymodel/Steady State');
Perform two analyses with different start times and assigns the resulting steady-state vectors to two different variables
x0andx1. This is useful e.g. if the model has a reference signal with a step change and you want to determine the steady state before and after the change.plsteadystate('mymodel/Steady State', 'TStart', 0, ... 'FinalStateName', 'x0'); plsteadystate('mymodel/Steady State', 'TStart', 1, ... 'FinalStateName', 'x1');
AC Sweep / Loop Gain Analysis
To perform an AC Sweep, copy the AC Sweep block into your model. The block outputs a perturbation signal, which must be injected into the system. The system response must be fed back into the block input.
To perform a loop gain analysis, copy the Loop Gain Analysis (AC Sweep) block into your model and insert it into the path of a feedback loop.
An analysis can be run interactively from the block dialogs or via a MATLAB command. The calling syntax is
placsweep(block);
where block is the Simulink handle or the full block path of the AC Sweep block or Loop Gain Analysis (AC Sweep) block. The block handle or path can be followed by parameter/value pairs. Otherwise, the settings specified in the block dialog are used.
The following table lists the parameters of the AC Sweep block and Loop Gain Analysis (AC Sweep) block. The Parameter column shows the parameter names to be used with the placsweep command. The Description column indicates whether and where you can set the value in the dialog box. Parameters that are not accessible in the dialog box can be modified using the set_param command.
Parameter |
Description |
|---|---|
|
Period length of the unperturbed system. Set by the System period length field. |
|
Simulation start time. Set by the Simulation start time field. |
|
Range of the perturbation frequencies. Set by the Frequency sweep range field. |
|
Specifies whether the sweep frequencies should be distributed on a |
|
Number of data points generated. Set by the Number of points field. |
|
Perturbation amplitude at the first perturbation frequency. Set by the Amplitude at first freq field. |
|
Method used for obtaining the periodic steady-state operating point of the perturbed system: |
|
Relative error tolerance used in the convergence criterion. Set by the Termination tolerance field. |
|
Maximum number of iterations allowed. Set by the Max number of iterations field. |
|
Specifies the level of detail of the diagnostic messages displayed in the command window ( |
|
Hide all Simulink scope windows during an analysis in order to save time. |
|
Specifies how to handle Simulink blocks with ‘hidden’ states, i.e. states that are not stored in the state vector ( |
|
Name of a MATLAB variable used to store the transfer function at the end of an analysis. Set by the Output variable field. |
|
Plot a Bode diagram of the transfer function at the end of an analysis. Set by the Plot Bode diagram drop-down list. |
|
Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
|
If a steady-state analysis is used to obtain the starting point of the ac analysis (see parameter |
These examples show how to run analyses for the block AC Sweep in the model mymodel:
Start an analysis using the parameters specified in the dialog box.
placsweep('mymodel/AC Sweep');
Perform two analyses with different start times and assigns the resulting transfer functions to two different variables
T0andT1. This is useful e.g. if the model has a reference signal with a step change and you want to determine the transfer function before and after the change.placsweep('mymodel/AC Sweep', 'TStart', 0, ... 'OutputName', 'T0'); placsweep('mymodel/AC Sweep', 'TStart', 1, ... 'OutputName', 'T1');
Impulse Response Analysis
To perform an impulse response analysis, copy the Impulse Response Analysis block into your model. The block outputs a perturbation signal, which must be injected into the system. The system response must be fed back into the block input.
An analysis can be run interactively from the block dialogs or via a MATLAB command. The calling syntax is
plimpulseresponse(block);
where block is the Simulink handle or the full block path of the Impulse Response Analysis block. The block handle or path can be followed by parameter/value pairs. Otherwise, the settings specified in the block dialog are used.
The following table lists the parameters of the Impulse Response Analysis block. The Parameter column shows the parameter names to be used with the plimpulseresponse command. The Description column indicates whether and where you can set the value in the dialog box. Parameters that are not accessible in the dialog box can be modified using the set_param command.
Parameter |
Description |
|---|---|
|
Period length of the unperturbed system. Set by the System period length field. |
|
Simulation start time. Set by the Simulation start time field. |
|
Range of the perturbation frequencies. Set by the Frequency sweep range field. |
|
Specifies whether the sweep frequencies should be distributed on a |
|
Number of data points generated. Set by the Number of points field. |
|
Perturbation amplitude of the discrete impulse. Set by the Perturbation field. |
|
Specifies whether and how the effect of the sampling should be compensated ( |
|
Relative error tolerance used in the convergence criterion of the initial steady-state analysis. Set by the Termination tolerance field. |
|
Maximum number of iterations allowed during the initial steady-state analysis. Set by the Max number of iterations field. |
|
Specifies the level of detail of the diagnostic messages displayed in the command window ( |
|
Hide all Simulink scope windows during an analysis in order to save time. |
|
Specifies how to handle Simulink blocks with ‘hidden’ states, i.e. states that are not stored in the state vector ( |
|
Name of a MATLAB variable used to store the transfer function at the end of an analysis. Set by the Output variable field. |
|
Plot a Bode diagram of the transfer function at the end of an analysis. Set by the Plot Bode diagram drop-down list. |
|
Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
|
Number of cycle-by-cycle simulations that should be performed before the initial steady-state analysis. This parameter can be used to provide the algorithm with a better starting point. The default is |
Multitone / Loop Gain Analysis
To perform a multitone analysis, copy the Multitone Analysis block into your model. The block outputs a perturbation signal, which must be injected into the system. The system response must be fed back into the block input.
To perform a loop gain analysis, copy the Loop Gain Analysis (Multitone) block into your model and insert it into the path of a feedback loop.
An analysis can be run interactively from the block dialogs or via a MATLAB command. The calling syntax is
plmultitone(block);
where block is the Simulink handle or the full block path of the Multitone Analysis or Loop Gain Analysis block. The block handle or path can be followed by parameter/value pairs. Otherwise, the settings specified in the block dialog are used.
The following table lists the parameters of the Multitone Analysis block and Loop Gain Analysis (Multitone) block. The Parameter column shows the parameter names to be used with the plmultitone command. The Description column indicates whether and where you can set the value in the dialog box. Parameters that are not accessible in the dialog box can be modified using the set_param command.
Parameter |
Description |
|---|---|
|
Range of the perturbation frequencies. Set by the Frequency sweep range field. |
|
Amplitude of the perturbation signal. Set by the Amplitude field. |
|
Simulation start time. Set by the Simulation start time field. |
|
Specifies the level of detail of the diagnostic messages displayed in the command window ( |
|
Hide all Simulink scope windows during an analysis in order to save time. |
|
Name of a MATLAB variable used to store the transfer function at the end of an analysis. Set by the Output variable field. |
|
Plot a Bode diagram of the transfer function at the end of an analysis. Set by the Plot Bode diagram drop-down list. |
Extraction of State-Space Matrices
PLECS allows you to extract the state-space matrices describing the linear portion of a circuit model for a given combination of switch positions. The commands used for this purpose are listed below. In each of the commands circuit is the full Simulink path of a PLECS Circuit block.
Query the state-space order:
names = plecs('get', circuit, 'StateSpaceOrder');
Returns a struct containing the names of the components associated with the circuit model’s inputs, outputs, states and switches.
Set the switch positions for the subsequent analysis to
switchpos:plecs('set', circuit, 'SwitchVector', switchpos);
Retrieve state-space matrices:
t = plecs('get', circuit, 'Topology');
Returns a struct with the state-space matrices \(\mathbf{A}\), \(\mathbf{B}\), \(\mathbf{C}\), \(\mathbf{D}\) and \(\mathbf{I}\) for the vector of switch positions specified by the previous command. The matrix \(\mathbf{I}\) is the identity matrix if all electrical states are independent. Otherwise it specifies the relationship between the dependent variables. These matrices can be used for state_space averaging.
The matrices obtained can be further used for state_space averaging.
Example Model
See the example model “State Space Matrices”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Application Example
This section demonstrates the application of the analysis tools in PLECS Blockset for the design of the regulated buck converter system operating at a switching frequency of \(100\,\mathrm{kHz}\) shown in Fig. 94. The converter should supply a regulated \(15\,\mathrm{V}\) to a resistive load at a nominal load current of \(5\,\mathrm{A}\).
Fig. 94 Simulation model of the regulated buck converter
The examples used in this section follow the design example in Erickson [1], Chapter 9. They have been implemented in the following demo models:
Demo Model
See the demo model “Buck Converter with Parameter Sweep”.
Find it in PLECS under Window > Demo Models > Power Supplies.
Demo Model
See the demo model “Buck Converter with Analysis Tools”.
Find it in PLECS under Window > Demo Models > Power Supplies.
Demo Model
See the demo model “Buck Converter with Loop Gain Analysis”.
Find it in PLECS under Window > Demo Models > Power Supplies.
Steady-State Analysis
We first examine the open-loop behavior of the system. In order to get the desired output voltage we need to apply a fixed duty-cycle of \(V_\mathrm{out}/V_\mathrm{src} = 15\,\mathrm{V}/28\,\mathrm{V}\). You can verify this by using the Steady-State Analysis block to obtain the steady-state waveform of the output voltage.
For this purpose you copy the block into the model and double-click it to open the dialog box. The parameter System period length is already set to the correct value, i.e. 1e-5. Set the parameter Show steady-state cycles to e.g. 10 so that you can more easily check that the system is indeed in the steady state when the analysis finishes. Then click on Start analysis. The algorithm should converge after the first iteration, and the scope should show the waveform in Fig. 95.
Fig. 95 Steady-state output voltage
AC Sweep
Open-loop control-to-output transfer function
In order to determine the control-to-output transfer function, you need to perturb the steady-state duty-cycle and measure the corresponding perturbation of the output voltage. This is achieved by connecting an AC Sweep block as shown in Fig. 96. The block’s output is the perturbation signal; it is added to the steady-state duty cycle. The block’s input is connected to the load’s voltage signal.
Fig. 96 Simulation model to determine the open-loop control-to-output transfer function
The initial amplitude of the perturbation is set to 1e-3 which is approx. \(2/1000\) of the duty cycle. We want to sweep a frequency range between \(100\,\mathrm{Hz}\) and \(50\,\mathrm{kHz}\) with a few extra points between \(800\;\mathrm{Hz}\) and \(1200\,\mathrm{Hz}\). This is achieved by setting the parameter to [100 800:50:1200 50000]. As expected, the resulting bode plot (Fig. 97) of the transfer function shows a double pole at \(f_0 = 1/(2\pi\sqrt{LC}) \approx 1\,\mathrm{kHz}\) and a dc gain of \(G_0 = 28\,\mathrm{V} \approx 29\,\mathrm{dB}\).
Fig. 97 Bode plot of the open-loop control-to-output transfer function
Open-loop output impedance
Although not required for the compensator design, we will now calculate the output impedance for demonstration purposes. To do so we need to inject a small ac current into the converter output and measure the resulting perturbation of the output voltage. We therefore connect a Current Source (Controlled) in parallel with the load Resistor R as shown in Fig. 98. This current source is controlled by the perturbation signal of the AC Sweep block. The block input is again connected to the load voltage signal. The average steady-state output current is \(5\,\mathrm{A}\); we therefore set the initial perturbation amplitude to 1e-2.
Fig. 98 Simulation model to determine the open-loop output impedance
The resulting output impedance is shown in Fig. 99.
Fig. 99 Bode plot of the open-loop output impedance
Impulse Response Analysis
Alternatively you can determine the open-loop transfer functions using the Impulse Response Analysis block as shown in Fig. 100. In this analysis method, the calculation of an individual output point is relatively inexpensive. We therefore set the number of points to 300 and extend the sweep range to [10 50000]. In order to compensate for the discrete rectangular pulse used to perturb the system, we choose the setting external reference for the control-to-output transfer function and discrete pulse for the output impedance. This option is specific to the PLECS Blockset. It separately handles the calculation of control-to-output transfer functions that depend on the duty cycle of a switched converter, where the rectangular input signal can interfere with the modulator’s sampling.
Fig. 100 Using the Impulse Response Analysis block
Loop Gain Analysis
Compensator settings
The compensator should attain a crossover frequency of \(f_c = 5\,\mathrm{kHz}\). At this frequency, the open-loop control-to-output transfer function has a phase of nearly -180°. It should be lifted by 52° to get a peak overshoot of 16%. This is achieved using a PD compensator with a zero at \(f_z = 1.7\,\mathrm{kHz}\), a pole at \(f_p = 14.5\,\mathrm{kHz}\) and a dc gain of \(k = (f_c/f_0)^2\sqrt{f_z/f_p}/G_0 \approx 0.3\). For a zero stationary error a PI compensator with an inverted zero at \(f_Z = 500\,\mathrm{Hz}\) is added.
The compensator is implemented as shown in Fig. 101 (left). The compensator output is limited to the interval \([0.1, 0.9]\). In order to prevent windup problems during the steady-state analysis, the integrator is limited to the same range. Its transfer function is shown in Fig. 101 (right).
Fig. 101 PID compensator design (top) and its transfer function (bottom)
Loop gain
The loop gain of the closed control loop is measured by inserting the Loop Gain Analysis (AC Sweep) block into the loop path. A good place is the feedback path as shown in Fig. 102. The average steady-state load voltage is \(15\,\mathrm{V}\); the initial perturbation amplitude is therefore chosen as \(10^{-2}\). The convergence of the initial steady-state analysis can be accelerated by pre-charging the capacitor to its average steady-state voltage.
Fig. 102 Simulation model to determine the loop gain
As can be seen from the resulting bode plot (Fig. 103), the design goals for crossover frequency and phase margin have been reached.
Fig. 103 Bode plot of the loop gain (solid) shown together with the open-loop control-to-output function (dashed) and the PID compensator transfer function (dotted).
State-Space Averaging
Another method for obtaining the open-loop transfer functions of a circuit is a technique called state-space averaging. This topic is fairly complex and could easily fill a book of its own. This manual therefore assumes that you are familiar with the concept and just highlights how to use PLECS in the process.
Example Model
See the example model “State Space Matrices”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
The small-signal ac model of a dc converter operating in continuous conduction mode (CCM) is described by the equation system
where the quantities \(\tilde{\mathbf{x}}(t)\), \(\tilde{\mathbf{u}}(t)\), \(\tilde{\mathbf{y}}(t)\) and \(\tilde{m}(t)\) are small ac variation around the operating point \(\bar{\mathbf{x}}\), \(\bar{\mathbf{u}}\), \(\bar{\mathbf{y}}\) and \(\bar{m}\). The averaged state-space matrices \(\bar{\mathbf{A}}\), \(\bar{\mathbf{B}}\), \(\bar{\mathbf{C}}\) and \(\bar{\mathbf{D}}\) are defined as
where the subscript \(_1\) denotes the interval when the switch is conducting and the diode blocking, and the subscript \(_2\) denotes the interval when the switch is blocking and the diode conducting.
You can use PLECS to calculate the different matrices \(\mathbf{A}_1\), \(\mathbf{A}_2\) etc. and from these the various transfer functions. Using the buck converter from the previous example, the first step is to determine the internal order of the switches:
load_system('plBuckSweep');
names = plecs('get', 'plBuckSweep/Circuit', ...
'StateSpaceOrder');
names.Switches
ans =
'Circuit/FET'
'Circuit/D'
Next you retrieve the state-space matrices for the two circuit topologies:
plecs('set', 'plBuckSweep/Circuit', 'SwitchVector', [1 0]);
t1 = plecs('get', 'plBuckSweep/Circuit', 'Topology');
plecs('set', 'plBuckSweep/Circuit', 'SwitchVector', [0 1]);
t2 = plecs('get', 'plBuckSweep/Circuit', 'Topology');
Now you can calculate the averaged state-space matrices:
m = 15/28;
A = t1.A*m + t2.A*(1-m);
B = t1.B*m + t2.B*(1-m);
C = t1.C*m + t2.C*(1-m);
D = t1.D*m + t2.D*(1-m);
Output impedance
The output impedance is the transfer function from a state-space input (the current source I_ac) to a state-space output (the voltmeter Vm). Such a transfer function is given by:
Since the circuit model is a MIMO (multi-input multi-output) model, you need to specify the indices of the proper elements in the input and output vector. You can identify them using the fields Inputs and Outputs of the struct names that you retrieved earlier:
names.Inputs
ans =
'Circuit/V_dc'
'Circuit/I_ac'
names.Outputs
ans =
'Circuit/Vm'
'Circuit/Am'
'Circuit/FET'
'Circuit/FET'
'Circuit/D'
'Circuit/D'
So, the output impedance is the transfer function from input 2 to output 1. If you have the Control System Toolbox, you can now display the Bode diagram as shown in Fig. 104.
bode(ss(A,B(:,2),C(1,:),D(1,2)), {2*pi*100, 2*pi*50000})
Fig. 104 Open-loop output impedance (solid line) calculated with state-space averaging compared to the data points returned by the AC Sweep (dots).
Open-loop control-to-output transfer function
The control-to-output transfer function describes the effect of the small ac variation \(\tilde{m}\) on the system outputs. From the small-signal ac model equations we find that
with
Note that \(\mathbf{B}_{\mathrm{co}}\) and \(\mathbf{D}_{\mathrm{co}}\) are column vectors since there is only one scalar input variable, \(\tilde{m}\). The vector \(\bar{\mathbf{u}}\) is a column vector consisting of the dc input voltage and the small-signal ac current.
This leads to the following program code, resulting in the bode plot shown in Fig. 105.
u = [28; 0];
B_co = (-(t1.A-t2.A)*(A\B)+(t1.B-t2.B))*u;
D_co = (-(t1.C-t2.C)*(A\B)+(t1.D-t2.D))*u;
bode(ss(A,B_co,C(1,:),D_co(1)), {2*pi*100, 2*pi*50000})
Fig. 105 Bode plot of the open-loop control-to-output transfer function calculated with state-space averaging (solid) and the data points returned by the AC Sweep (dots).