![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: SPI.c
- Branch:
- filt
- Revision:
- 229:f359509f0c70
- Parent:
- 228:a8195e1b1123
--- a/SPI.c Tue Jan 09 13:19:26 2018 +0000 +++ b/SPI.c Tue Jan 09 13:23:37 2018 +0000 @@ -347,8 +347,8 @@ HFOAmpfilt=BUTTER(25); //HFOAmpfiltC = iirr(HFOAmp); - sprintf((Time),"%d %d %d \r\n",0xffff-ADC5New, HFOAmp, HFOAmpfilt); - WriteCon(Time); + /*sprintf((Time),"%d %d %d \r\n",0xffff-ADC5New, HFOAmp, HFOAmpfilt); + WriteCon(Time);*/ } } @@ -370,8 +370,7 @@ -int BUTTER(int NewSample) { - static unsigned int SHIFT=1; + int BUTTER(int NewSample) { int ACoef[NCoef+1] = { 8195, 16390, @@ -398,14 +397,13 @@ //Calculate the new output x1[0] = NewSample; - y1[0] = ACoef[0]>>SHIFT * x1[0]; + y1[0] = ACoef[0] * x1[0]; for(n=1; n<=NCoef; n++) - y1[0] += ACoef[n]>>SHIFT * x1[n] - BCoef[n]>>SHIFT * y1[n]; + y1[0] += ACoef[n] * x1[n] - BCoef[n] * y1[n]; - y1[0] =(int)(y1[0]/ BCoef[0]>>SHIFT); + y1[0] =(int)(y1[0]/ BCoef[0]); - // return (int)(y1[0] / DCgain>>SHIFT); - return (int)(y1[0]); + return y1[0] / DCgain; }