Fonction d'interfaçage
fr
ADC_c
//ADC_c Analog to Digital Converter block
//Classical interface function ver1.0 - scilab-2.7
//3 Mars 2006 - INRIA - Author : A.Layec
function [x,y,typ]=ADC_c(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
x=arg1;
graphics=arg1.graphics;
if graphics.flip then
graphics.gr_i(1)(5)='xstringb(orig(1)+sz(1)*0.2,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
graphics.gr_i(1)(7)='xpoly(orig(1)+[0.95;0.95;0.3;0.05;0.3;0.95]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
else
graphics.gr_i(1)(5)='xstringb(orig(1)+sz(1)*0.1,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
graphics.gr_i(1)(7)='xpoly(orig(1)+[0.05;0.05;0.7;0.95;0.7;0.05]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
end
x.graphics=graphics;
standard_draw(x)
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;
exprs=graphics.exprs;
while %t do
text=['Set Analog to Digital Converter Block'];
[ok,q,vmin,of_er,fsr_er,typ,nbit,cc2,qn,herit,exprs]=getvalue(text,...
['Step';'Minimun input value';'Offset error';'Fsr error';'Type of Quantization';...
'Number of bits';'2''s complement (0:no, 1:yes)';...
'Enable Quantization error output (0:no, 1:yes)';'Inherit (no:0, yes:1)'],...
list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',1,'vec',1),exprs);
if ~ok then break,end;
if (size(vmin)==size(q)&size(q)==size(of_er)&size(q)==size(fsr_er)&...
size(q)==size(typ)&size(q)==size(nbit)&size(q)==size(cc2)) then
Nu = prod(size(q));
if (qn==0) then
if herit==1 then
model.evtin=[]
[model,graphics,ok]=check_io(model,graphics,Nu,Nu,[],[]);
else
model.evtin=1
[model,graphics,ok]=check_io(model,graphics,Nu,Nu,1,[]);
end
model.in=[Nu]
model.out=[Nu]
else
if herit==1 then
model.evtin=[]
[model,graphics,ok]=check_io(model,graphics,Nu,[Nu;Nu],[],[]);
else
model.evtin=1
[model,graphics,ok]=check_io(model,graphics,Nu,[Nu;Nu],1,[]);
end
model.in=[Nu]
model.out=[Nu;Nu]
end
if ok then
graphics.exprs=exprs;
rpar=[q;vmin;of_er;fsr_er];
model.rpar=rpar(:);
alpha=int([typ;nbit;cc2;qn]);
model.ipar=alpha(:);
x.graphics=graphics; x.model=model;
break;
end
else
message('All parameters (except the last) must have the same size');
end
end
case 'define' then
Nu=1;
nbit=8;
q=0.1;
vmin=0;
of_er=0;
fsr_er=0;
typ=1;
cc2=1;
qn=0;
herit=1;
model=scicos_model()
model.sim=list('adc',4)
model.in=Nu
model.out=Nu
model.evtin=[]
model.evtout=[]
model.dstate=[]
model.rpar=[q;vmin;of_er;fsr_er]
model.ipar=[typ;nbit;cc2;qn]
model.blocktype='d'
model.firing=[]
model.dep_ut=[%t %f]
gr_i=['txt=[''ADC''];';
'thick=xget(''thickness'')'
'pat=xget(''pattern'')'
'fnt=xget(''font'')'
'xstringb(orig(1)+sz(1)*0.2,orig(2)+sz(2)*0.15,txt,sz(1)*0.7,sz(2)*0.7,''fill'');'
'xset(''thickness'',2)'
'xpoly(orig(1)+[0.05;0.05;0.7;0.95;0.7;0.05]*sz(1),orig(2)+[0.9;0.1;0.1;0.5;0.9;0.9]*sz(2),""lines"")'
'xset(''thickness'',thick)'
'xset(''pattern'',pat)'
'xset(''font'',fnt(1),fnt(2))'
]
label=[sci2exp(q),sci2exp(vmin),sci2exp(of_er),sci2exp(fsr_er),...
sci2exp(typ),sci2exp(nbit),sci2exp(cc2),sci2exp(qn),string(herit)];
x=standard_define([2 2],model,label,gr_i)
end
endfunction