Fonction d'interfaçage
fr
MASHBLK_f
//MASHBLK_f Scicos discret MASH sigma delta modulator
//Classical interface function ver1.0 - scilab-3.0
//17 janvier 2005 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=MASHBLK_f(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(['MASH 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=[%f %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
graphics.exprs=exprs
model.rpar=gain(:)
//model.dstate=[zeros(Nu,1);zeros(Nu,1)]
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('mash',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=[%f %f]
gr_i=['txt=['' MASH'';'' Sigma/Delta ''];';
'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']
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