1 Introduction

Nonlinear system identification is now a mature field. For the last three decades, much attention has been paid to the problem of building nonlinear models from data [10, 22, 33, 40]. A natural next step is the use of such identified models in more specific applications, such as compensation and control, which is the aim of this work.

The presence of nonlinear effects can impose significant performance limitations in a wide range of applications, such as actuators [7,8,9, 20, 25, 37], sensors [13, 18], pH neutralization [21], and power systems [41], among others [14, 15, 30, 32, 44, 45]. A natural solution would be to mitigate such effects by making the systems more linear with the aid of a compensator and, consequently, more amenable to control. A dynamical model with a simple structure is quite useful to design a compensator.

Compensation approaches aim to design a compensation input that reduces nonlinearity, allowing for more accurate control and tracking. Many of these approaches start with an appropriate model that represents the most fundamental aspects of the system, especially the static nonlinearity [5]. In the literature, there is a vast number of works devoted to the modeling and compensation for nonlinear systems ranging from those based on phenomenological models [7,8,9, 26, 27, 37, 44] to those that use computational intelligence [36] such as Radial Basis Functions (RBFs) [13, 25, 47] and Neural Networks (NNs) [19, 30, 31, 41, 45, 46], among others.

The identification of phenomenological models tends to be a challenging task that requires sophisticated algorithms based often on heuristics techniques. Therefore, satisfactory results depend largely on the proper design of these algorithms, including the tuning of meta-parameters, which is usually an empiric task [36]. In addition, the design of compensators from such models is not usually simple or even possible, because it depends on the analytical inversion of these models. For methods based on universal approximation of functions, such as RBFs and NNs, it is more difficult to provide a physics-based interpretation [36]. A particular type of neural network that has been often used in the literature for identification and compensation of nonlinear systems is the Nonlinear AutoRegressive with eXogenous inputs Neural Networks, i.e., NARX NNs [31, 46]. Despite the benefits of NARX NNs due to the fair generality presented by NARX structures, these frameworks are based on a black-box philosophy that complicates the use of constraints related to the structure or parameters, which can be elegantly accommodated in gray-box approaches [1]. Also, their compensators present low or no degree of interpretability, which limits the analysis of these types of models and their compensators.

An alternative framework is based on NARX polynomial models, which are adopted in this paper. For this class of models, if the structure is carefully chosen [3, 12, 35], besides being quite general [24], such models can encode nonlinear information in a simple and recognizable way [5, 29], which allows using them to derive explicitly compensation laws [1]. In addition, NARX polynomials are amenable to gray-box techniques [2] that allow the encoding relevant features from nonlinear systems, which is usually not possible with purely black-box strategies. From now on, the term NARX models must be understood strictly as NARX polynomial models, and form the basis of this work. Although these models can represent a variety of phenomena, few works in the literature apply NARX polynomials for compensation since the most common applications take NARX NNs as a basis.

In the context of hysteresis compensation, [23] has presented a strategy based on an analytical inversion of NARX models. For this purpose, somewhat restrictive assumptions must be satisfied by the model structure. Also, as pointed out in [1], the methodology developed by [23] may suffer from singularity problems when the velocity variable is equal to zero.

Two ways to design compensators have been presented in [1]: The first one is similar to what was done in [23] and the second seeks compensators directly from the data. Both strategies have overcome the singularity problem because the restrictions on the models structure prevent a division by the velocity variable in the compensator. However, as the former also needs to isolate the input explicitly, such a method handles with more specific structures than those used in the present paper. The second strategy requires careful data processing, such as filtering the output signals. Also, some algebraic manipulations are required to overcome potential causality problems [1].

The main contributions of this work are the proposed approaches to find compensation inputs iteratively for nonlinear systems in static and dynamical contexts through identified NARX models. Besides, an adaptation of the dynamical strategy is presented for hysteretic systems. In both strategies, an algebraic polynomial of the compensation input is formulated, which is achieved by manipulating the identified model. Thus, the compensation signal is calculated iteratively, which confers an adaptive feature to the approaches. The proposed compensators are compared with one well-established [37] and two recent [1] ones.

This work is organized as follows. In Sect. 2, background is provided and the compensation problem is stated in Sect. 2.2. Section 3 presents the formulation for static compensation (3.1), dynamical compensation (3.2) and adapts such formulation specifically for systems with hysteresis (3.3). Numerical and experimental results are discussed in Sect. 4. Finally, concluding remarks are given in Sect. 5.

2 Background

A NARX (Nonlinear Autoregressive model with eXogenous inputs) polynomial model \({{\mathcal {M}}}\) for a single-input single-output system is given by [24]:

$$\begin{aligned} y(k)&{=}&f^\ell \big (y(k{-}1), \ldots ,y(k{-}n_y), \nonumber \\&~&\quad u(k{-}\tau _\mathrm{d}), \ldots ,u(k{-}n_u)\big ){+}e(k), \end{aligned}$$
(1)

where \(u(k),\,y(k) \in {\mathbb {R}}\) are, respectively, the input and output signals sampled at instant \(k \in {\mathbb {N}}\), and \(f^\ell (\cdot )\) is a nonlinear polynomial function with degree \(\ell \in {\mathbb {N}}^+\). \(n_u,\,n_y \in {\mathbb {N}}^+\) are the maximum lags for u and y, respectively, \(\tau _\mathrm{d} \in {\mathbb {N}}^+\) is the pure time delay, and e(k) accounts for the uncertainties and possible noise.

Model (1) is a parsimonious polynomial model in the sense that it contains only a small group of regressors chosen from an usually large set of candidate regressors by means of some structure selection procedure [3, 12, 17, 35, 38]. Each regressor of \({{\mathcal {M}}}\), which can be any linear and nonlinear combination up to degree \(\ell \), is multiplied by a constant parameter, \(\theta _i\). Hence, a NARX polynomial model is linear-in-the-parameters and classic least squares (LS) procedures can be used [34]. In the presence of noise, however, it is common to add moving average (MA) terms to the model, which will no longer be linear-in-the-parameters. Fortunately, extended least squares estimators (ELS) can be used to circumvent noise-induced bias [12, 28].

2.1 Steady-state analysis

The steady-state relation of model (1) is obtained by taking \(u(k)={\bar{u}}\) and \(y(k)={\bar{y}}, ~\forall k\), thus yielding:

$$\begin{aligned} \bar{{\mathcal {M}}}: ~ {\bar{y}} = {\bar{f}}^{\ell }({\bar{u}},{\bar{y}}), \end{aligned}$$

which, for a known value of \({\bar{u}}\), can be rewritten as:

$$\begin{aligned}&c_{y,\,\ell _y}({\bar{u}}){\bar{y}}^{\ell _y}{+}c_{y,\,\ell _y{-}1}({\bar{u}}) {\bar{y}}^{\ell _y{-}1}+\ldots +c_{y,1}({\bar{u}}){\bar{y}}\nonumber \\&\quad + c_{y,0}({\bar{u}}) {=} 0, \end{aligned}$$
(2)

where \(1 \le \ell _y \le \ell \) is the degree of the static model \(\bar{{\mathcal {M}}}\), whose coefficients \(c_{y,i},~i=0,\ldots ,\ell _y\) usually depend on \({\bar{u}}\). Solving (2) for the unknown \({\bar{y}}\) is achieved by finding the \(\ell _y\) roots of this polynomial. The roots of (2) will yield the fixed points of model (1) for \({\bar{u}}\), whose definition is presented below.

Definition 1

(Fixed points [6]) The steady-state analysis of model (1) is computed by taking \(y(k){=}{\bar{y}},\,\forall k\) and \(u(k){=}{\bar{u}},\,\forall k\), yielding \({\bar{y}} = {\bar{f}}^{\ell }({\bar{y}},{\bar{u}})\), whose solution/root(s) \({\bar{y}}\) (2) for a given constant value of input \({\bar{u}}\) is defined as the fixed point(s), or equilibria, of model (1) for \({\bar{u}}\).

The condition for (local) stability of the fixed points is obtained by finding the eigenvalues of the Jacobian matrix of model \({\mathcal {M}}\) (1) evaluated at each fixed point, as follows:

$$\begin{aligned} \bigg |\mathrm{{eig}} \left( \frac{\partial f^{\ell }}{\partial {\varvec{y}}} \Big |_{{\bar{u}},{\bar{y}}} \right) \bigg | < 1, \end{aligned}$$
(3)

where \({\varvec{y}}=[y(k-1)\, \ldots y(k-n_y)]^T\), T is the transpose and \(\mathrm{eig}(\cdot )\) indicates the eigenvalues.

Example 1

Consider model \({{\mathcal {M}}}\) given by:

$$\begin{aligned} y(k)&{=}&{\hat{\theta }}_1y(k-1)+{\hat{\theta }}_2u(k-1)+{\hat{\theta }} _3u(k-1)u(k-2) \nonumber \\&{~}&+{\hat{\theta }}_4u(k-1)^2+{\hat{\theta }}_5u(k-1)^3, \end{aligned}$$
(4)

for which \(\tau _\mathrm{d} {=} 1\), \(n_y{=}1\), \(n_u{=}2\), and \(\ell {=}3\). Its static form \(\bar{{\mathcal {M}}}\) is obtained taking \(u(k\!-1){=}u(k-2){=}{\bar{u}}\) and \(y(k-1)=y(k){=}{\bar{y}}\), such that:

$$\begin{aligned} {\bar{y}} = {\hat{\theta }}_1{\bar{y}} +{\hat{\theta }}_2 {\bar{u}}+{\hat{\theta }}_3{\bar{u}}^2 +{\hat{\theta }}_4{\bar{u}}^2+{\hat{\theta }}_5{\bar{u}}^3, \end{aligned}$$
(5)

which can be written in the format of (2) as:

$$\begin{aligned} 0 = \underbrace{\big [{\hat{\theta }}_1-1\big ]}_{c_{y,1}}{\bar{y}} + \underbrace{{\hat{\theta }}_5{\bar{u}}^3 +\big [{\hat{\theta }}_3+{\hat{\theta }}_4\big ]{\bar{u}}^2 + {\hat{\theta }}_2 {\bar{u}}}_{c_{y,0}({\bar{u}})}. \end{aligned}$$
(6)

Hence, model (4) only has one fixed point for each value of \({\bar{u}}\), given by:

$$\begin{aligned} {\bar{y}} = -\dfrac{c_{y,0}({\bar{u}})}{c_{y,1}} = \dfrac{{\hat{\theta }}_5{\bar{u}}^3+\big [{\hat{\theta }}_3+{\hat{\theta }} _4\big ]{\bar{u}}^2+{\hat{\theta }}_2{\bar{u}}}{1-{\hat{\theta }}_1}. \end{aligned}$$
(7)

For the first-order model (4), the Jacobian “matrix” will be a scalar and condition (3) becomes:

$$\begin{aligned} \left| \frac{\partial f^{\ell }}{\partial y(k-1)} \Big |_{{\bar{u}},{\bar{y}}} \right|< & {} 1, \nonumber \\ \left| {\hat{\theta }}_1 \Big |_{{\bar{u}},{\bar{y}}} \right|< & {} 1, \nonumber \\ -1 ~<~ {\hat{\theta }}_1< & {} 1. \end{aligned}$$
(8)

If (8) is satisfied, then (7) is a stable fixed point. \(\square \)

2.2 Statement of the problem

It is assumed that a NARX model \({\mathcal {M}}\) (1) is available for a given nonlinear dynamical system \({\mathcal {S}}\), estimated from input-output data \(Z^N=\{u(k),\,y_\mathrm{s}(k)\}_{k=1}^N\) collected from \({\mathcal {S}}\). Based on \({{\mathcal {M}}}\), the aim is to design a compensator \({{\mathcal {M}}}_r\) such that the open-loop combination of \({{\mathcal {M}}}_r\) followed by \({\mathcal {S}}\) (see Fig. 1) is more linear and therefore more amenable for control. Specifically, \({{\mathcal {M}}}_r\) should compensate the nonlinearity in \({\mathcal {S}}\).

Fig. 1
figure 1

Block diagram of the compensated system

Mathematically, we require that the reference r(k) and output \(y_\mathrm{c}(k)\) of the compensated system should be closer to each other than the input u(k) and output \(y_\mathrm{s}(k)\) of the uncompensated system. Hence if J is some proximity cost function, like the mean squared value, we require that \(J[r(k),\,y_\mathrm{c}(k)]<J[u(k),\,y_\mathrm{s}(k)]\).

3 Methodology

This section presents the methodology developed to design compensators based on NARX polynomial models. First, in Sect. 3.1, we present the static compensation that is simpler to understand and serves as a basis for the main result, which is the dynamical compensation detailed in Sect. 3.2. In the sequel, this approach is applied to systems with hysteresis in Sect. 3.3. The identification of model \({{\mathcal {M}}}\) is not described in this paper. The interested reader is referred to [2] for a view of system identification methods, and [43] for the procedures followed to obtain the models used in this paper.

3.1 Static compensation

It is assumed that the input and output signals are bounded, thus \(u(k) \in [u_\mathrm{min},\, u_\mathrm{max}], \forall k\) and \(y_\mathrm{s}(k) \in \) \([y_{\mathrm{min}},\ y_{\mathrm{max}}], \forall k\). As for model \({\mathcal {M}}\) (1), the following assumptions will be needed:

Assumption 1

\({\mathcal {M}}\) is valid, that is, \(y(k) \approx y_\mathrm{s}(k)\) for the same input.

Assumption 2

For any \({\bar{u}} \in [u_\mathrm{min},u_\mathrm{max}]\), the model \({{\mathcal {M}}}\) has at least one local stable fixed point such that \({\bar{y}} \in [y_\mathrm{min}, y_\mathrm{max}]\).

In order to obtain a static compensator \(\bar{{\mathcal {M}}}_r\), an inverse problem in steady-state has to be solved. In other words, we seek the system input values \({\bar{m}}\) that will drive the output to the reference at steady-state, \({\bar{y}} \approx {\bar{r}}\). Starting with the model \({\mathcal {M}}\) in steady-state, \({\bar{y}} = {\bar{f}}^{\ell }({\bar{u}},{\bar{y}})\), \({\bar{y}}\) is replaced with \({\bar{r}}\) and \({\bar{u}}\) with \({\bar{m}}\) to yield \(\bar{{\mathcal {M}}}_r\): \({\bar{r}} = {\bar{f}}^{\ell }({\bar{m}},{\bar{r}})\). Consequently, it is possible to rewrite (2) by grouping its terms in such a way that it yields a polynomial in the unknown variable \({\bar{m}}\), \(\mathcal {{{\bar{M}}}}_\mathrm{r}\):

$$\begin{aligned}&c_{m,\,\ell _m}({{\bar{r}}}){{\bar{m}}}^{\ell _m} {+} c_{m,\,\ell _ m{-}1}({{\bar{r}}}){{\bar{m}}}^{\ell _m{-}1}{+} \ldots \nonumber \\&\quad \ldots {+}c_{m,\,1}({{\bar{r}}}){\bar{m}} {+} c_{m,\,0}({{\bar{r}}}) {=} 0. \end{aligned}$$
(9)

Although each of the \(\ell _m\) roots of (9) is a solution to the inverse problem, not all are appropriate to be used in practice. For this reason, two constraints are considered. The used root:

Constraint C1) must be real, \({m} \in {\mathbb {R}}\); and

Constraint C2) must be within the data range, namely \({m} \in [u_\mathrm{min},\, u_\mathrm{max}]\).

Assumption 2 ensures that any root \({\bar{m}}\) (9) that satisfies the above constrains will drive the system to a stable fixed point. Also, because of Assumption 1, such a steady-state will satisfy \({\bar{y}}_\mathrm{c} \approx {{\bar{r}}}\). The algebraic procedure is illustrated below with a simple example. Then, in the sequel, a dynamical version of this procedure will be discussed in Sect. 3.2.

Example 2

In Example 1, it was seen that:

$$\begin{aligned} {\bar{y}} = {\hat{\theta }}_1{\bar{y}} +{\hat{\theta }}_2 {\bar{u}}+{\hat{\theta }}_3{\bar{u}}^2 +{\hat{\theta }}_4{\bar{u}}^2+{\hat{\theta }}_5{\bar{u}}^3, \end{aligned}$$

which can be written in the format of (9) as:

$$\begin{aligned} \!\!\!\!\!\!{\bar{r}}&{=}&{\hat{\theta }}_1{\bar{r}} +{\hat{\theta }}_2 {\bar{m}}+{\hat{\theta }}_3{\bar{m}}^2 +{\hat{\theta }}_4{\bar{m}}^2+{\hat{\theta }}_5 {\bar{m}}^3, \nonumber \\ 0&{=}&\underbrace{{\hat{\theta }}_5}_{c_{m,3}}{\bar{m}}^3 +\underbrace{\big [{\hat{\theta }}_3+{\hat{\theta }}_4\big ]}_{c_{m,2}}{\bar{m}}^2 + \underbrace{{\hat{\theta }}_2}_{c_{m,1}}{\bar{m}} +\underbrace{\big [{\hat{\theta }}_1{\bar{r}}-{\bar{r}}\big ]}_{c_{m,0}({\bar{r}})}. \end{aligned}$$
(10)

Hence, for a given reference value \({\bar{r}}\), the roots of (10) provide potential compensation inputs that in steady-state will drive the system to the target. A practical problem is to decide which of the three roots in this example should be used. If there is only one real root, then it is chosen as the compensation input. However, if there are three real roots, a more general decision-making process is required. \(\square \)

For the sake of clarity, the roots of (9) will be placed in a vector \({\varvec{{\bar{m}}}}({\bar{r}}) \triangleq [{\bar{m}}_{1}~\cdots ~{\bar{m}}_{\ell _m}]^T\). Although the \(\ell _m\) values of \({\bar{m}}\) are solutions to the inverse problem, only those that satisfy C1 and C2 should be considered as potential compensation inputs. This reasoning underlies the main algorithm that will be used in the dynamical context. The practical issue of how  to choose from two potential inputs that satisfy C1 and C2 will be discussed in the dynamical setting below.

3.2 Dynamical compensation

The main difference between the framework developed in this subsection and the basis laid down in the previous one is that here the reference is a sequence of values r(k), and not a constant value \({\bar{r}}\). The same is true for the compensation input m(k) and the compensated output \(y_\mathrm{c}(k)\).

The aim now is to achieve \(y(k) \approx r(k)\) by solving an inverse problem dynamically. Replacing variables as in Sect. 3.1 and omitting the noise term, (1) can be written as:

$$\begin{aligned} r(k) {=} f^\ell \big (r(k{-}1), {\ldots }, r(k{-}n_y), m(k{-}\tau _\mathrm{d}), {\ldots }, m(k{-}n_u)\big ). \end{aligned}$$

As will become clear, it is convenient to introduce the time-shift \(k \leftarrow k+\tau _\mathrm{d}\) – meaning that k will be replaced with \(k+\tau _\mathrm{d}\) – hence the last equation becomes:

$$\begin{aligned} r(k{+}\tau _\mathrm{d})&{=}&f^\ell \big (r(k{+}\tau _\mathrm{d}{-}1),\ldots ,r(k{+} \tau _\mathrm{d}{-}n_y), \nonumber \\&~&\quad m(k),\ldots , m(k{+}\tau _\mathrm{d}{-}n_u)\big ). \end{aligned}$$
(11)

The aim is to find m(k) that will drive the system to the desired target r(k). Consequently, as before, (11) will be expressed in terms of a polynomial in the unknown m(k) as:

$$\begin{aligned} 0 {=} c_{{\ell _m}}(k)m(k)^{\ell _{m}} {+} c_{{\ell _m{-}1}}(k)m(k)^{\ell _m{-}1} +\ldots \nonumber \\ \ldots + c_{1}(k)m(k) + c_{0}(k), \end{aligned}$$
(12)

where the time-varying coefficients \(c_{j}(k)\), \(j = 0,\ldots ,\ell _m\), can depend on past values of m up to time \(k-1\), and on past and future values of r up to time \(k+\tau _\mathrm{d}\). Hence, the following additional assumption is required in the dynamical case.

Assumption 3

The reference signal must be known up to time \(k+\tau _\mathrm{d}\).

The following example illustrates this procedure.

Example 3

Consider the same model used in Example 1, replacing y(k) with r(k) and u(k) with m(k), yields:

$$\begin{aligned} r(k)&{=}&{\hat{\theta }}_1r(k-1)+{\hat{\theta }}_2m(k-1)+{\hat{\theta }}_ 3m(k-1)m(k-2) \\&{~}&+ {\hat{\theta }}_4m(k-1)^2+{\hat{\theta }}_5m(k-1)^3, \end{aligned}$$

for which \(\tau _\mathrm{d}=1\). Next, taking the time-shift \(k \leftarrow k+1\), the last equation can be expressed in the form of (12):

$$\begin{aligned} 0&{=}&{\hat{\theta }}_5m(k)^3{+}{\hat{\theta }}_4m(k)^2{+}\big [{\hat{\theta }}_ 2{+}{\hat{\theta }}_3m(k{-}1)\big ]m(k)\nonumber \\&{~}&{+}[{\hat{\theta }}_1r(k){-}r(k{+}1)], \nonumber \\ 0&{=}&c_{3}(k)m(k)^3{+}c_{2}(k)m(k)^2{+}c_{1}(k)m(k)+c_{0}(k), \end{aligned}$$
(13)

where all the values of r are known (see Assumption 3) and also all past values of m. Hence, at each time step k the solutions to (13), that is, the three values of m(k) are the potential compensation inputs. \(\square \)

Remarks on the initialization and the choice of the root to be used as the compensation input follow. The term calibration curve in Remark 1 – see below – refers to a set of M pairs of input-output values for \({\mathcal {S}}\) obtained in steady-state: \(\{({\bar{u}}_{p},\,{\bar{y}}_{\mathrm{s},p}) \}_{p=1}^M\). This can be achieved by exciting the system with a sequence of steps with final values \({\bar{u}}_{p}\) and, for each of them, waiting for steady-state before measuring \({\bar{y}}_{\mathrm{s},p}\).

Remark 1

(Initial compensator conditions). From Assumption 3, \(r(k+\tau _\mathrm{d})\) is known in (12). Call that value \({\bar{r}}\). Using the calibration curve of \({{\mathcal {S}}}\), find the respective \({\bar{m}}\) and take \(m(j)={\bar{m}},~j=k-1,\ldots ,k{+}\tau _\mathrm{d}{-}n_u\). If the calibration curve is not available, the static nonlinearity of model \({{\mathcal {M}}}\), which is the mathematical approximation of such a curve, can be use instead. Additionally, we can solve (9), \({\bar{r}}{=}{\bar{f}}^{\ell }({\bar{m}},{\bar{r}})\), for \({\bar{m}}\). If there is more than one solution use the one that: i) stabilizes the model output and ii) satisfies constraints C1 and C2. Items i) and ii) are automatically taken into account by using the calibration curve or static nonlinearity of \({{\mathcal {M}}}\). \(\square \)

Remark 2

(The decision-making process). Let \({\varvec{m}}_k \triangleq [m_{1}^k~\cdots ~m_{\ell _m}^k]^T\) be the set of roots of (12). If only one element of \({\varvec{m}}_k\) satisfies C1 and C2, then this will be the compensation input at time k, otherwise we choose the root according to:

$$\begin{aligned} m(k)=\underset{m_j^k,~\forall j\in \{1,\ldots ,\ell _m\}}{\arg \min }&\Big (|m_j^k-m(k-1)|\Big ) . \nonumber \\ \text {subject to:} ~C1,\,C2 \end{aligned}$$
(14)

The use of (14) selects the solution \(m_j^k\) that is closest to the compensation value used in the previous time step. This simple criterion results in smoother signals m(k) and, consequently, in less compensation effort [1]. \(\square \)

If \(\ell _m\) is even and composed only of complex conjugate values, then take \(m(k){=}m(k-1)\). This situation is not common for models that satisfy Assumption 1. Algorithm 1 summarizes the method to select the appropriate root.

figure a

3.3 Compensation for systems with hysteresis

The inclusion of the first difference of the input u(k) and the corresponding sign function as regressors is a sufficient condition for NARX models to mimic a hysteresis loop [29]. A general NARX model set [11] extended with these regressors will be referred to as \({{\mathcal {M}}}_\mathrm{h}\):

$$\begin{aligned} y(k)&{=}&g^{\ell }\big (y({k-1}),\cdots ,y(k-n_{y}), \,u(k-\tau _\mathrm{d}),\cdots , \nonumber \\&{~}& u(k-n_u), \phi _{1}(k-1), \,\phi _{2}(k-1) \big ) +e(k),\nonumber \\ \end{aligned}$$
(15)

where \(\phi _{1}(k){=}u(k){-}u(k{-}1)\), \(\phi _{2}(k) {=} \mathrm{sign}(\phi _{1}(k))\), \(g^{\ell }(\cdot )\) is a polynomial function of the regressor variables up to degree \(\ell \), and the other parameters are the same as defined in (1). For models such as (15), there are two sets of equilibria for the deterministic part (omitting the noise) under loading-unloading inputs: one for loading with \(\phi _{2}(k){=}1\), and one for unloading with \(\phi _{2}(k){=}{-}1\) [1]. A constrained approach is proposed and detailed in [1] to ensure that the model can describe dynamic behavior, and steady-state for varying inputs that become constant at some point.

Therefore, to deal specifically with hysteresis compensation, the general method proposed in Sect. 3.2 will be adapted. Considering non-constant inputs, the following simplification will be used:

$$\begin{aligned} \phi _1(k-1)\phi _2(k-1)= & {} \phi _1(k-1)\dfrac{|\phi _1(k-1)|}{\phi _1(k-1)}, \nonumber \\= & {} |u(k-1)-u(k-2)|, \end{aligned}$$
(16)

for \(u(k-1) \ne u(k-2)\).

The compensator is developed following the steps below:

  1. 1.

    Rewrite \({{\mathcal {M}}}_\mathrm{h}\) as:

    $$\begin{aligned} 0&{=}&g^{\ell }\big (y({k-1}),\cdots ,y(k-n_{y}), \,u(k-\tau _\mathrm{d}),\cdots , \nonumber \\&{~}&u(k\!-\!n_u),\phi _{1}(k\!-\!1), \,\phi _{2}(k\!-\!1) \big ) - y(k); \end{aligned}$$
    (17)
  2. 2.

    if \(\phi _1(k-1)\phi _2(k-1)\) appears in any regressor of (17), replace it using (16);

  3. 3.

    if \(\phi _1(k\!-\!1)\) and \(\phi _2(k\!-\!1)\) still appear, replace them with \(u(k\!-\!1)\!-\!u(k\!-\!2)\) and \(|u(k\!-\!1)\!-u(k-2)|/[u(k\!-\!1)\) \(-u(k-2)]\), respectively;

  4. 4.

    if \([u(k-1)-u(k-2)]\) appears in any denominator, multiply the equation by \([u(k-1)-u(k-2)]\);

  5. 5.

    replace y(k) with r(k), u(k) with m(k), perform the time shift \(k \leftarrow k + \tau _\mathrm{d}\), and rewrite this equation like (12);

  6. 6.

    split the equation with \(|\cdot |\) into two polynomials in the unknown m(k):

    $$\begin{aligned} 0&{=}&c_{\ell _m}^\mathrm{L}(k)m(k)^{\ell _m}+c_{\ell _m-1}^\mathrm{L}(k)m(k)^{\ell _m-1}\nonumber \\&{~}&+\ldots +c_{1}^\mathrm{L}(k)m(k)+ c_{0}^\mathrm{L}(k)\nonumber \\&{~}&\text {for} \quad m(k)>m(k-1), \end{aligned}$$
    (18)
    $$\begin{aligned} 0&{=}&c_{\ell _m}^\mathrm{U}(k)m(k)^{\ell _m}+c_{\ell _m-1}^\mathrm{U}(k)m(k)^{\ell _m-1}\nonumber \\&{~}&+\ldots +c_{1}^\mathrm{U}(k)m(k)+ c_{0}^\mathrm{U}(k) \nonumber \\&{~}&\text {for} \quad m(k)<m(k-1), \end{aligned}$$
    (19)

where the superscripts \(\mathrm L\) and \(\mathrm U\) refer to loading and unloading regimes, respectively. Because now the system is hysteretic, (12) has two counterparts: one for loading (18), and one for unloading (19). In this case, the compensation input m(k) will be a feasible root of (18) or (19). Before detailing the decision-making process, the previous steps are illustrated below.

Example 4

Suppose that the model \({{\mathcal {M}}}_\mathrm{h}\) is:

$$\begin{aligned} y(k)= & {} {\hat{\theta }}_1y(k\!-\!1)\!+\! {\hat{\theta }}_2u(k\!-\!1)^3 \nonumber \\&+\,{\hat{\theta }}_3\phi _1(k\!-\!1)\phi _2(k\!-\!1)u(k\!-\!1) \nonumber \\&+\,{\hat{\theta }}_4\phi _1(k-1)\phi _2(k-1)y(k-1). \end{aligned}$$
(20)

Following steps 1 and 2, (20) is rewritten as:

$$\begin{aligned} 0= & {} {\hat{\theta }}_1y(k\!-\!1)\!+\! {\hat{\theta }}_2u(k\!-\!1)^3 \nonumber \\ {}&+\,{\hat{\theta }}_3|u(k\!-\!1)-u(k\!-\!2)|u(k\!-\!1) \nonumber \\&+\,{\hat{\theta }}_4|u(k\!-\!1)-u(k\!-\!2)|y(k-1) - y(k). \end{aligned}$$
(21)

In this model, steps 3 and 4 do not apply. Following step 5, we get (remember that \(\tau _\mathrm{d}=1\)):

$$\begin{aligned} 0= & {} {\hat{\theta }}_1r(k)\!+\! {\hat{\theta }}_2m(k)^3 \!+\! {\hat{\theta }}_3|m(k)-m(k\!-\!1)|m(k) \nonumber \\&+{\hat{\theta }}_4|m(k)-m(k\!-\!1)|r(k) - r(k+1), \end{aligned}$$
(22)

which can be split into two polynomials (step 6) as:

$$\begin{aligned} 0= & {} {\hat{\theta }}_2m(k)^3 + {\hat{\theta }}_3m(k)^2+ \nonumber \\&[-{\hat{\theta }}_3m(k-1)+{\hat{\theta }}_4r(k)]m(k)+\nonumber \\&[{\hat{\theta }}_1r(k)-{\hat{\theta }}_4m(k-1)r(k)-r(k+1)] \nonumber \\&\text {for} \quad m(k)>m(k-1), \end{aligned}$$
(23)
$$\begin{aligned} 0= & {} {\hat{\theta }}_2m(k)^3 -{\hat{\theta }}_3m(k)^2+ \nonumber \\&[{\hat{\theta }}_3m(k-1)-{\hat{\theta }}_4r(k)]m(k)+\nonumber \\&[{\hat{\theta }}_1r(k)+{\hat{\theta }}_4m(k-1)r(k)-r(k+1)] \nonumber \\&\text {for} \quad m(k)<m(k-1). \end{aligned}$$
(24)

Here, (23) refers to loading regime similar to form (18) with \(c_{3}^\mathrm{L}(k)\! =\!{\hat{\theta }}_2\), \(c_{2}^\mathrm{L}(k)\!=\!{\hat{\theta }}_3\), \(c_{1}^\mathrm{L}(k)\!=\!-{\hat{\theta }}_3m(k-1)+{\hat{\theta }}_4r(k)\), and \(c_{0}^\mathrm{L}(k)\!=\!{\hat{\theta }}_1r(k)\!-\!{\hat{\theta }}_4m(k-1)r(k)\!-\!r(\!k\!+1\!)\); while, in an analogous way, (24) refers to unloading regime in form (19) with coefficients \(c_{3}^\mathrm{U}(k) ={\hat{\theta }}_2\), \(c_{2}^\mathrm{U}(k)=-{\hat{\theta }}_3\), \(c_{1}^\mathrm{U}(k)={\hat{\theta }}_3m(k-1)-{\hat{\theta }}_4r(k)\), and \(c_{0}^\mathrm{U}(k)={\hat{\theta }}_1r(k)+{\hat{\theta }}_4m(k-1)r(k)-r(k+1)\).

Polynomials (23) and (24), which are valid for \(k \ge 1\), can be initialized, at \(k=0\), using an estimate of the hysteresis loop, as illustrated in Example 5. \(\square \)

In addition to Assumption 3, C1 and C2, the following must also be true for hysteretic systems:

Constraint C3) \(m(k)>m(k-1)\), if (18) is used at time k; OR

Constraint C4) \(m(k)<m(k-1)\), if (19) is used at time k.

Constraints C3 and C4 are needed to ensure that the root is consistent with the regime for which it was calculated. Therefore, the decision-making process for hysteretic systems is similar to that explained in Remark 2 with the addition of these new constraints. Hence:

$$\begin{aligned} m(k)=\underset{m_{j}^k,~\forall j\in \{1,\ldots ,\ell _m\}}{\arg \min }&\Big (|m_{j}^k-m(k-1)|\Big ), \nonumber \\ \text {subject to:} ~C1,\,C2,\,Cq \end{aligned}$$
(25)

where \(q \in \{3,4\}\). The step-by-step procedure is analogous to Algorithm 1, but now using (25) instead of (14).

3.4 Initialization for systems with hysteresis

If any parameter of compensators (18) and (19) depends on previous values of the compensation input m(k), i.e., \(\{m(k{-}1),\,\ldots ,m(k{+}\tau _\mathrm{d}{-}n_u)\}\), such values must be determined for initialization. In Sect. 3.2, the static curve was used, as described in Remark 1. Here, a hysteresis loop \({{\mathcal {H}}}\), which is the counterpart of the static curve, will be used instead. In what follows, a procedure is described to obtain \({{\mathcal {H}}}\) for a given model \({{\mathcal {M}}}_\mathrm{h}\) (15).

Consider the following sinusoidal input signal with period \(T = 1/f_\mathrm{min}\):

$$\begin{aligned} {\tilde{u}}(k) = A \sin \left( 2\pi f_\mathrm{min}k\right) + {\tilde{u}}_0, \end{aligned}$$
(26)

where \(f_\mathrm{min}=1/T\) is the lowest frequency of interest, \({\tilde{u}}_0 {=} (u_\mathrm{min} {+} u_\mathrm{max})/2\) is the mean, and \(A = u_\mathrm{max} - {\tilde{u}}_0\) is the amplitude. Using \({\tilde{u}}(k)\) in model (15), after the transient, the resulting data set \(\{{\tilde{u}}(k), {\tilde{y}}(k)\}^{N_e}_{k=N_i}\), where \(N_i > T\) and \(N_e = N_i + T\), corresponds to a hysteresis loop \({\mathcal {H}}\). The use of \({\mathcal {H}}\) to initialize the compensator is illustrated in the next example.

Example 5

Consider model (20) of Example 4, whose parameter values are \({\hat{\theta }}_1=0.8\), \({\hat{\theta }}_2=0.4\), \({\hat{\theta }}_3=0.2\), and \({\hat{\theta }}_4 = 0.1\). In order to initialize the compensator, at \(k=0\), \(m(-1)\) is needed in (23) and (24). For this purpose, suppose that the excitation input signal \({\tilde{u}}\) (26) is defined with \(A = 1\), \(f_\mathrm{min} = 1 \text { } \mathrm{Hz}\), and \({\tilde{u}}_0 = 1\) for which the resulting \({\mathcal {H}}\) is shown in Fig. 2.

Fig. 2
figure 2

Loop \({\mathcal {H}}\) is obtained from the simulation of model (20) with the input described in Example 5. Blue dots refer to loading regime, while those in red refer to unloading. For a given output or reference, say r(1), there are two possible inputs indicated by triangles blue and red that correspond to \(m_\mathrm{L}(0)\) and \(m_\mathrm{U}(0)\), respectively. Which of these to use to start computing the compensator is determined by the regime at initialization time

From Assumption 3, we have that the reference is known up to time \(r(k{+}1)\). Suppose that \(r(1)=2\) and that \({\tilde{y}}=r(1)\), there are two possible values for the input \({\tilde{u}}\), namely of, \( m_\mathrm{L}(0)\) and \(m_\mathrm{U}(0)\), which can be obtained from \({\mathcal {H}}\) (Fig. 2). The selection between these values is made based on the current regime of the reference signal, i.e., loading \((r(1)-r(0)>0)\) or unloading \((r(1)-r(0)<0)\). In this example, at \(k=0\), the reference is in the loading regime and, therefore, \(m(0)=m_\mathrm{L}(0)\) is chosen to initialize (23) and (24). \(\square \)

4 Results

This section illustrates the compensator design proposed in Sect. 3 for two simulated benchmark systems and for a pilot plant starting from the identified models. The input design and other identification procedures are detailed in [43]. To evaluate the performance achieved with the proposed compensation two strategies were used. The first one is to compare the static nonlinearities of the compensated and uncompensated systems. The second is related to the time evolution where the mean absolute percentage error (MAPE)

$$\begin{aligned} \mathrm{{MAPE}} = \dfrac{\sum _{k=1}^{N}|y_s(k) - y(k)|}{N|{\max }({{\varvec{y}}_s})-{\min }({{\varvec{y}}_s})|} \times 100\% \end{aligned}$$
(27)

is computed for both systems.

4.1 A heating system

The bench test system is a small electrical heater modeled by the following Hammerstein model [4]:

$$\begin{aligned} y(k) =&\beta _1 y(k-1) {+} \beta _2 v(k-1) {+} \beta _3 y(k-2)\nonumber \\&\quad + \beta _4 v(k-2), \nonumber \\ v(k) =&p_1 u(k)^2+ p_2 u(k), \end{aligned}$$
(28)

where y(k) is the normalized temperature, and u(k) is the electric power applied to the heater within the range \( 0{ \le } u(k) {\le } 1\). The data set has been presented in [5].Footnote 1 The operation region of the model is \(u(k) \in [0,~1]\) and \(y(k) \in [0,~0.5]\). As described in [43], the obtained parameters of (28) are: \(p_1 {=} 4.639331 \times 10^{-1}\), \(p_2 {=} 5.435865 \times 10^{-2}\); \(\beta _1{=}1.205445\), \(\beta _2 {=} 8.985133 {\times } 10^{-2}\), \(\beta _3{=} {-}3.0877507 {\times } 10^{-1}\) and \(\beta _4 {=} 9.462358 \times 10^{-3}\). From now on, the Hammerstein model (28) will be treated as the system \({\mathcal {S}}\) to be compensated.

To compensate the nonlinearities in \({\mathcal {S}}\), the following three-term model \({\mathcal {M}}\) was obtained as detailed in [43]:

$$\begin{aligned} y(k) = {\hat{\theta }}_1y(k-1)+{\hat{\theta }}_2 u(k-2)^2 + {\hat{\theta }}_3y(k-2), \end{aligned}$$
(29)

where \({\hat{\theta }}_1 = 8.958185 \times 10^{-1}\), \( {\hat{\theta }}_2 = 6.393347 \times 10^{-2}\), and \({\hat{\theta }}_3 = -1.746750 \times 10^{-2}\). Validation results (see Table 1) indicate some degradation at higher frequencies and at points of operation close to the origin.

Table 1 \(\mathrm{MAPE}\) for model (29) with sinusoidal inputs \(u(k) = u_0 + 0.2 \mathrm{{sin}}(2\pi f k) \). Free-run simulation was used

The static function of \({\mathcal {M}}\) (29) is:

$$\begin{aligned} {\bar{y}} = \dfrac{{\hat{\theta }}_2 {\bar{u}}^2}{1-{\hat{\theta }}_1-{\hat{\theta }}_3}, \end{aligned}$$
(30)

from where it is seen that for each value of the input, there is only one fixed point. Because \({\mathcal {M}}\) is second-order, there are two eigenvalues at each fixed point \({\bar{y}}\). The Jacobian matrix in this case does not depend on \({\bar{u}}\) or \({\bar{y}}\). Using (3) the condition for stability is:

$$\begin{aligned} \begin{matrix} \left| \mathrm {eig} \left( \begin{bmatrix} 0 &{} 1 \\ \theta _3 &{} \theta _1 \end{bmatrix} \right) \right| < 1, \end{matrix} \end{aligned}$$

where the eigenvalues of the Jacobian matrix are the algebraic solutions of \(\lambda ^2-\theta _1\lambda -\theta _3 = 0\), which yields \(|\lambda _1| = 0.8759\) and \(|\lambda _2| = 0.0199\). Therefore, the fixed point for each input value is stable and, consequently, Assumption 2 is satisfied.

To illustrate the static compensation method presented in Sect. 3.1, \({\bar{y}}\) is replaced with \({\bar{r}}\) and \({\bar{u}}\) with \({\bar{m}}\) in (30) to find a polynomial in the unknown \({\bar{m}}\), that can be expressed like (9):

$$\begin{aligned} {\bar{r}}= & {} \dfrac{{\hat{\theta }}_2 {\bar{m}}^2}{1-{\hat{\theta }}_ 1-{\hat{\theta }}_3}, \nonumber \\ 0= & {} \underbrace{[{\hat{\theta }}_2]}_{c_{m,2}}{\bar{m}}^2+\underbrace{[({\hat{\theta }}_1+{\hat{\theta }}_3-1){\bar{r}}]}_{c_{m,0}({\bar{r}})}. \end{aligned}$$
(31)

Since (31) is an incomplete quadratic equation and the operation region is limited to \(0 \le {\bar{m}} \le 1\), the algebraic solution is given by:

$$\begin{aligned} {\bar{m}} = \sqrt{\dfrac{-c_{m,0}({\bar{r}})}{ c_{m,2}}} = \sqrt{\dfrac{(1-{\hat{\theta }}_1-{\hat{\theta }}_3){\bar{r}}}{{\hat{\theta }}_2}}. \end{aligned}$$
(32)

Also, as \({\bar{r}} \ge 0\), \({\hat{\theta }}_2 > 0\) and \(1-{\hat{\theta }}_1-{\hat{\theta }}_3> 0\), the result of the square root in (32) is always real. In Fig. 3, the static compensation results are shown for a reference that is a sequence of steps given by:

$$\begin{aligned} r(k) = \sum \limits _{i=n_a}^{n_b} \mu H(k-i\tau ), \end{aligned}$$
(33)

where \(n_a\), \(n_b\), \(\tau \) and \(\mu \) are user-defined parameters, and H(k) is the unit step function:

$$\begin{aligned} H(k) ={\left\{ \begin{array}{ll} 0 &{} \text{ for } k <0; \\ 1 &{} \text{ for } k \ge 0. \end{array}\right. } \end{aligned}$$
(34)

As expected, the compensated system is approximately linear (see Fig. 3b). The static compensation can be used to find the initial values for the dynamical compensator when needed.

Fig. 3
figure 3

Validation results for static compensation: is the reference generated using (33) with \(n_a=0\), \(n_b=11\), \(\tau = 600\), \(\mu =1/30\); , compensated system; , uncompensated system. In a temporal evolution of the outputs and the reference; b static curves in the \(r \times y\) plane

For dynamical compensation, using model \({\mathcal {M}}\) (29) yields (see Eq. 11):

$$\begin{aligned} r(k+1) = {\hat{\theta }}_1 r(k)+{\hat{\theta }}_2m(k)^2+{\hat{\theta }}_3r(k-1) \end{aligned}$$

and (see Eq. 12):

$$\begin{aligned} 0= & {} \underbrace{[{\hat{\theta }}_2]}_{c_{2}}m(k)^2+\underbrace{[{\hat{\theta }}_1r(k) +{\hat{\theta }}_3r(k-1)-r(k+1)]}_{c_{0}(k)}. \end{aligned}$$
(35)

Solving (35) at each iteration yields the compensation input m(k). Because (35) is quadratic, there are two possibilities. Either both roots are real, and then Algorithm 1 is used to select which one to use, or the roots are complex conjugate in which case the previous value is used, i.e., \(m(k)=m(k-1)\).

The solution of (35) gives the compensator \({\mathcal {M}}_\mathrm{r}\):

$$\begin{aligned} m(k) = \sqrt{\dfrac{-c_{0}(k)}{c_{2}}} = \sqrt{\dfrac{r(k+1)-{\hat{\theta }}_1r(k)-{\hat{\theta }}_3r(k-1)}{{\hat{\theta }}_2}}. \nonumber \\ \end{aligned}$$
(36)

Because m(k) does not depend on its previous values, in order to initialize (36), it is sufficient to make \(r(-1)=r(0)\) in (36) at \(k=0\).

In Fig. 4 and in Table 2, the results obtained with \({\mathcal {M}}_\mathrm{r}\) (36) is compared to the uncompensated system for different reference signals. The uncompensated results were obtained using r(k) as the input for \({\mathcal {S}}\). From Table 2, it is seen that as the frequency increases, the compensation becomes somewhat less effective, as would be expected for most control systems. Also for small values of r(k) (see Fig. 4b), complex roots appear, and according to Algorithm 1, the last computed value will be used, that is, \(m(k) = m(k-1)\).

Fig. 4
figure 4

Compensation results. a temporal evolution; b the applied inputs. In (a), is the reference \(r(k) = 0.15 \mathrm{{sin}}(2\pi (1/480) k+\pi /2) + 0.2\); is the output of the compensated system \(y_\mathrm{c}(k)\) and is the output of the system \(y_\mathrm{s}(k)\) without compensation. In (b), is the compensation input m(k), while is the input applied in the uncompensated system

Table 2 \(\mathrm{MAPE}\) for compensated and uncompensated systems with \(r(k) = r_0 \mathrm{{sin}}(2\pi f k+\pi /2) + r_0\)

Figure 5 shows the results for a Monte Carlo test of 10000 runs. The reference r(k) used in this test is a sequence of ascending steps similar to those of Fig. 3a. During each run, a perturbed model \({\mathcal {M}}\) (29) is obtained by taking parameters from a Gaussian distribution centered at the original parameters and with the covariance matrix of the estimator. The black dashed lines indicate the region determined by \(\mu ({\bar{r}}) \pm 2\sigma ({\bar{r}})\), where \(\mu ({\bar{r}})\) is the output mean and \(\sigma ({\bar{r}})\) is the standard deviation. The compensation performance is considerably effective on average for \({\bar{r}}{<}0.3\), and then it degrades a bit.

Fig. 5
figure 5

Static curves: dynamical compensation. Steady-state values of the reference r(k) generated using (33) with \(n_a=1\), \(n_b =10\), \(\tau =360\) and \(\mu = 0.04257\). Static curve of the uncompensated system, and of the compensated system obtained by averaging over 10000 Monte Carlos runs, \(\mu (\bar{r})\). \(\pm 2\sigma (\bar{r})\) error bars. The \(*\) are the values after the systems reach steady-state. See Fig. 3 for other details

4.2 A hysteretic system

In this example, the following Bouc-Wen model was used to describe the hysteretic behavior of a piezoelectric actuator (PZT) that is an unimorph cantilever [37]:

$$\begin{aligned} {\dot{h}}(t) =&\alpha _\mathrm{bw}{\dot{u}}(t)-\beta _\mathrm{bw}|{\dot{u}}(t)|h(t) -\gamma _\mathrm{bw} {\dot{u}}(t)|h(t)|, \nonumber \\ y(t) =&\nu _{y}u(t) - h(t), \end{aligned}$$
(37)

where u(t)[V] is the voltage input, y(t)[\(\mathrm {\mu }m\)] is the position output, the parameters \(\alpha _\mathrm{bw} = 0.9 [\mu \mathrm { m}/\mathrm {V}]\) and \(\beta _\mathrm{bw}=\gamma _\mathrm{bw} = 0.008[\mathrm {V}^{-1}]\) determine the hysteresis loop, while \(\nu _{y}=1.6 [\mu \mathrm { m}/\mathrm {V}]\) is a weight factor for the output. Here, (37) is referred to as the system \({\mathcal {S}}\) to be compensated, which is simulated with a fourth-order Runge–Kutta method with integration step \(\delta _t\!=\!5 \mathrm {ms}\).

The following NARX polynomial model \({{\mathcal {M}}}_\mathrm{h}\) (15) to represent \({\mathcal {S}}\) was obtained as detailed in [43]:

$$\begin{aligned} y(k)= & {} {\hat{\theta }}_1y(k{-}1){+}{\hat{\theta }}_2\phi _{2}(k{-}1)\phi _ {3}(k{-}1)u(k{-}1) \nonumber \\&+{\hat{\theta }}_3\phi _{2}(k{-}1)\phi _{3}(k{-}1)y(k{-}1){+}{\hat{\theta }}_4\phi _{2}(k{-}1),\nonumber \\ \end{aligned}$$
(38)

where \({\hat{\theta }}_1 = 1.000099\), \( {\hat{\theta }}_2 = 6.630567 \times 10^{-3}\), \({\hat{\theta }}_3 = -6.247018 \times 10^{-3}\), and \({\hat{\theta }}_4=7.892915\). Validation results (see Table 3) indicate some degradation at higher frequencies and amplitudes.

Table 3 \(\mathrm{MAPE}\) for model (38) with sinusoidal inputs \(u(k) = \mathrm{{Gsin}}(2\pi f k)\). Free-run simulation was used

Following steps 1, 2, 3 and 5 (see Sect. 3.3) the compensator obtained is \({{\mathcal {M}}}_\mathrm{h, r}\):

$$\begin{aligned} 0= & {} {\hat{\theta }}_1r(k){-}r(k{+}1){+}{\hat{\theta }}_2|m(k){-}m(k{-}1)|m(k) \nonumber \\&{+}{\hat{\theta }}_3|m(k){-}m(k{-}1)|r(k){+}{\hat{\theta }}_4|m(k){-}m(k{-}1)|,\nonumber \\ \end{aligned}$$
(39)

for which is assumed that \(m(k) {\ne } m(k-1)\). Splitting this into two polynomials, step 6 yields:

$$\begin{aligned} 0 \text { }{=}\text { } c_{2}^\mathrm{L}m(k)^2{+}c_{1}^\mathrm{L}(k)m(k){+} c_{0}^\mathrm{L}(k),~~ \text {for}~~ m(k){>}m(k{-}1);\nonumber \\ \end{aligned}$$
(40)

and

$$\begin{aligned} 0\text { }{=} \text { }c_{2}^\mathrm{U}m(k)^2{+}c_{1}^\mathrm{U}(k)m(k){+} c_{0}^\mathrm{U}(k),~~ \text {for} ~~ m(k){<}m(k{-}1),\nonumber \\ \end{aligned}$$
(41)

where \(c_{2}^\mathrm{L}={\hat{\theta }}_2\), \(c_{1}^\mathrm{L}(k)=-{\hat{\theta }}_2m(k-1)+{\hat{\theta }}_3r(k)+{\hat{\theta }}_4\), \(c_{0}^\mathrm{L}(k)={\hat{\theta }}_1r(k)-{\hat{\theta }}_3m(k-1)r(k)-{\hat{\theta }}_4m(k-1)-r(k+1)\), \(c_{2}^\mathrm{U}=-{\hat{\theta }}_2\), \(c_{1}^\mathrm{U}(k)={\hat{\theta }}_2m(k-1)-{\hat{\theta }}_3r(k)-{\hat{\theta }}_4\), and \(c_{0}^\mathrm{U}(k)={\hat{\theta }}_1r(k)+{\hat{\theta }}_3m(k-1)r(k)+{\hat{\theta }}_4m(k-1)-r(k+1).\)

As some parameters of (40) and (41) depend on \(m(k-1)\), the initialization of the compensator is required at \(k=0\). Applying \({\tilde{u}} = 50\mathrm{{sin}}(2\pi 0.2k)\) to model \({{\mathcal {M}}}_\mathrm{h}\) (38), the hysteresis loop \({{\mathcal {H}}}({\tilde{u}}, {\tilde{y}})\) is determined. Making \({\tilde{y}} = r(k + 1)\), \(m(k-1)\) can be provided directly from loop \({\mathcal {H}}\) as in Example 5.

Validation results (see Fig. 6 and Table 4) indicate that the compensated system presents better tracking performance than the uncompensated one in all evaluated scenarios. In addition, the worst results occur at higher frequencies and amplitudes.

Fig. 6
figure 6

Compensation results for system (37). a temporal evolution of outputs; b the \(r \times y\) plane and c temporal evolution of inputs. represents the reference \(r(k) = 30\mathrm{{sin}}(2\pi (2) k+\pi /2)\); , results for compensator given by (40) and (41) and , uncompensated system

Table 4 \(\mathrm{MAPE}\) for compensated and uncompensated systems with \(r(k) = G_0 \mathrm{{sin}}(2\pi f k+\pi /2)\)

Finally, Fig. 7 shows the results for 10000 Monte Carlo runs, where \(r(k) = 20 \mathrm{{sin}}(2\pi (2) k+\pi /2)\) is used in 5 cycles. A perturbed model \({{\mathcal {M}}}_\mathrm{h}\) (38) is obtained, as before. From Monte Carlo tests the region \(\mu (k) \pm 2\sigma (k)\) was computed similarly as described in Sect. 4.1, but now for each k. Comparing with Fig. 5, the error bars determine a wider region due to the sensitivity of \({\mathcal {M}}_\mathrm{h}\) on variations in \({\hat{\theta }}_2\).

Fig. 7
figure 7

Results for 10000 Monte Carlo runs. a temporal evolution of the outputs in the last cycle; b plane \(r(k) \times y(k)\). refers to the uncompensated system, refers to the reference and is the average \(\mu (k)\) of the 10000 Monte Carlo runs for the compensated system. represent the error bars of \(\pm 2\sigma (k)\)

It should be mentioned that the constraint \(\Sigma _y=1\) presented in [1] is not fulfilled, where \(\Sigma _y=1\) is the sum of all linear output regressors. In order to show how this constraint affects the behavior of the model and compensator, we use a constrained least squares estimator to impose \(\Sigma _y=1\) on the parameters of model (38). The model obtained with constraints, \({{\mathcal {M}}}_\mathrm{h, cns}\), has the same structure of \({\mathcal {M}}_\mathrm{h}\) (38) with parameters: \(\Sigma _y={\hat{\theta }}_{1, \mathrm cns}= 1\), \({\hat{\theta }}_{2, \mathrm cns} = 6.630913 \times 10^{-3}\), \({\hat{\theta }}_{3, \mathrm cns} = -6.157515 \times 10^{-3}\), and \({\hat{\rho }}_{4, \mathrm cns}=7.893146\).

The compensator of \({{\mathcal {M}}}_\mathrm{h}\) and \({{\mathcal {M}}}_\mathrm{h, cns}\) have a same polynomial structure. The compensator \({{\mathcal {M}}}_\mathrm{h, cns,r }\) is obtained when we replace each corresponding parameter of \({{\mathcal {M}}}_\mathrm{h, cns}\) in (40) and (41). The modeling and compensation results are similar to those in Tables 3 and  4, and are omitted.

A more relevant comparison for these two models and compensators is shown in Fig. 8 where a reference sinusoidal signal becomes constant. Note that the validation and compensation results for \({{\mathcal {M}}}_\mathrm{h}\) (38) do not converge at steady-state. As \({\bar{\phi }}_1={\bar{\phi }}_2=0\), both models become \({\bar{y}} = \Sigma _y{\bar{y}}\) that have a single eigenvalue equal to \(\Sigma _y\). Consequently, as \(\Sigma _y={\hat{\theta }}_1>1\), \({{\mathcal {M}}}_\mathrm{h}\) is unstable while the constraint \(\Sigma _y={\hat{\theta }}_{1,\mathrm cns}=1\), makes \({{\mathcal {M}}}_\mathrm{h, cns}\) to remain in the last state. The compensation methods work in open-loop, hence steady-state errors are expected, but they tend to be less significant for more accurate models. In the current example, whereas model \({{\mathcal {M}}}_\mathrm{h}\) diverges, the constrained model \({{\mathcal {M}}}_\mathrm{h, cns}\) provides a steady-state error of approximately \(0.26\mu \)m in Fig. 8b. Such errors are reflected in the compensation performance since \({{\mathcal {M}}}_\mathrm{h, cns, r}\) presents an offset error of \(0.83\mu \)m in Fig. 8d while the other, \({{\mathcal {M}}}_\mathrm{h, r}\), has a steady-state error which tends to infinity similarly to its model.

Fig. 8
figure 8

Validation and compensation results for models \(\mathcal{M}_\mathrm{h}\) and \(\mathcal{M}_\mathrm{h, cns}\) when a sinusoidal input or reference become constant. a \(u(k)=30\mathrm{sin}(2\pi (2)k)\) that becomes constant at \(k=920\). This input determines the outputs in b when applied to the system \(\mathcal S\) , to \(\mathcal{M}_\mathrm{h}\) and to \(\mathcal{M}_\mathrm{h, cns}\) . In c, m(k) for \(\mathcal{M}_\mathrm{h}\) and \(\mathcal{M}_\mathrm{h, cns}\) that were calculated for \(r(k)=u(30\mathrm{sin}(2\pi (2)k)\)). d The corresponding outputs for (c) where r(k) is

4.3 Experimental results

In this section, the compensation strategy is applied to an experimental pneumatic control valve, for which control performance can degrade significantly due to friction, dead-zone, dead-band, and hysteresis [16, 39].

The present valve is the same used in [1], where the measured output is its stem position and the input is a pressure signal applied to the valve after passing V/I and I/P conversion. The sampling time is \(T_\mathrm{s}=0.01\,\mathrm{s}\) and, for details of the identification of this system the reader is referred to [1, 43]. Four models will be considered in this study, as detailed below.

1- \({{\mathcal {M}}}_\mathrm{h}\) is the model identified with the inclusion of \(\phi _{1}(k)\) and \(\phi _{2}(k)\) as candidate regressors [29], and with the gray-box restrictions proposed by [1]. As shown in Fig. 8, such constraints are important to describe the steady-state behavior. The estimated model is:

$$\begin{aligned} y(k)= & {} {\hat{\theta }}_1y(k-1)+{\hat{\theta }}_2y(k-2) + {\hat{\theta }}_ 3\phi _1(k-1) \nonumber \\+ & {} {\hat{\theta }}_4u(k-1)\phi _{1}(k-1)\phi _{2}(k-1) \nonumber \\+ & {} {\hat{\theta }}_5y(k-2)\phi _{1}(k-1)\phi _2(k-1), \end{aligned}$$
(42)

with \({\hat{\theta }}_1{=}9.76\times 10^{-1}\), \({\hat{\theta }}_2{=}2.40 \times 10^{-2}\), \({\hat{\theta }}_3{=}1.19 \times 10^{-1}\), \({\hat{\theta }}_4=3.76\) and \({\hat{\theta }}_5=-4.73\). Note that, \(\Sigma _y = {\hat{\theta }}_1 + {\hat{\theta }}_2 = 1\).

The following models are found in the literature.

2- \({{\mathcal {M}}}_\mathrm{bw}\) is used to represent a BW model (37) with parameters re-estimated using an evolutionary approach based on niches [42]: \(\alpha _\mathrm{bw} = 7.54 \times 10^{-1}\), \(\beta _\mathrm{bw}=-4.96\), \(\gamma _\mathrm{bw}=- 3.61\) and \(\nu _{y}=7.54 \times 10^{-1}\).

The two last models adopted were identified in [1]:

3- \({{\mathcal {M}}}_\mathrm{h,2}\) was identified – see Eq. 33 in [1] – with the same constraints used for \({{\mathcal {M}}}_\mathrm{h}\) (42), plus an additional one such that the input signal can be isolated when writing the compensator equation.

4- \({\breve{\mathcal M}}_\mathrm{h}\) was identified to describe the inverse relationship between u(k) and y(k) of the valve – see Eq. 34 in [1]. Therefore, the model provides \({\hat{u}}(k)\) given y(k). The set of candidate regressors includes \(\breve{\phi }_{1}(k)=y(k)-y(k-1)\) and \(\breve{\phi }_{2}(k)=\mathrm{sign}[\breve{\phi }_{1}(k)]\).

The performance of the direct models (see Table 5) show similar values of the MAPE. Since \({\breve{\mathcal M}}_\mathrm{h}\) is an inverse model, which predicts the input signal instead of the output and must be simulated from a smoothed version of y(k) [1], we do not directly compare the MAPE accuracy of this model with the others. More details can be found in [43].

Table 5 \(\mathrm{MAPE}\) for models validation with sinusoidal inputs \(u(t) = G_0 \mathrm{{sin}}(2\pi (0.1) t+\pi /4)+3\mathrm{V}\)

The respective compensators are given below.

1- Compensator \({{\mathcal {M}}}_\mathrm{h,r}\), for \({{\mathcal {M}}}_\mathrm{h}\) (42), was obtained following steps 1, 2, 3, 5 and 6 and consists of two quadratic polynomials like (40) and (41) with parameters: \(c_{2}^\mathrm{L}={\hat{\theta }}_4\), \(c_{1}^\mathrm{L}(k)\!=\!{\hat{\theta }}_3-{\hat{\theta }}_4m(k-1)+{\hat{\theta }}_5r(k-1)\), \(c_{0}^\mathrm{L}(k)={\hat{\theta }}_1r(k)+{\hat{\theta }}_2r(k-1)+{\hat{\theta }}_3{m(k-1)}- {\hat{\theta }}_5r(k-1)m(k-1)-r(k+1)\), \(c_{2}^\mathrm{U}=-{\hat{\theta }}_4\), \(c_{1}^\mathrm{U}(k)=-{\hat{\theta }}_3+{\hat{\theta }}_4m(k-1)-{\hat{\theta }}_5r(k-1)\) and \(c_{0}^\mathrm{U}(k)={\hat{\theta }}_1r(k)+{\hat{\theta }}_2r(k-1)-{\hat{\theta }}_3m(k-1) +{\hat{\theta }}_5r(k-1)m(k-1)-r(k+1)\).

2- The compensation law m(t), for model \({{\mathcal {M}}}_\mathrm{bw}\) and referred to as \({{\mathcal {M}}}_\mathrm{bw, r}\), was proposed by [37]:

$$\begin{aligned} m(t)= \dfrac{10}{7.21}[r(t)+h(t)]. \end{aligned}$$
(43)

3- The compensator for \({{\mathcal {M}}}_\mathrm{h, 2}\) namely \({{\mathcal {M}}}_\mathrm{h, 2, r}\) is given by Eq. 35 in [1].

4- Finally, \({\breve{\mathcal M}}_\mathrm{h,r}\), the compensator for \({\breve{\mathcal M}}_\mathrm{h}\), is given by Eq. 36 of [1].

Compensation results (see Table 6 and Fig. 9) are considerably better in all evaluated scenarios when compared to the uncompensated system.

Table 6 \(\mathrm{MAPE}\) for compensated and uncompensated systems with \(r(t) = G_0 \mathrm{{sin}}(2\pi (0.1) t)+3.07\mathrm{V}\)
Fig. 9
figure 9

Compensation results for the pneumatic valve. a three cycles of the compensation inputs; b outputs for the compensated systems; cf show the \(r \times y\) plane for each compensator.  \(r(t) = 0.34\mathrm{{sin}}(2\pi (0.1)t+\pi /4)+3V\); , uncompensated system; compensation with \({\mathcal {M}}_\mathrm{h, r}\)(4041); compensation with \({\mathcal {M}}_\mathrm{bw, r}\) (43); compensation with \({\mathcal {M}}_\mathrm{h, 2, r}\) (35) in [1]; compensation with \(\breve{{\mathcal {M}}}_\mathrm{h,r}\) (36) in [1]

For the uncompensated system, the input is the reference r(k). Using this as a starting point, we would like to quantify how much more has to be done in order to achieve compensation. To this end, the following is computed:

$$\begin{aligned} E({\delta _m}) = \sum _{k=N-N_0}^{N-1} \delta _m(k)^2, \end{aligned}$$
(44)

where \(\delta _m(k)=|m(k)-r(k)|\) and N is the length of \(\delta _m(k)\). \(E({\delta _m})\) can be interpreted as the energy of \(\delta _m(k)\) over one period \(N_0\). Also, the variability with respect to the uncompensated system is given by the standard deviation of \(\delta _m(k)\), \(\sigma (\delta _m)\) (see Table 7).

Table 7 \(E({\delta _m})\)[\(\sigma ({\delta _m})\)] for the investigated compensators with \(r(t) = G_0 \mathrm{{sin}}(2\pi (0.1) t)+3.07\mathrm{V}\)

Similar to the validation results of model \({{\mathcal {M}}}_\mathrm{bw}\), the corresponding compensator \({{\mathcal {M}}}_\mathrm{bw,r}\) (43) performs slightly worse compared to those based on NARX models. This suggests that NARX models are more appropriate to describe nonlinearities in the valve. This is not surprising, as the class of NARX polynomials is more general than the Bouc-Wen class. On the positive side, the Bouc-Wen model provided the simplest compensator among those presented, although it is given in continuous-time which demands a numerical integration algorithm. In addition (see Table 7) the respective compensator provides small values of \(E(\delta _m)\) and \({\sigma }(\delta _m)\). The most challenging task related to the Bouc-Wen model is to estimate its parameters, which was done with an evolutionary approach.

Both compensation strategies proposed by [1] performed well. \({{\mathcal {M}}}_\mathrm{h, 2, r}\) requires special care in choosing the model structure otherwise the compensation input m(k) cannot be computed explicitly. Apart from that the compensation law tends to be easier to calculate than for the one put forward in this work. On the negative side, \({{\mathcal {M}}}_\mathrm{h, 2, r}\) produces inputs with more abrupt changes (see Fig. 9a and e). This is reflected in higher values of \(E(\delta _m)\) and \({\sigma }(\delta _m)\).

The overall good performance of compensator \({\breve{\mathcal M}}_\mathrm{h,r}\) comes at the expense of careful data preprocessing [1]. This compensator can produce smooth compensation inputs (Fig. 9a and f) with low MAPE values (Table 6). However, \(E(\delta _m)\) and \({\sigma }(\delta _m)\) tend to increase considerably with the reference amplitude (Table 7).

The compensator designed with the methodology put forward in this work, \({{\mathcal {M}}}_\mathrm{h, r}\), was also able to compensate for the nonlinearity in the valve. The MAPE is among the lowest, especially for moderate-high reference amplitudes \(G_0\), with the advantage that \(E(\delta _m)\) and \({\sigma }(\delta _m)\) do not increase as much as for the other regulators with \(G_0\) (Table 7). In addition, \({\mathcal {M}}_\mathrm{h}\) has only five terms which facilitates obtaining the compensation law. Also, if the parameters of such a model needed to be updated, a recursive algorithm could be readily implemented. On the other hand, if the process models turned out to be polynomials with degree greater than three, numerical solvers would be needed to find the roots. Fortunately, many systems can be adequately described using polynomials with \(\ell \ge 3\). As a side note, there is a self-consistency check indirectly provided by the current method, which is the appearance of unfeasible roots: either complex or real, but outside the operating range. Whenever this happens it is an indication that the process model is not adequate. Fortunately, no such problems occurred in the present case study.

5 Conclusion

This work has presented an approach to compensate nonlinearities based on NARX polynomial models previously estimated. The method is simple and easy to interpret, as the compensation input turns out to be the value required for the system to attain steady-state values. The compensation input is obtained iteratively, which confers some adaptability to the method. The degree of adaptability can be readily increased by estimating the model parameters recursively, this has not been explored in the paper.

The method has been considered in three contexts: static – for constant references, dynamical – for sinusoidal references, and for systems with hysteresis. At first, the technique was illustrated using two simulated systems. The performance is comparable to that of other methods available in the literature. In addition, the method presents some robustness to variation in the parameters, as evaluated using Monte Carlo tests.

The proposed technique was also implemented on a pilot plant, where the goal was to compensate the nonlinearity of a pneumatic control valve. The performance was compared with a compensator designed in [37] and two more recent strategies published by [1]. All compensators can achieve nonlinearity compensation for the valve (see Table 6). Pros and cons of each technique were discussed.

Another interesting feature of the presented technique is that a compensator can be designed for linear or nonlinear systems with or without using constraints during model estimation. Perhaps the main foreseen limitation occurs if the compensators are designed using polynomial models of degree greater than 3, which is not a common situation in practice, though it could happen. In this case, it would be necessary to use numerical solvers to find the roots, which could turn out to be a problem for more demanding online applications. Fortunately, many relevant systems can be described by models up to 3rd degree, for which the roots can be found with analytical expressions presented in Appendix 1.

Finally, the aim of the compensators is to cancel out most of the nonlinearity. This would allow for the design of linear feedback controllers as a second step. For future works, we intend to investigate the possible issues related to this closed-loop scheme and if the greater amount of unfeasible roots might be interpreted as a relevant indicator for time-varying behavior.