1874 views|0 replies

2015

Posts

0

Resources
The OP
 

DSP IIR digital filter implementation program source code [Copy link]

DSP IIR digital filter implementation program source code Appendix (C program source code): #include "DSP2833x_Device.h" // DSP2833x Headerfile Include File #include "DSP2833x_Examples.h" // DSP2833x Examples Include File #include  
#define IIRNUMBER 2
#define SIGNAL1F 1000
#define SIGNAL2F 4500
#define SAMPLEF  10000
#define PI       3.1415926


float InputWave();
float IIR();


float fBn[IIRNUMBER]={ 0.0,0.7757 };
float fAn[IIRNUMBER]={ 0.1122,0.1122 };
float fXn[IIRNUMBER]={ 0.0 };
float fYn[IIRNUMBER]={ 0.0 };
float fInput,fOutput;
float fSignal1,fSignal2;
float fStepSignal1,fStepSignal2;
float f2PI;
int i;
float fin[256],fout[256];
//输入fIn毛刺正弦波,输出fOut较光滑正弦波,Graph: 256,32-bit floating integer,
int nIn,nOut;


main()
{
    nIn=0; nOut=0;
    fInput=fOutput=0;
    f2PI=2*PI;
    fSignal1=0.0;
    fSignal2=PI*0.1;
//  fStepSignal1=2*PI/30;
//  fStepSignal2=2*PI*1.4;
    fStepSignal1=2*PI/50;
    fStepSignal2=2*PI/2.5;
    while ( 1 )
    {
        fInput=InputWave();
        fin[nIn]=fInput;
        nIn++; nIn%=256;
        fOutput=IIR();
        fout[nOut]=fOutput;
        nOut++;             // break point
        if ( nOut>=256 )
        {
            nOut=0;
        }
    }
}


float InputWave()
{
    for ( i=IIRNUMBER-1;i>0;i-- )
    {
        fXn=fXn[i-1];
        fYn=fYn[i-1];
    }
    fXn[0]=sin((double)fSignal1)+cos((double)fSignal2)/6.0;
    fYn[0]=0.0;
    fSignal1+=fStepSignal1;
    if ( fSignal1>=f2PI )   fSignal1-=f2PI;
    fSignal2+=fStepSignal2;
    if ( fSignal2>=f2PI )   fSignal2-=f2PI;
    return(fXn[0]);
}


float IIR()
{
    float fSum;
    fSum=0.0;
    for ( i=0;i
DSP IIR digital filter implementation program source code


This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list