# Hybrid model for a switching system

Consider a system with a dc motor and the load, coupled by flexible shaft as shown in the next diagram

where:
$\varphi \; \dot{\varphi}$ : Position and speed of the load respectively.

$\theta \; \dot{\theta}$ : Position and speed of the motor shaft respectively.

$B_{L}\;B_{m}$: Dynamic friction coefficient of the load and the motor respectively.

$J_{L}\;J_{m}$: Inertia moment of the load and the motor respectively.

$K_{s}$: Elastic torsion coefficient of the spring.

The states of system are the position and speed of the motor and the load respectively, $z=[\varphi \; \dot{\varphi} \; \theta \; \dot{\theta}]$ and the input is the voltage applied. With this and using Newtons Law and the electrical equations for the motor, the system in state space is:

$\left\{ \begin{array}{ccc} \dot{z} & = & Az+Bv\\ \varphi & = & Cz \end{array} \right.$

$\mbox{A}= \left( \begin{array}{cccc} 0 & 1 & 0 & 0\\ -\frac{K_{s}}{J_{L}} & -\frac{B_{L}}{J_{L}} & \frac{K_{s}}{J_{L}} & 0\\ 0 & 0 & 0 & 1\\ \frac{K_{s}}{J_{M}} & 0 &-\frac{K_{s}}{J_{M}} & -\frac{K^{2}+R_{A}\;B_{M}}{J_{M}\;R_{A}} \end{array} \right) \mbox{B}=\left( \begin{array}{c} 0\\ 0\\ 0\\ \frac{K}{J_{M}\;R_{A}}\\ \end{array} \right) \mbox{C}=\left( \begin{array}{lcccr} 1 & 0 & 0 & 0\\ \end{array} \right)$

To control the position in a point of reference a sliding mode control with next structure is developed

Because of the implemented control the signal input to plant is not continuous, and it can be modelled as a switching signal with hysteresis, that jumps between two differences values depending of signal $e$.
The close loop system can be modelled as a hybrid system, if an extra variable $\tau$ which count the time between jumps is considered and is reseted when jump occurs. the variable that jumps is called $q$.

$x = \left[ \begin{array}{c} z\\ \tau\\ q \end{array} \right]$

$\dot{x} = \left[ \begin{array}{c} f_{q}\\ \dot{\tau}\\ \dot{q} \end{array} \right] = \left[ \begin{array}{c} Ax+B(q\,\mbox{v})\\ 1\\ 0 \end{array} \right] \qquad C=\{ z \in\mathbb{R}^{4} \; , \tau \in \mathbb{R}: \tau \ge 0 \; , q \in \mathbb{Q} \}$

$x^{+} = \left[ \begin{array}{c} z^{+}\\ \tau^{+}\\ q^{+} \end{array} \right] = \left[ \begin{array}{c} z\\ 0\\ -q \end{array} \right]$

$D = \{(q,u) \in \{-1;1\} \times \mathbb{R}: q=-1 , u \ge \overline{h} \} \; \bigcup \; \{ (q,u) \in \{-1;1\} \times \mathbb{R}: q=1 , u \leq \underline{h} \}$

Where $\overline{h} ,\; \underline{h}$ are the levels of hystereses and $v$ is the positive bounded of the switching signal.

% run.m to simulate timer with reset

clear all

global u
global r

%Reference Position [rad]
r=5;

%Initial Value for input for de switching signal
u=0;

%Define inicial conditions of the states

x0=[0;0;0;0;0;1];

%simulation horizon
TSPAN = [0 4];
JSPAN = [0 15];

%ruls for jump
%rule  = 1 -> priority for jumps
%rule  = 2 -> priority for flows
%rule  = 3 -> ramdom priority

rule=1;

options = odeset('RelTol',1e-6,'MaxStep',.1);

%run simulation
[t j x] = HyEQsolver(@f,@g,@C,@D,x0,TSPAN,JSPAN,rule,options);

figure(1)
clf
subplot(2,1,1),plotflows(t,j,x(:,1))
grid on

ylabel('x1')
subplot(2,1,2),plotjumps(t,j,x(:,1))
grid on
ylabel('x1')

% plot hybrid arc
plotHybridArc(t,j,x)
xlabel('j')
ylabel('t')
zlabel('x')

function inD = D(x)
% Jump set
% Check if in D

global u

% Hysterisis level
hbar=1;

q=x(6);

if ((q == -1) && (u >= hbar))
inD = 1;
elseif ((q==1) && (u <= -hbar))
inD = 1;
else
inD=0;
end


function inC = C(x)
%flow set
%checck if in C

inC=1;

end


function xdot = f(x)
%flow map

global u
global r

z1=x(1);
z2=x(2);
z3=x(3);
z4=x(4);

tau=x(5);
q=x(6);

z=[z1;z2;z3;z4];

% Linear System
A=[0 1 0 0 ; -90.8 -0.7 90.8 0 ; 0 0 0 1 ; 55,41 0 -55.41 - 105.6];
B=[0 ; 0 ; 0 ; 220.7];

K=[2.2895 0.2714 0.8352 0.0045];

u = r-(K*z);

%Flow
xdot = [(A*z)+(B*(q*24)) ; 1 ; 0];

end

Advertisements