Capsim Block Documentation
This star designs and implements a cascade form IIR digital filter.
Port | Type | Name | |
---|---|---|---|
0 | float | x |
Port | Type | Name | |
---|---|---|---|
0 | float | y |
int i,j,jj,jt; int status; int no_samples; char fname[100]; FILE *fopen(); FILE *ird_F; |
---|
switch(filterType) { case LOW_PASS: if(fpb >= fsb) { fprintf(stderr,"iirfil:Low pass stop band frequency lower \ \n than or equal to pass band. \n"); return(4); } break; case HIGH_PASS: if(fpb <= fsb) { fprintf(stderr,"iirfil:High pass stop band frequency \ \n heigher than or equal to pass band. \n"); return(4); } break; case BAND_PASS: if((fpl >= fpu) || (fpl <=fsl) || (fpu >= fsu) || (fsl >=fsu)){ fprintf(stderr,"iirfil: Band pass filter spec error. \n"); return(4); } break; case BAND_STOP: if((fpl >= fpu) || (fpl >=fsl) || (fpu <= fsu) || (fsl >=fsu)) { fprintf(stderr,"iirfil: Band pass filter spec error. \n"); return(4); } break; } /* * Design the IIR filter. * Put poles and Zeroes in file tmp.pz . */ status =IIRDesign(filterName,fs,fpb,fsb,fpl,fpu,fsl,fsu, pbdb,sbdb,filterType,desType); if (status) { fprintf(stderr,"Design Error in IIRDesign. \n"); return(4); } /* * Generate cascade coefficients from file tmp.pz * Store in filterName.cas */ status=IIRCas(filterName); if (status) { fprintf(stderr,"Design Error in iircas cascade calc. \n"); return(4); } /* * produce compact version of filterName.pz file * store it in filterName.pz, i.e. overwrite filterName.pz */ PzConv(filterName); /* * open file containing filter coefficients. Check * to see if it exists. * */ strcpy(fname,filterName); strcat(fname,".cas"); if( (ird_F = fopen(fname,"r")) == NULL) { fprintf(stderr,"iirfil: File tmp.cas could not be opened \n"); return(4); } /* * Read in the filter coefficients and filter parameters. * */ fscanf(ird_F,"%d",&ns); for (i=0; i |
---|
for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) { IT_IN(0); for (j=0; j< ns; j++){ if (j==0){ xs[1]=0.0; xs[2]=0.0; xs[0]=x(0); if (n>0) xs[1]=x(1); if (n>1) xs[2]=x(2); } if (j>0) { for (jj=0; jj<3; jj++) xs[jj] = ys[jj]; } jt = j*3; for (jj=0; jj<2; jj++) ys[jj+1] = ycas[jt+jj]; ys[0]=xs[0]+(zc1[j]*xs[1])+(zc2[j]*xs[2])-(pc1[j]*ys[1])-(pc2[j]*ys[2]); for (jj=0; jj<2; jj++) ycas[jt+jj] = ys[jj]; } if(IT_OUT(0)) { KrnOverflow("iirfil",0); return(99); } y(0) = ys[0]/wnorm; n = n+1; } return(0); |
---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks) Copyright (C) 1989-2017 Silicon DSP Corporation This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.silicondsp.com Silicon DSP Corporation Las Vegas, Nevada */ |
---|
/* iirfil.s */ /*********************************************************************** iirfil() ************************************************************************ This star designs and implements a cascade form IIR digital filter. The specs and results of the design are stored in the file tmp.dat. The cascade filter coefficients are store in a file tmp.cas as: ns: Number of sections zc1[i] zc2[i] i=1 to ns the numerator coefficients pc1[i] pc2[i] i=1 to ns the denominator coefficients in the Z-domain. |
---|