Generic Finite Impulse Response filter block
Finite impulse response filter are defined with the discrete state equation :
In the Z transform domain, the transfert function of this equation is able to be rewritten by :
where
are the value of the coefficients of the impulse response, N is the number of coefficients and
are the delaying operator.
An example of a finite impulse response filter with 4 coefficients build with scicos basic blocks is shown in the super block equivalent model section.
- Type of RIF:
Type 'vec' of size 1. integer. ste the type of the impulse response
If set 1
- Number of coefficients:
Type vec of size -1. number of coefficients
- Vector of impulse response:
Type vec of size -1. impulse response
- Size of input vectors:
Type vec of size -1. size of the regular input
- Plot impulse response (0:No/Windows Id)?:
Type vec of size 1. plot impulse response in a graphic window
If set 2
- Size of the filter:
Type vec of size 1. filter order
- Sampling frequency:
Type vec of size 1. set the sampling period to compute the impulse response
- Type of wfir filter (lp,hp,bp,sb):
Type str of size 1. filter defintion
- Low - High frequency cutoff:
Type vec of size 2. 2-vector of cutoff
- Type of filtering window (re,tr,hn,hm,kr,ch):
Type str of size 1. filtering window
- Chebychev or Kaiser window parameters: :
Type vec of size 2. Chebychev or Kaiser windw parameters
- Plot impulse response (0:No/Windows Id)?:
Type vec of size 1. plot impulse response in a graphic window
If set 3
- Size of the filter:
Type vec of size -1. number of coefficients
- Size of input vectors:
Type vec of size -1. size of the regular input
- Frequency Sampling:
Type vec of size -1. set the sampling period to compute the impulse response
- Rool-Off Factor:
Type vec of size -1. filter parameter
- Output Gain:
Type vec of size -1. the output gain of the filter
- Plot impulse response (0:No/Windows Id)?:
Type vec of size 1. plot impulse response in a graphic window
If set 4
- Size of the filter:
Type vec of size -1. number of coefficients
- Size of input vectors:
Type vec of size -1. size of the regular input
- Frequency Sampling:
Type vec of size -1. set the sampling period to compute the impulse response
- Rool-Off Factor:
Type vec of size -1. filter parameter
- Output Gain:
Type vec of size -1. the output gain of the filter
- Plot impulse response (0:No/Windows Id)?:
Type vec of size 1. plot impulse response in a graphic window
If set 5
- Size of the filter:
Type vec of size -1. number of coefficients
- Size of input vectors:
Type vec of size -1. size of the regular input
- Frequency Sampling:
Type vec of size -1. set the sampling period to compute the impulse response
- BT Factor:
Type vec of size -1. filter parameter
- Output Gain:
Type vec of size -1. the output gain of the filter
- Plot impulse response (0:No/Windows Id)?:
Type vec of size 1. plot impulse response in a graphic window
- Accepted herited (0/1)?:
Type 'vec' of size 1. Enable the event herited property (disable the event input port).
- always active: no
- direct-feedthrough: no
- zero-crossing: no
- mode: no
- number/sizes of inputs: 1 / 1
- number/sizes of outputs: 1 / 1
- number/sizes of activation inputs: 1 / 1
- number/sizes of activation outputs: 0 /
- continuous-time state: no
- discrete-time state: yes
- name of computational function: nfilter
RIFGEN_f.sci
/* nfilter Scicos Temporal RIF block
* Type 4 simulation function ver 1.0 - scilab-2.6&2.7
* 13 octobre 2003 - IRCOM GROUP - Author : A.Layec
* 17 janvier 2005 : passage type 4
*/
/* REVISION HISTORY :
* $Log$
*/
#include "machine.h"
#include "scicos_block.h"
#include <stdio.h>
/* Cette fonction de simulation réalise le filtrage temporel
* par réponse impulsionnelle finie.
* Elle est capable de réaliser le produit de convolution
* d'un vecteur d'entrée par un vecteur des réponses impulsionnelles.
* Pour l'instant, le vecteur des réponses impulsionnelles est de taille fixe (nb_coef)
* pour chaque filtre mais chaque réponse impulsionnelle peut avoir une forme différente.
*
* L'opération réalisée est
* y[][k]=rpar[][k]*u[][k] où * représente ici le produit de convolution discret.
* a chaque rythme d'échantillonnage la valeur de u[][k] est stocké dans z[][k]
* et la valeur de y[][k] est calculée
*
* entrées régulières : vecteur des échantillons des signaux d'entrées u[0..Nu-1].
* sortie régulières : vecteur des échantillons des signaux filtrés y[0..Nu-1].
* entrée évènementielles : fréquence d'échantillonnage.
* sorties évènementielles : néant.
* paramètres réels :
* rpar[0..nbcoef-1,nbcoef..2*nbcoef-1,...,(Nu-1)*nbcoef-1..Nu*nbcoef-1] : vecteur des réponses impulsionnelles
* paramètres entiers :
* ipar[0] : nbcoef : nombre de coefficients de la réponse impulsionnelle
* insz[0] : Nu : nombre de signaux à filtrer
* Vecteur Z :
* z[0..nbcoef-1,nbcoef..2*nbcoef-1,...,(Nu-1)*nbcoef-1..Nu*nbcoef-1] =
* u[0][k-nbcoef-1],u[0][k-nbcoef-2],..,u[0][k],...,u[Nu-1][k-nbcoef-1],u[Nu-1][k-nbcoef-2],..,u[Nu-1][k]
*/
/*prototype*/
void nfilter(scicos_block *block,int flag)
{
/*déclaration des variables*/
double *y;
double *u;
int *sz,*nbcoef;
int i,nu;
int ptrui,ptrz;
/*récupération des adresses des ports*/
y=(double *)block->outptr[0];
u=(double *)block->inptr[0];
/*récupération des paramètres*/
nu=block->ipar[0];
nbcoef=&block->ipar[1];
sz=&block->ipar[1+nu];
/*Le flag 1 réalise le produit de convolution discret*/
if(flag==1||flag==6)
{
ptrui=0;
ptrz=0;
for (i=0;i<nu;i++)
{
/*fprintf(stderr,"nb_coef[%d]=%d,sz[%d]=%d \n",i,nbcoef[i],i,sz[i]);*/
/*Appel nfilter*/
nfilter_c(&sz[i],&nbcoef[i],&u[ptrui],&block->rpar[ptrz],&y[ptrui],&block->z[ptrz]);
if(nu>1)
{
ptrui=sz[i];
ptrz=nbcoef[i];
}
}
}
}
IRCOM Group
Alan Layec