emeter_filters.c

来自「基于MSPF449的三相电压表功率的开发程序」· C语言 代码 · 共 40 行

C
40
字号
//**************************************************************************
//    The FIR filter is used here for phase lag/lead compensation.
//    The phase lag/lead compensation FIR do not have unity gain factor so an
//    extra gain compensation stage is added.
//    The FIR is implement in fractional binary arithmatic. Sign the gain correction 
//      can be >1. This needs to be taken into account 
//
//    Vincent Chan 
//    Texas Instruments Hong Kong Ltd
//    Date        Comments
//    =====================
//    01/09/19    Code Starts
//    01/10/07    First cut test done
//**************************************************************************
#include "emeter_3phase.h"
//--------------------------------------------------------------------------


//  This routine provides a one TAP FIR which gives a fractional delay. The gain is compensated

int FIR(int int_params[],int input)
{
int i,j;
              //y[n+1]*gain = x[n+1]+beta*x[n+1];
if(int_params[FIR_GAIN]<0)        
  {                             //In this case gain >1
  i=FRACTIONAL_SIGNED_MUL(int_params[FIR_TAP],int_params[FIR_BETA])+input;
  j=int_params[FIR_GAIN]-32768;
  j=FRACTIONAL_SIGNED_MUL(j,i)+i;
  i=j;
  }
else
  {  
  i=FRACTIONAL_SIGNED_MUL(int_params[FIR_TAP],int_params[FIR_BETA])+input;
  i=FRACTIONAL_SIGNED_MUL(int_params[FIR_GAIN],i);
  }

int_params[FIR_TAP]=input;
return(i);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?