PLECS 3.3 Online Help |
Many specifications of a power electronic system are often given in terms of steady-state characteristics. A straight-forward way to obtain the steady-state operating point of a system is to simulate over a sufficiently long time-span until all transients have faded out. The drawback of this brute-force approach is that it can be very time consuming. Usually a system has time constants that are much longer than the switching period. This applies in particular to electro-thermal models.
The steady-state analysis of a periodic system is based on a quasi-Newton method with Broyden's update. In this approach the problem is formulated as finding the roots of the function
where is an initial vector of state variables and
is the final vector of state
variables one period
later.
Evaluating or
therefore involves running a simulation from
to
. The period,
, must be the least common multiple of the periods of
all sources (signal or electrical) in the model.
The above problem can be solved iteratively using
The Jacobian is calculated numerically using finite differences. If
is the
number of state variables, calculating the Jacobian requires
simulation runs
where each state variable in turn is slightly perturbed and the difference between the
perturbed and unperturbed solution is computed to obtain one column of
:
Because this is computationally expensive, only the first Jacobian is actually computed this way. In subsequent iterations, the Jacobian is updated using Broyden's method, which does not require any additional simulations.
The convergence criterion of the iterations is based on the requirement that both
the maximum relative error in the state variables and the maximum relative
change from one iteration to the next are smaller than a certain limit :
A steady-state analysis comprises the following steps:
To reduce the number of simulation runs and thus save computation time PLECS can calculate the Jacobian matrix entries pertaining to thermal states directly from the state-space matrices rather than using finite differences.
There is a certain error involved with this method since it neglects the feedback from the thermal states to the electrical states (or Simulink states). While this will not affect the accuracy of the final result of the steady-state analysis it may slow down the convergence. Normally, however, the overall performance will be much faster than calculating the full Jacobian matrix.
The calculation method is controlled by the parameter JacobianCalculation (see below).
In the PLECS Blockset, the steady-state analysis depends on the fact that a model can be completely initialized with the InitialState parameter of the sim command. However, certain Simulink blocks that clearly have an internal memory do not store this memory in the state vector and therefore cannot be initialized. Among these blocks are the Memory block, the Relay block, the Transport Delay block and the Variable Transport Delay block. If a model contains any block with hidden states, the algorithm may be unable to find a solution.
If the effect of a state variable on the system is limited in some way but the state variable itself is not limited, it might wind up towards infinity. In this case the algorithm may fail to converge or return a false solution. In order to avoid this problem you should limit the state variable itself, e.g. by enabling the Limit output checkbox of an Integrator block.
The AC Analysis uses the Steady-State Analysis to compute the transfer function of a periodic system at discrete analysis frequencies. For each frequency the following steps are executed:
The perturbation frequencies are defined by specifying the sweep range and the number of points to be placed within this range on a linear or logarithmic scale.
An alternative and faster method to determine the open loop transfer function of a system is the Impulse Response Analysis. Instead of perturbing a system with sinusoidal stimuli of different frequencies, one at a time, a single impulse is applied when the system is in steady state. The system transfer function can then be calculated very efficiently over a wide frequency range (from zero to half the system frequency) by computing the Laplace transform of the transient impulse response.
The impulse response analysis is performed in three steps:
Theoretically, in order to compute the system transfer function from the Laplace transform of the system response, the system must be perturbed with a unit Dirac impulse (also known as delta function). This is not practical for numerical analysis, so the algorithm applies a finite rectangular pulse instead. For transfer functions such as the line-to-output transfer function or the output impedance this can be compensated for by dividing the Laplace transform of the system response by the Laplace transform of the rectangular pulse. This is achieved by setting the parameter Compensation for discrete pulse to discrete pulse, which is the default.
However, when calculating control-to-output transfer functions that involve the duty cycle of a switched converter, the rectangular input signal interferes with the sampling of the modulator. In this case the compensation type should be set to external reference. This causes the Impulse Response Analysis block to have two input signals that should be connected as shown in this figure.
Finally, you can set the compensation type to none which means that the computed transfer function is taken as is. Use this setting if the modulator uses regular sampling and the sampling period is identical to the system period.
In PLECS Standalone all analyses are managed in the Analysis Tools Dialog shown below. To open the dialog, select Analysis tools... from the Simulation menu of the schematic editor.
The left hand side of the dialog window shows a list of the analyses that are currently configured for the model. To add a new analysis, click the button marked + below the list and select the desired analysis type. To remove the currently selected analysis, click on the button marked -. You can reorder the analyses by clicking and dragging an entry up and down in the list.
The right hand side of the dialog window shows the parameter settings of the currently selected analysis. Each analysis must have a unique Description. The other parameters available for the different analysis types are described further below.
The button Start analysis/Abort analysis starts the currently selected analysis or aborts the analysis that is currently running. The button Show log/Hide log shows or hides a log window that displays the progress of an analysis and diagnostic messages.
In order to perform an AC sweep, you need to insert a Small Signal Perturbation and a Small Signal Response block in order to define the points at which the perturbation is injected and the response is measured. The Small Signal Gain block can be used to obtain the closed loop gain of a feedback loop.
At the end of an analysis, a scope window will open and display the Bode diagram of the transfer function. You can also open the scope manually by clicking one Show results button.
For a description of the steady-state options please refer to Steady-State Analysis.
In order to perform an impulse response analysis, you need to insert a Small Signal Perturbation and a Small Signal Response block in order to define the points at which the perturbation is injected and the response is measured.
At the end of an analysis, a scope window will open and display the Bode diagram of the transfer function. You can also open the scope manually by clicking one Show results button.
For a description of the parameters please refer to AC Sweep. In an impulse response analysis, the computational effort for an individual frequency is very cheap. Therefore, the parameter Additional frequencies is omitted; instead, the Number of points can be set to a large value in order obtain smooth curves.
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. These commands can be used both in a Simulation Script and on the Octave console. In each of the commands circuit is the name of the circuit model.
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.
plecs('set', circuit, 'SwitchVector', switchpos);
sets the vector of switch positions for the subsequent analysis to switchpos.
t = plecs('get', circuit, 'Topology');
returns a struct with the state space matrices A, B, C, D and I for the vector of switch positions specified by the previous command. The matrix I is the identity matrix if all electrical states are independent. Otherwise it specifies the relationship between the dependent variables.
Above commands can also be invoked via the XML-RPC interface using an analogous syntax.
The demo model BuckOpenLoop implements the buck converter shown below. It operates at a switching frequency of 100 kHz with a fixed duty-cycle of 15/28. To run a transient simulation from zero initial conditions, select Start from the Simulation menu.
To view the analyses configured in this model select Analysis tools... from the
Simulation menu. The only periodic source in the model is the carrier signal used in
the modulator. Hence, the parameter System period for all analyses is specified as
.
To view the steady-state operation of the converter, select Steady-State Analysis from the list and click on Start analysis. After the analysis has found the periodic operating point, the scope will show five steady-state cycles.
For the calculation of the control-to-output transfer function, a small perturbation needs to be added to the modulation index. This is done with the Small Signal Perturbation block m', which has the Show feed-through input setting enabled. The system output in this case is defined as the output voltage of the converter. The output signal of the voltmeter is therefore connected to the Small Signal Response block vo'.
To calculate the transfer function using the AC Sweep, select Control to Output TF (AC Sweep) from the list and click on Start analysis. The analysis sweeps the frequency range between 100 Hz and 50 kHz. 21 points are placed logarithmically within this range; to obtain a smoother output, additional data points are generated between 800 and 1400 Hz.
To calculate the transfer function using the Impulse Response Analysis, select Control to Output TF (Impulse Response) from the list and click on Start analysis.
For the calculation of the output impedance, a small perturbation current is injected into the converter output using a current source that is controlled by the Small Signal Perturbation block i' and the output voltage response is measured. As above, two analyses have been configured that calculate the impedance using the AC Sweep and the Impulse Response Analysis.
The demo model BuckClosedLoop implements the controlled buck converter shown below. A PID controller regulates the output voltage to 15 volts.
For the calculation of the voltage loop gain, the Small Signal Gain block Loop Gain Meter has been inserted into the feedback path. If you look under the mask of the Small Signal Gain, you can see how the block both injects a small perturbation and measures the system response.
To calculate the loop gain, select Analysis tools... from the Simulation menu, then choose Closed Loop Gain from the list of analyses and click Start analysis.
In the PLECS Blockset, you configure analyses by copying the appropriate blocks from the Analysis Tools library in PLECS Extras into your model.
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 |
TimeSpan | 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. |
TStart | Simulation start time. Set by the Simulation start time field. |
Tolerance | Relative error tolerance used in the convergence criterion. Set by the Termination tolerance field. |
MaxIter | Maximum number of iterations allowed. Set by the Max number of iterations field. |
Display | Specifies the level of detail of the diagnostic messages displayed in the command window (iteration, final, off). Set by the Display drop-down list. |
HideScopes | Hide all Simulink scope windows during an analysis in order to save time. |
HiddenStates | Specifies how to handle Simulink blocks with `hidden' states, i.e. states that are not stored in the state vector (error, warning, none). Set by the Hidden model states drop-down list. |
FinalStateName | 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. |
NCycles | Number of steady-state cycles that should be simulated at the end of an analysis. Set by the Show steady-state cycles field. |
JPert | Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
JacobianCalculation | Controls the way the Jacobian matrix is calculated (full, fast). The default is fast. |
NInitCycles | 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 0. |
These examples show how to run analyses for the block Steady State in the model mymodel:
plsteadystate('mymodel/Steady State');
starts an analysis using the parameters specified in the dialog box.
plsteadystate('mymodel/Steady State', 'TStart', 0, ...
'FinalStateName', 'x0');
plsteadystate('mymodel/Steady State', 'TStart', 1, ...
'FinalStateName', 'x1');
performs two analyses with different start times and assigns the resulting steady-state vectors to two different variables x0 and x1. 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.
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 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 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 AC Sweep and Loop Gain Analysis blocks. 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 |
TimeSpan | Period length of the unperturbed system. Set by the System period length field. |
TStart | Simulation start time. Set by the Simulation start time field. |
FreqRange | Range of the perturbation frequencies. Set by the Frequency sweep range field. |
FreqScale | Specifies whether the sweep frequencies should be distributed on a linear or logarithmic scale. Set by the Frequency sweep scale field. |
NPoints | Number of data points generated. Set by the Number of points field. |
InitialAmplitude | Perturbation amplitude at the first perturbation frequency. Set by the Amplitude at first freq field. |
Method | Method used for obtaining the periodic steady-state operating point of the perturbed system: Brute force simulation - start from model initial state, Brute force simulation - start from unperturbed steady state, Steady-state analysis - start from model initial state, Steady-state analysis - start from unperturbed steady state. Set by the Method drop-down list. |
Tolerance | Relative error tolerance used in the convergence criterion. Set by the Termination tolerance field. |
MaxIter | Maximum number of iterations allowed. Set by the Max number of iterations field. |
Display | Specifies the level of detail of the diagnostic messages displayed in the command window (iteration, final, off). Set by the Display drop-down list. |
HideScopes | Hide all Simulink scope windows during an analysis in order to save time. |
HiddenStates | Specifies how to handle Simulink blocks with 'hidden' states, i.e. states that are not stored in the state vector (error, warning, none). Set by the Hidden model states drop-down list. |
OutputName | Name of a MATLAB variable used to store the transfer function at the end of an analysis. Set by the Output variable field. |
BodePlot | Plot a Bode diagram of the transfer function at the end of an analysis. Set by the Plot Bode diagram drop-down list. |
JPert | Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
NInitCycles | If a steady-state analysis is used to obtain the starting point of the ac analysis (see parameter Method above), this parameter specifies the number of cycle-by-cycle simulations that should be performed before the steady-state analysis. This parameter can be used to provide the algorithm with a better starting point. The default is 0. |
These examples show how to run analyses for the block AC Sweep in the model mymodel:
placsweep('mymodel/AC Sweep');
starts an analysis using the parameters specified in the dialog box.
placsweep('mymodel/AC Sweep', 'TStart', 0, ...
'OutputName', 'T0');
placsweep('mymodel/AC Sweep', 'TStart', 1, ...
'OutputName', 'T1');
performs two analyses with different start times and assigns the resulting transfer functions to two different variables T0 and T1. 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.
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 Resonse 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 |
TimeSpan | Period length of the unperturbed system. Set by the System period length field. |
TStart | Simulation start time. Set by the Simulation start time field. |
FreqRange | Range of the perturbation frequencies. Set by the Frequency sweep range field. |
FreqScale | Specifies whether the sweep frequencies should be distributed on a linear or logarithmic scale. Set by the Frequency sweep scale field. |
NPoints | Number of data points generated. Set by the Number of points field. |
Perturbation | Perturbation amplitude of the discrete impulse. Set by the Perturbation field. |
Compensation | Specifies whether and how the effect of the sampling should be compensated (none, discrete pulse, external reference). Set by the Compensation for discrete pulse drop-down list. |
Tolerance | Relative error tolerance used in the convergence criterion of the initial steady-state analysis. Set by the Termination tolerance field. |
MaxIter | Maximum number of iterations allowed. Set by the Max number of iterations field. |
Display | Specifies the level of detail of the diagnostic messages displayed in the command window (iteration, final, off). Set by the Display drop-down list. |
HideScopes | Hide all Simulink scope windows during an analysis in order to save time. |
HiddenStates | Specifies how to handle Simulink blocks with 'hidden' states, i.e. states that are not stored in the state vector (error, warning, none). Set by the Hidden model states drop-down list. |
OutputName | Name of a MATLAB variable used to store the transfer function at the end of an analysis. Set by the Output variable field. |
BodePlot | Plot a Bode diagram of the transfer function at the end of an analysis. Set by the Plot Bode diagram drop-down list. |
JPert | Relative perturbation of the state variables used to calculate the approximate Jacobian matrix. |
NInitCycles | If a steady-state analysis is used to obtain the starting point of the ac analysis (see parameter Method above), this parameter specifies the 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 0. |
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.
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.
plecs('set', circuit, 'SwitchVector', switchpos);
sets the vector of switch positions for the subsequent analysis to switchpos.
t = plecs('get', circuit, 'Topology');
returns a struct with the state space matrices A, B, C, D and I for the vector of switch positions specified by the previous command. The matrix I is the identity matrix if all electrical states are independent. Otherwise it specifies the relationship between the dependent variables.
This section demonstrates the application of the analysis tools in the PLECS Blockset for the design of the regulated buck converter system operating at a switching frequency of 100 kHz shown in the figure below. The converter shall supply a regulated 15 volts to a resistive load at a nominal load current of 5 amperes.
The examples used in this section follow the design example in [Erickson], chapter 9. They have been implemented in the demo models plBuckSweep, plBuckImpulseResponse and plBuckLoop.
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 . 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 the figure below.
Steady-state output voltage
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 below. The block output is the perturbation signal; it is added to the steady-state duty cycle. The block input is connected to the load voltage signal.
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 100Hz and 50kHz
with a few extra points between 800Hz and 1200Hz. This is achieved by setting the
parameter to [100 800:50:1200 50000]. As expected, the resulting bode plot of the
transfer function shows a double pole at and a dc gain of
.
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 controlled current source in parallel with the load resistor as shown below. 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 amperes; we therefore set the initial perturbation amplitude to 1e-2.
Open-loop output impedance
Alternatively you can determine the open-loop transfer functions using the Impulse Response Analysis block as shown in the figure below. 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.
Using the Impulse Response Analysis block
PID compensator and transfer function
Closed-loop gain
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. The code examples given here are collected in the demo M-file plSSADemo.
The small-signal ac model of a dc converter operating in continuous conduction mode (CCM) is described by the equation system
You can use PLECS to calculate the different matrices ,
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:
Next you retrieve the state-space matrices for the two circuit topologies:
Now you can calculate the averaged state-space matrices:
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:
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:
The figure below shows the output impedance drawn with a solid line. The dots represent the data points returned by the ac sweep.
Open-loop output impedance
Open-loop control-to-output transfer function
The control-to-output transfer function describes the effect of the small ac
variation on the system outputs. From the small-signal ac model equations we
find that
with
This leads to the following program code:
The figure below shows the control-to-output transfer function drawn with a solid line. The dots represent the data points returned by the ac sweep.
Open-loop control-to-output transfer function