Main Content

The design of feedback and feedforward gains for a given system is a common controller design technique. In this example, you use an extremum seeking controller to track a given reference plant model by adapting feedback and feedforward gains for an uncertain dynamical system.

For this example, consider the following first-order linear system.

$$\underset{}{\overset{\dot{}}{x}}(t)={a}_{0}x(t)+{b}_{0}u(t)$$

Here, $\mathit{x}\left(\mathit{t}\right)$ and $\mathit{u}\left(\mathit{t}\right)$ are the state and control input of the system, respectively. The constants ${\mathit{a}}_{0}$ and ${\mathit{b}}_{0}$ are unknown.

The goal of this example is to track the performance of the following reference plant model, which defines the required transient and steady-state behavior.

$${\underset{}{\overset{\dot{}}{x}}}_{ref}(t)={a}^{*}{x}_{ref}(t)+{b}^{*}r(t)$$

Here, ${\mathit{x}}_{\mathrm{ref}}\left(\mathit{t}\right)$ is the state of the reference plant and $\mathit{r}\left(\mathit{t}\right)$ is the reference signal.

The aim of the control signal $$u(t)$$ is to make the states $$x(t)$$of the uncertain system track the reference states ${\mathit{x}}_{\mathrm{ref}}\left(\mathit{t}\right)$.

$$u(t)=-Kx(t)+Kr(t)$$

The designed controller contains a feedback term $-\mathit{Kx}\left(\mathit{t}\right)$ and a feedforward term $\mathit{Kr}\left(\mathit{t}\right)$.

Substitute this control signal into the unknown linear system dynamics.

$$\underset{}{\overset{\dot{}}{x}}(t)={a}_{0}x(t)+{b}_{0}(-Kx(t)+Kr(t))$$

You can rewrite this expression as shown in the following equation.

$$\underset{}{\overset{\dot{}}{x}}(t)=-({a}_{0}+{b}_{0}K)x(t)+{b}_{0}Kr(t)$$

In the ideal case, if the coefficients ${\mathit{a}}_{0}$ and ${\mathit{b}}_{0}$ of the nominal system dynamics are known, then you can determine the controller gain $\mathit{K}$ using pole-placement techniques. Doing so produces the following matching condition.

$${a}_{0}+{b}_{0}K={a}^{*},{b}_{0}K={b}^{*}$$

When you use a single gain value as both the feedforward and feedback gain, this matching condition might not be satisfied for all the possible values of ${\mathit{a}}_{0}$ and ${\mathit{b}}_{0}$. For a more general solution, you can tune two different gain values (multiparameter tuning).

For this example, use the following unknown system and the reference dynamics.

$$\underset{}{\overset{\dot{}}{x}}(t)=-1x(t)+u(t)$$

$${\underset{}{\overset{\dot{}}{x}}}_{ref}(t)=-3{x}_{ref}(t)+2r(t)$$

In this case, the ideal control gain is $$K=-2$$.

To implement an extremum seeking control (ESC) approach to the preceding problem, you define an objective function, which the ESC controller then maximizes to find the controller gain $\mathit{K}$.

For this example, use the following objective function.

$$J=-5\int {(x(t)-{x}_{ref}(t))}^{2}dt$$

The following figure shows the setup for extremum seeking control.

The cost function is computed from the outputs of the reference system and the actual system.

The extremum seeking controller updates the gain parameter.

The control action is updated using the new gain value.

This control action is applied to the actual system.

This problem configuration is implemented in the `firstOrderrefTracking_Esc`

Simulink model.

```
mdl = 'firstOrderRefTracking_Esc';
open_system(mdl)
```

In this model, the gain value is optimized using the Extremum Seeking Control block.

The System Dynamics and Objective subsystem contains the reference model, the plant (including the actual system and control action), and the objective function computation. These elements are all implemented using MATLAB Function blocks.

`open_system([mdl '/System Dynamics and Objective'])`

Specify an initial guess for the gain value.

IC = 0;

The Extremum Seeking Control block perturbs the parameter value using a modulation signal. It then demodulates the resulting change in the objective function signal before computing the parameter update. Configure the extremum seeking control parameters for this block.

First specify the number of parameters to be tuned (`N`

) and the learning rate (`lr`

).

N = 1; lr = 0.55;

Configure the demodulation and modulation signals by specifying their frequency (`omega`

), phases (`phi_1`

and `phi_2`

), and their amplitudes (`a`

and `b`

).

omega = 5; % Forcing frequency a = 1; % Demodulation Amplitude b = 0.1; % Modulation Amplitude phi_1 = 0; % Demodulation phase phi_2 = 0; % Modulation phase

For this example, the Extremum Seeking Control block is configured to remove high-frequency noise from the demodulated signal. Set the cutoff frequency for the corresponding low-pass filter.

omega_lpf = 1;

Simulate the model.

sim(mdl);

To check the reference tracking performance, view the state trajectories from the simulation. The actual trajectory converges to the reference trajectory in less than five seconds.

`open_system([mdl '/System Dynamics and Objective/State'])`

To examine the behavior of the ESC controller, first view the objective function, which reaches its maximum value quickly.

`open_system([mdl '/System Dynamics and Objective/Cost'])`

By maximizing the objective function, the ESC controller optimizes the control gain value around its ideal value of –1. The fluctuations in the gain value are due to the modulation signal from the Extremum Seeking Control block.

`open_system([mdl '/System Dynamics and Objective/Gain K'])`

`bdclose('firstOrderRefTracking_Esc')`