Fonction d'interfaçage
fr
VCO_f
//VCO_f Scicos VCO with Frequency divider Event block
//Classical interface function ver1.0 - scilab-2.7
//10 octobre 2003 Author : - IRCOM GROUP - A.Layec
//12 janvier 2004 : mise à jour type 4
// remplace tous les anciens blocks VCO
function [x,y,typ]=VCO_f(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
tt1='VCO'
tt2=[]
tt3=[]
if arg1.model.ipar(1)==1 then
if arg1.model.ipar(3)==0 then
tt2=['%N'];
else
tt1=' VCO'
if arg1.graphics.flip then
tt2=['%N %M'];
else
tt2=['%N %M'];
end
end
else
if arg1.model.ipar(3)==0 then
tt2=[];
else
if arg1.graphics.flip then
tt1=' VCO'
tt2=[' %M'];
else
tt1=' VCO'
tt2= ['%M '];
end
end
end
txt=[tt1;tt2];
standard_draw(arg1)
case 'getinputs' then
[x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
[x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
[x,y]=standard_origin(arg1)
case 'set' then
x=arg1;
graphics=arg1.graphics;model=arg1.model;
exprs1=graphics.exprs(1:8)
exprs2=graphics.exprs(9:11)
exprs3=graphics.exprs(12:13)
while %t do
[ok,pulsation,sensibilite,pas,transition,dyn_input,fnl,typ_noise,sratio,exprs1]=...
getvalue('Scicos VCO with Frequency divider Event block',...
['Pulsation [rad/s]';'Sensitivity [rad/V]';'Integration step [s]';...
'Angular position of crossing [rad]';'Dynamical Value (0:No/1:Yes)';...
'Use input nonlinearity (0:No/1:Yes)';'Type of Noise (0:Nothing/1:uniform)';...
'Use second integer frequency divider (0:No/Integer Value)'],...
list('vec',-1,'vec',-1,'vec',1,'vec',1,'vec',1,'vec',1,'vec',1,'vec',1),exprs1);
if ~ok then break,end;
if (size(pulsation)==size(sensibilite)) then
Nu = prod(size(pulsation));
if dyn_input==1 then
if sratio<>0 then
[model,graphics,ok]=check_io(model,graphics,[Nu;Nu],Nu,1,[1;1])
else
[model,graphics,ok]=check_io(model,graphics,[Nu;Nu],Nu,1,1)
end
model.in=[1;1]
else
if sratio<>0 then
[model,graphics,ok]=check_io(model,graphics,[Nu],Nu,1,[1;1])
else
[model,graphics,ok]=check_io(model,graphics,Nu,Nu,1,1)
end
model.in=1
end
if ok then
///
if fnl==1 then
while %t do
ok2=%f;
[ok2,gain,coef,plot_tanh,exprs2]=getvalue('Set Hyperbolic Tangent function',...
['Gain';'Coefficient';'Plot non linearity (0=No) ?'],...
list('vec',1,'vec',1,'vec',1),exprs2);
if ~ok2 then
exprs2=graphics.exprs(9:11); //pourquoi cela?
break
end;
if ok2 then
//rpar=[rpar(:);gain;coef];
if plot_tanh<>0 then
win=xget("window")
xset("window",int(plot_tanh))
xset("wdim",300,200)
xbasc()
i=1:12
Fo=pulsation/(2*%pi)
plot2d(i,Fo+gain/(2*%pi)*tanh(coef*(i)),2);
xgrid(0);
xset("window",win);
end
break;
end
end
else
gain=evstr(exprs2(1))
coef=evstr(exprs2(2))
end
///
///
if typ_noise==1 then
while %t do
ok3=%f;
[ok3,m,sig,exprs3]=getvalue('Set Noise on input command',...
['Mean [rad/v]';'Variance [rad/v]'],...
list('vec',1,'vec',1),exprs3);
if ~ok3 then
exprs3=graphics.exprs(12:13); //pourquoi cela?
break
end;
if ok3 then
break
end
end
else
m=evstr(exprs3(1))
sig=evstr(exprs3(2))
end
///
if sratio<>0 then
model.firing=[0;0]
else
model.firing=[0]
end
ci=[0;0;0;0;0;transition;0]
rpar=[pas;pulsation;sensibilite;transition;gain;coef;m;sig]
ipar=[dyn_input;fnl;sratio;typ_noise]
exprs=[exprs1(:)',exprs2(:)',exprs3(:)']
graphics.exprs=exprs
model.dstate=ci(:)
model.rpar=rpar(:)
model.ipar=ipar(:)
x.graphics=graphics; x.model=model;
break;
end
else
message('Vector Pulsation and Vector Sensibilité must have the same size');
end
end
case 'define' then
Nu=1;
pulsation=2*%pi
sensibilite=2*%pi*1e3
pas=0.1
transition=2*%pi
ci=[0;0;0;0;0;2*%pi;0]
dyn_input=0 //choix rapport de division dynamique
fnl=0 //choix non linéarité
typ_noise=0 //choix du bruit
sratio=0 //deuxième diviseur de fréquence à rapport entier
gain=1
coef=1
plot_tanh=0
m=0
sig=0
ipar=[dyn_input;fnl;sratio;typ_noise]
rpar=[pas;pulsation;sensibilite;transition;gain;coef;m;sig]
model=scicos_model()
model.sim=list('vco',4)
model.in=[Nu]
model.out=Nu
model.evtin=1
model.evtout=1
model.dstate=ci(:)
model.rpar=rpar(:)
model.ipar=ipar(:)
model.blocktype='d'
model.firing=[0]
model.dep_ut=[%f %f]
gr_i=['xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
exprs1=['2*%pi','2*%pi*1e3',sci2exp(pas),'2*%pi',string(dyn_input),string(fnl),string(typ_noise),string(sratio)];
exprs2=[sci2exp(gain),sci2exp(coef),string(plot_tanh)]
exprs3=[string(m),string(sig)]
exprs=[exprs1,exprs2,exprs3]
x=standard_define([2.5 2],model,exprs,gr_i)
end
endfunction