SDBLK_c
//SDBLK_c Scicos discret Sigma Delta modulator
//Classical interface function ver1.0 - scilab-4.1
//22 mars 2006 - INRIA - Author : A.Layec
function [x,y,typ]=SDBLK_c(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
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;
exprs=graphics.exprs;
while %t do
[ok,Nu,gain,m_order,typ_out,e_q,herit,exprs]=getvalue(['Sigma Delta modulator'],..
['Size of inputs';'Amplitude of input modulator';...
'Order of modulator(1,2 or 3)';'Type of output(0:Regular/-1;1:Scaled)';...
'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),exprs);
if ~ok then break,end;
if ok then
if herit==1 then
model.dep_ut=[%t %f]
if e_q==1
[model,graphics,ok]=check_io(model,graphics,[Nu],[Nu;Nu],[],[])
model.evtin=[]
model.in=[Nu]
model.out=[Nu;Nu]
else
[model,graphics,ok]=check_io(model,graphics,[Nu],[Nu],[],[])
model.evtin=[]
model.in=[Nu]
model.out=[Nu]
end
else
model.dep_ut=[%t %f]
if e_q==1
[model,graphics,ok]=check_io(model,graphics,[Nu],[Nu;Nu],1,[])
model.evtin=1
model.in=[Nu]
model.out=[Nu;Nu]
else
[model,graphics,ok]=check_io(model,graphics,[Nu],[Nu],1,[])
model.evtin=1
model.in=[Nu]
model.out=[Nu]
end
end
if e_q==1 then
model.ipar(1)=1
else
model.ipar(1)=0
end
if (m_order==1)|(m_order==2)|(m_order==3) then
if(m_order==1) then
model.ipar(2)=m_order
model.dstate=[0;0]
elseif(m_order==2) then
model.ipar(2)=m_order
model.dstate=[0;0;0;0;0]
elseif(m_order==3) then
model.ipar(2)=m_order
model.dstate=[0;0;0;0;0;0;0;0;0]
end
else
model.ipar(2)=1
model.dstate=[0;0]
end
if(typ_out==0)|(typ_out==1)|(typ_out==-1) then
model.ipar(3)=typ_out
else
model.ipar(3)=0
end
if model.ipar(2)==1 then
graphics.gr_i(1)(7)='txt=[''1st order'']';
elseif model.ipar(2)==2 then
graphics.gr_i(1)(7)='txt=[''2nd order'']';
elseif model.ipar(2)==3 then
graphics.gr_i(1)(7)='txt=[''3rd order'']';
end
graphics.exprs=exprs
model.rpar=gain(:)
x.graphics=graphics;
x.model=model;
break;
end
end
case 'define' then
Nu=1
gain=1
m_order=1
typ_out=0
e_q=0
herit=0
model=scicos_model()
model.sim=list('sdblk',4)
model.in=Nu
model.out=Nu
model.evtin=1
model.evtout=[]
model.dstate=[0;0]
model.rpar=gain
model.ipar=[]
model.blocktype='d'
model.firing=[]
model.dep_ut=[%t %f]
gr_i=['thick=xget(''thickness'')';
'xset(''thickness'',2)';
'pat=xget(''pattern'')';
'fnt=xget(''font'')';
'xpoly(orig(1)+[0.45;0.1;0.3;0.1;0.45]*sz(1),orig(2)+[0.75;0.75;0.5;0.25;0.25]*sz(2),""lines"")';
'xpoly(orig(1)+[0.725;0.55;0.9;0.725]*sz(1),orig(2)+[0.75;0.25;0.25;0.75]*sz(2),""lines"")';
'txt=''1st order'';'
'style=5;'
'rectstr=stringbox(txt,orig(1),orig(2),0,style,1);'
'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
'xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');'
'e=gce();'
'e.font_style=style;'
'xset(''thickness'',thick)';
'xset(''pattern'',pat)';
'xset(''font'',fnt(1),fnt(2))']
exprs=[sci2exp(Nu),sci2exp(gain),...
sci2exp(m_order),sci2exp(typ_out),...
sci2exp(e_q),sci2exp(herit)];
x=standard_define([2.5 2],model,exprs,gr_i)
end
endfunction