Skip to content

digital signal processing FIR filter implimentation in microcontroller

Notifications You must be signed in to change notification settings

binarymaker/fir-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FIR Filter

finite impulse response (FIR) digital filter for microcontroller

Library files

Concept block

alt text

alt text

Code usage

/* Include library */
#include "fir.h"

/* Filter objects */
movingAverage_t fir_ftr;
movingAverage_t fir_ftr_2;

/* co-eff value calculated from Iowa Hills FIR Filters tool */

float low_pass_coeff[] = {

 0.033037850144342927,
 0.115593443353483427,
 0.195352709288829529,
 0.244281564490212016,
 0.244281564490212016,
 0.195352709288829529,
 0.115593443353483427,
 0.033037850144342927

};


float high_pass_coeff[] = {

 0.020062112266054671,
 0.039940619065501934,
 0.053593365042411495,
 0.053416852363487331,
 0.031286041832566183,
-0.023735038477653174,
-0.142727313632826841,
-0.612151054466002487,
 0.612151054466002487,
 0.142727313632826841,
 0.023735038477653174,
-0.031286041832566183,
-0.053416852363487331,
-0.053593365042411495,
-0.039940619065501934,
-0.020062112266054671

};

void main()
{
   /* Initialization of filters */
   fir_create(&fir_ftr, low_pass_coeff, 8, 1.176, 100);    /* filter size 8, sample time 100ms */
   fir_create(&fir_ftr_2, high_pass_coeff, 16, 1, 150);    /* filter size 16, sample time 150ms */

   while(1)
   {
      signal = signal_source();  /* signal source function may ADC, Capture count, sensor data*/

      /* Filter process
      * 
      * call this function maximum passible short time
      */
      fir_filter(&fir_ftr, signal);
      fir_filter(&fir_ftr_2, signal);

      process_or_print = fir_ftr.filtered;
      process_or_print = fir_ftr_2.filtered;
   }
}

Filter images

  • channel 0 - signal + noise (+/- 50)
  • channel 1 - filter output

32 Tab filter 500Hz

  • Sampling frequency - 500hz
  • cutoff frequency - 5hz

alt text

Zoom

alt text

Iowa Hills FIR Filters tool configuration

alt text

32 Tab filter 100Hz

  • Sampling frequency - 100hz
  • cutoff frequency - 5hz

alt text

Iowa Hills FIR Filters tool configuration

alt text

16 Tab filter 500Hz

  • Sampling frequency - 500hz
  • cutoff frequency - 5hz

alt text

Iowa Hills FIR Filters tool configuration

alt text

Signed values

alt text

Thanks to Iowa Hills FIR Filters tool Download

Refer other filters

Releases

No releases published

Packages

No packages published