# Matlab Sliding mode observer in Matlab or Simulink

1. Aug 2, 2017

### Payam30

Hi,
I have designed a variable-based observer analytically on paper. Now it's time to implement it in Simulink/matlab.
Suppose we have followings in a tire model. The EOM says:
$$J\dot{\omega} = T-R_eF_x$$
$$m\dot{v}_x = F_x$$
where J is the inertia of the wheel, $\omega$ is the angular velocity , m is the mass and v is the translation velocity or horizontal speed, T is the torque input and Fx is the driving force. R is the effective radius of the velocity. The goal is to observe the effective radius, angular velocity and horizontal velocity using a sliding mode observer.
A theorem says:

'A system is generically observable if the whole state can be expressed as a function of y, of u and a finite number of their derivatives'

this tell us :
$$Rang_K [dy \: d\dot{y} ...\: dy^{n-1}]^T = n$$
further more:
$$\Gamma = [dy \: d\dot{y} ...\: dy^{n-1}]^T$$
and the system is observable if $\frac{\partial \Gamma}{\partial x} \neq 0$.
Let's do the canonical form of observability
we know:
$$\dot{x} = f(x) + \Delta f(x,t) + \chi (y,u)$$
$$y = h(x)$$
Then :
clearly the term $\chi$ is a output input dependend which is based on known parameters. then it should not affect the observability. We assume further that the term $\Delta f$ is a bounded uncertainty and does not affect the observability. Then we can remove these terms and get a simple system as :
$$\dot{x} = f(x)$$
$$y = h(x)$$
lets now say that the measurable outputs are $\omega, v_x$ and are $x = \omega \: v_x \: R_e$ and we have $\dot{x} = [\dot{\omega} \: \dot{v}_x \: \dot{R}e]$
Then:
$$\dot{x}= \begin{bmatrix} \frac{F_x}{J} x_3\\ F_x/m\\ 0 \end{bmatrix}+ \begin{bmatrix} 0\\ 0\\ \eta \end{bmatrix}+ \begin{bmatrix} \frac{1}{J}u\\ 0\\ 0 \end{bmatrix}$$
Recall from :
$$\Gamma = \begin{bmatrix} y_1\\ \dot{y_1} \\ y_2 \\ \dot{y_2} \end{bmatrix}$$
That gives:
$$\Gamma = \begin{bmatrix} x_1\\ T/J - F_x /J * x_3\\ x_2 \\ F_x/m \end{bmatrix}$$
We introduce $\zeta = [y \: \dot{y} .. y^{n-1}]^T = \Gamma(x)$ then $\hat{\dot{x}} =[ \frac{\partial \Gamma(x)}{\partial x}]^{-1} \hat{\dot{\zeta}}$
with introducing $\zeta$ we get following:
$$\dot{\zeta} = A\zeta + \begin{bmatrix} 0\\ 0\\ .\\ .\\ \theta(\zeta) \end{bmatrix}$$
where :
$A=\begin{bmatrix} 0 &1 &0 &... &0 \\ 0& 0 &1 & .. &0 \\ ..& .. & .. & .. &. \\ ..& .. & .. &.. &1 \\ .. & .. &.. & .. &0 \end{bmatrix} \: \: C=[1 \: 0 \: ...\: 0] , \: \theta = y^n$
An observer for such system is
$$\hat{ \dot{\zeta}} = A\hat{\zeta} + \begin{bmatrix} 0\\ 0\\ .\\ .\\ \theta(\zeta) \end{bmatrix}+ k(y,\hat{\zeta})$$ And that gives
$$\hat{\dot{x}} = f(\hat{x}, y) + \chi (y,u) + [\frac{\partial \Gamma}{\delta \hat{x}}]^{-1} k(y,\hat{x})$$

Using a High Order Sliding Mode Differentiation following can be designed:

$$\hat{\dot{x}} = f(\hat{x}, y) + \chi (y,u) + [\frac{\partial \Gamma}{\delta \hat{x}}]^{-1} \begin{bmatrix} \gamma_1\\ \gamma_2\\ .\\ .\\ \gamma_n \end{bmatrix}$$ where
$$\begin{bmatrix} \gamma_1\\ \gamma_2\\ .\\ .\\ \gamma_n \end{bmatrix} = \begin{bmatrix} a_1 L^{\frac{1}{n+1}}|y-\hat{x}_1|^{\frac{n}{n+1}}sign(y-\hat{x}_1)\\ a_2 L^{\frac{1}{n}}|\gamma _1|sign(\gamma_1)\\ .\\ .\\ a_n L sign(\gamma_{n-1}) \end{bmatrix}$$
The problem is now how to implement this in simulink since its not a statespace system. Can anybody tell me or give me a hint about how to do this in simulink.

2. Aug 7, 2017

### PF_Help_Bot

Thanks for the thread! This is an automated courtesy bump. Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post? The more details the better.