Sample-and-hold control

Consider the following sample-and-hold architecture:

Image

where the sampling time is not constant. A new sample is obtained when \left|m-z\right|\geqslant\delta, \delta>0. The memory m remains constant until a new sample is obtained.

In order to model the closed loop model as a hybrid system, we must define C,f,D,g

State Vector:

x=\left[\begin{array}{c}  z\\m\\u\end{array}\right]

f(x)=\left[\begin{array}{c}  Az\\ 0\\ 0\\\end{array}\right]

C=\left\{ \mathbb{R}^{n_{p}+n_{c}+n_{p}}\,:\left|m-z\right|<\delta\right\}

g(x)=\left[\begin{array}{c}  z\\-Kz\\-Kz\end{array}\right]

D=\left\{ \mathbb{R}^{n_{p}+n_{c}+n_{p}}\,:\left|m-z\right|\geqslant\delta\right\}

The simulation results are shown in the following images:

Image

Image

Image

Simulation code

%file name: run.m
clear all;
close all;
%%
% planta con S&H, se guarda una muestra de la planta en "m".
% No se tomara otra muestra hasta que la distancia entre la salida de la
% planta y m es mayor que DELTA

%planta:
A = -.5; %B=0;
%realimentación
K = 1; DELTA = 3;

%% Define initial conditions:
x0 = [10; 0; -10];

%% Simulation horizon
TSPAN = [0 10];
JSPAN = [0 15];
rule = 1;
options = odeset('RelTol', 1e-6, 'MaxStep', .1);

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

%%
plotHybridArc(t,j,x(:,3))
title('Input')
xlabel('j')
ylabel('t')
zlabel('entrada')

plotHybridArc(t,j,abs(x(:,2)-x(:,1)))
title('Delta')
xlabel('j')
ylabel('t')
zlabel('delta ')

plotHybridArc(t,j,x(:,1))
title('Output')
xlabel('j')
ylabel('t')
zlabel('z')

flow map

%file name: f.m
 function [ xdot ] = f( x )
 %F Summary of this function goes here
 % Detailed explanation goes here

A = -0.5; %B=0;
 K = 1; DELTA = 3;

z = x(1);
 zdot = A*z;

xdot = [zdot;0;0];
 end

jump map

function [ xPlus] = g(x)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

A = -.5; %B=0;
K = 1; DELTA = 3;

z = x(1);
zPlus = z;
mPlus = z;
uPlus = -K*z;

xPlus = [zPlus; mPlus; uPlus];
end

flow condition

function [ inC ] = C( x)
%INC Summary of this function goes here
% Detailed explanation goes here

A = -0.5; %B=0;
K = 1; DELTA = 3;
%%%

z = x(1);
m = x(2);
if abs(z-m)<DELTA
inC = true;
else
inC = false;
end

end

jump condition

function [ inD ] = D( x)
%INC Summary of this function goes here
% Detailed explanation goes here

A = -0.5; %B=0;
K = 1; DELTA = 3;
%%%

z = x(1);
m = x(2);
if abs(z-m)>=DELTA
inD = true;
else
inD = false;
end

end

Advertisements

One thought on “Sample-and-hold control

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s