10.1 Implementation in MATLAB/Simulink
b0
(scalar, critical gain parameter b0 to be obtained from plant modeling), K
(row vector containing the controller gains kT), L
(column vector of observer gains l), A_ESO
(system matrix AESO of the observer), and B_ESO
(column vector, input gain bESO of the observer).10.2 Implementation in C Programming Language
10.2.1 State-Space Form
struct
as shown in Listing 10.2, also including parameters for limiting the controller output. A user will then have to instantiate this struct
, and pass the instance to further C functions implemented below. A more refined approach separating coefficients and state variables would, of course, also be possible.x1
and x2
). To abbreviate the resulting code, some intermediate variables (named f1
and f2
here) were introduced. These are the values fed back through the state-feedback control law, and also needed to update the state variables, i. e. the storage variables of the unit delay. Figure 10.2 links all required source code lines with their origin in the block diagram. As discussed in Sect. 9.1, every practical controller should limit its output and be equipped with anti-windup measures. We therefore added an output magnitude limitation to the controller, which was already apparent from the block diagram. The resulting C function for computing a new, limited controller output value can be found in Listing 10.4.
-
instantiate the data structure from Listing 10.2;
-
initialize the coefficients (“tune the controller”) by calling the function in Listing 10.3;
-
initialize the internal state variables before being able to bumplessly enable the controller using the function from Listing 10.5;
-
and, periodically (once every Ts), call the update function in Listing 10.4 to compute the next controller output from the most recently measured plant output, before feeding the controller output to the actuator of the user’s application.
10.2.2 Dual-Feedback Transfer Function Form
struct
for parameters and internal state variables. The result is shown in Listing 10.6, also including parameters for the controller output limitation.x1
and x2
. It is also useful to introduce an intermediate variable—named f
here—which is being fed back through the α coefficients. To better support understanding the process of translating a block diagram to a programming language, Fig. 10.3 shows the block diagram annotated with C source code lines. A magnitude limitation was added to the controller output. The resulting C function for computing the controller output value is given in Listing 10.8.
-
instantiating the data structure from Listing 10.6;
-
initializing the coefficients (= tuning the controller) by calling the function in Listing 10.7;
-
initializing the internal state variables before being able to bumplessly enable the controller using the function from Listing 10.9;
-
and, periodically (once per sampling interval Ts), calling the update function in Listing 10.8 to compute the next controller output from the most recently measured plant output. The resulting controller output must then be fed to the actuator of the user’s application.