function y=Chen_vsm1(x)
% y=Chen_vsm1(x)
% x - [stop0,cum0,vk0, uk0,uk];Input to the stiction model
% y - [stop,cum,vk]; the output of the model, the valve output
% stop - indicate the condition of valve
% uk - the valve input ( the control output)
% cum- the cumulative stiction of valve
% vk- the output of the stiction model
% cum0,vk0,uk0 - the previous condition of cum,vk,uk
%% *******Specify the following parameters of the model**********************
FS=0.05; % the static friction of the valve
FD=0.02; % the dynamic friction of the valve
%% ******* The algorithm of the model*************
stop0=x(1); cum0=x(2); vk0=x(3); uk0=x(4); uk=x(5);dk0=x(6);
%if uk<0
% uk=0;
%end
%if uk>100
% uk=100;
%end
cum=cum0+uk-uk0;
%if cum==uk
% cum=1;
%end
dk=sign(cum);
if stop0==1;
if abs(cum)>FS
cum=dk*FD;
vk=uk-cum;
stop=0;
else
vk=vk0;
stop=stop0;
end
else
if (FD>0 && abs(cum)>FD)||(FD==0 && dk*dk0>0)||(FD==0 && abs(cum)>FS)|| (FD<0 && abs(cum)< -FD)
cum=dk*abs(FD);
vk=uk-cum;
stop=stop0;
else
vk=vk0;
stop=1;
end
end
y=[stop cum vk dk];