casfil

Capsim Block Documentation

Short Description

Star implements cascade form IIR digital filter.

Top
Input Connections
Port Type Name
0 float x
Top
Output Connections
Port Type Name
0 float y
Top
Parameters
Num Description Type Name Default Value
0 File with cascade filter parameters file filename tmp.cas
Top
States
Num Type Name Initial Value Description
0 float ycas_A[20]
1 float xs_A[3]
2 float ys_A[3]
3 float poleSec1_A[35]
4 float poleSec2_A[35]
5 float zeroSec_A[35]
6 float zeroSec2_A[35]
7 float fs
8 float wnorm
9 int ns
10 int n
Top

Declarations


 

   	int i,j,jj,jt;
        FILE *ird_F;



Top

Initialization Code



 

	/*
	 * open file containing filter coefficients. Check 
	 * to see if it exists.
	 *
	 */
        if( (ird_F = fopen(filename,"r")) == NULL) {
		fprintf(stderr,"Casfil: File could not be opened  \n");
		return(4);
	}
	/*
	 * Read in the filter coefficients and filter parameters.
	 *
	 */
         fscanf(ird_F,"%d",&ns);
      	 for (i=0; i
    
Top

Main Code



 


        while (IT_IN(0))
        {
               for (j=0; j< ns; j++){
                    if (j==0){
                              xs_A[1]=0.0;
                              xs_A[2]=0.0;
                              xs_A[0]=x(0);
                              if (n>0) xs_A[1]=x(1);
                              if (n>1) xs_A[2]=x(2);
                    }
                    if (j>0) { 
                             for (jj=0; jj<3; jj++)
                                           xs_A[jj] = ys_A[jj];
                    }

                    jt = j*3;
                    for (jj=0; jj<2; jj++)  
                        ys_A[jj+1] = ycas_A[jt+jj];

                    ys_A[0]=xs_A[0]+(zeroSec_A[j]*xs_A[1])+(zeroSec2_A[j]*xs_A[2])-(poleSec1_A[j]*ys_A[1])-(poleSec2_A[j]*ys_A[2]);

                    for (jj=0; jj<2; jj++)   
                          ycas_A[jt+jj] = ys_A[jj];
               }

               if(IT_OUT(0)) {
			               KrnOverflow("casfil",0);
			               return(99);
	           }
               y(0) = ys_A[0]/wnorm;
               n = n+1;
        }

        return(0);




Top

Wrapup Code



 





Top

License



/*  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
*/


Top

Description



 

/* casfil.s */
/***********************************************************************
                             casfil()
************************************************************************
Star implements cascade form IIR digital filter.
Parameter: (file) File with the filter coefficients and parameters
The inputs from the file are as follows;
           ns: Number of sections
           zeroSec_A[i] zeroSec2_A[i] i=1 to ns the numerator coefficients
           poleSec1_A[i] poleSec2_A[i] i=1 to ns the denominator coefficients
           in the Z-domain.
Date:  October 15, 1988 
Programmer: Tulay Adali
Modified: Sasan Ardalan

casfil


Star implements cascade form IIR digital filter.
Parameter: (file) File with the filter coefficients and parameters
The inputs from the file are as follows;
           ns: Number of sections
           zeroSec_A[i] zeroSec2_A[i] i=1 to ns the numerator coefficients
           poleSec1_A[i] poleSec2_A[i] i=1 to ns the denominator coefficients
           in the Z-domain.


Date:  October 15, 1988 
Programmer: Tulay Adali
Modified: Sasan Ardalan

*/