Managing sampled control blocks: ZOH & Multi Time-Step Solver
This tutorial explores how to model sampled control blocks in Simba, especially with the Multi Time-Step Solver" feature.
Example considered in this tutorial
Let's consider the simple example of a buck chopper connected to a RL load, with a current control loop. It is quite usual to model this control loop with:
- a ZOH block which samples and holds - during a defined sampling time - the value measured bu the current probe,
- a C-code block which here:
- defines the current reference,
- implements a recurrent equation to regulate the current,
In Simba, a multi-time step solver has been especially developped for control circuits which may be evaluated at a different time-step than the power circuit (see Multi Time-Step Solver in Simba documentation ).
Thus, there two ways to model the control circuit of this example: a classical way with a ZOH block and a second one, without a ZOH, where the C-block defines itself the sampling time.
Modeling the control circuit with a ZOH
In this model, a ZOH block is considered: it defines a sampling time which is set here to T_s = 1 / f_{sw}, where the switching frequency f_{sw} is 100 kHz here.
Warning
It is mandatory that all the following control blocks which have to consider this sampling define the same sampling time. This can be simply done by setting the Sampling Time parameter at auto (they can also be set at the same value of sampling time).
The C-code block following the ZOH sees its Sampling Time parameter set at auto, as well as the limiter and the scaling gain (they could also define this parameter at the same value T_s as the ZOH block).
Then, the comparator block and the carrier block must not be sampled and thus define their Sampling Time parameter set at none.
Info
It is important to note that the Multi Time-Step Solver will only evaluate the outputs of the sampled blocks at the sampling events: thus the output of the ZOH block will not be the typical stair waveform that we usually expect.
This can be clearly seen in the figure below which plots the carrier, the output of the ZOH block, the output of the C-code and the current i_L through the inductor.
Modeling without ZOH
In this second model, no ZOH block is considered. Th C-code block defines itself the sampling time T_s as shown below:
The figures below show comparisons between the models with and without a ZOH block:
- of the inductor currents i_L of both models,
- of the output of the C-code block.
The currents have been plot with a single vertical axis and are thus superimposed as both models are equivalent.
Modeling with a discrete controller
The same principle can be applied with most of control blocks and especially the discrete controller (the controller in z-domain) instead of the C-code block. Indeed, as this block requires the definition of a sampling time, its input is naturally sampled: here also, no ZOH block is required.
The figure below shows that the outputs of the C-code and the discrete controller are identical:
Conclusion
This tutorial explained how to model sampled control blocks in Simba. The original feature in Simba of the Multi Time-step Solver makes possible to directly define a sampling time in control blocks avoiding the use of a ZOH block.
ZOH blocks are also available in Simba for users who want to keep a more classical way of modeling.
Warning
Finally, a lot of attention must be paid to the control blocks that follow a sampled control block and that have to consider this sampling: they must define the same sampling time with the Sampling Time parameter set at auto.