Non-variable (TESTEDandWORKING)

Dependencies:   mbed-rtos mbed

Fork of ELEC347_Coursework by CMST

Committer:
chills
Date:
Tue Nov 28 13:06:24 2017 +0000
Revision:
6:a2737b51424c
Parent:
2:f6e49378dd8a
Child:
7:6cb27cce4c50
Working Code with Proof

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mwthewsey 0:d39a06ca6bf1 1 //#define Fs 35000 //Frequency of Sample Rate in Hz
mwthewsey 0:d39a06ca6bf1 2 //#define N 5 //Number of Nodes N
mwthewsey 0:d39a06ca6bf1 3
mwthewsey 0:d39a06ca6bf1 4 class FILTER
mwthewsey 0:d39a06ca6bf1 5 {
mwthewsey 0:d39a06ca6bf1 6 private:
mwthewsey 0:d39a06ca6bf1 7 // calculate_equation();//calculated the value of the equation
mwthewsey 0:d39a06ca6bf1 8
mwthewsey 0:d39a06ca6bf1 9 //Can be interrupt driven
mwthewsey 0:d39a06ca6bf1 10 int _Fs;
mwthewsey 0:d39a06ca6bf1 11 int _Fo;
mwthewsey 2:f6e49378dd8a 12 double _Boost;
mwthewsey 0:d39a06ca6bf1 13 int _Q;
mwthewsey 2:f6e49378dd8a 14 double _Wo_d;
mwthewsey 2:f6e49378dd8a 15 double _Wo_d2;
mwthewsey 2:f6e49378dd8a 16 float _Com_Den;
mwthewsey 2:f6e49378dd8a 17 float _NC0;
mwthewsey 2:f6e49378dd8a 18 float _NC1;
mwthewsey 2:f6e49378dd8a 19 float _NC2;
mwthewsey 2:f6e49378dd8a 20 float _DC1;
mwthewsey 2:f6e49378dd8a 21 float _DC2;
mwthewsey 2:f6e49378dd8a 22
mwthewsey 2:f6e49378dd8a 23 float _FilterOutput;
mwthewsey 0:d39a06ca6bf1 24 float _centreTap; //internal node of filter
mwthewsey 0:d39a06ca6bf1 25 float _b0;
mwthewsey 0:d39a06ca6bf1 26 float _b1;
mwthewsey 0:d39a06ca6bf1 27 float _b2;
mwthewsey 0:d39a06ca6bf1 28 float _b3;
mwthewsey 0:d39a06ca6bf1 29 float _b4;
mwthewsey 0:d39a06ca6bf1 30
mwthewsey 0:d39a06ca6bf1 31 // A - Denominator coefficients
mwthewsey 0:d39a06ca6bf1 32 float _a0;
mwthewsey 0:d39a06ca6bf1 33 float _a1;
mwthewsey 0:d39a06ca6bf1 34 float _a2;
mwthewsey 0:d39a06ca6bf1 35 float _a3;
mwthewsey 0:d39a06ca6bf1 36 float _a4;
mwthewsey 0:d39a06ca6bf1 37
mwthewsey 0:d39a06ca6bf1 38 float _G;
mwthewsey 0:d39a06ca6bf1 39 float _k;
mwthewsey 0:d39a06ca6bf1 40 float _Wo;
mwthewsey 0:d39a06ca6bf1 41
mwthewsey 0:d39a06ca6bf1 42 float _xn; //this value is the input value
mwthewsey 0:d39a06ca6bf1 43 float _xnm1;
mwthewsey 0:d39a06ca6bf1 44 float _xnm2;
mwthewsey 0:d39a06ca6bf1 45 float _xnm3;
mwthewsey 0:d39a06ca6bf1 46 float _xnm4;
mwthewsey 0:d39a06ca6bf1 47
mwthewsey 0:d39a06ca6bf1 48 float _yn;
mwthewsey 0:d39a06ca6bf1 49 float _ynm1;
mwthewsey 0:d39a06ca6bf1 50 float _ynm2;
mwthewsey 0:d39a06ca6bf1 51 float _ynm3;
mwthewsey 0:d39a06ca6bf1 52 float _ynm4;
mwthewsey 0:d39a06ca6bf1 53
mwthewsey 0:d39a06ca6bf1 54
mwthewsey 0:d39a06ca6bf1 55 public:
chills 6:a2737b51424c 56 FILTER(int Fs, int Fo, double Boost, int Q); //Constuctor
chills 6:a2737b51424c 57 ~FILTER(); //Destuctor
mwthewsey 0:d39a06ca6bf1 58
mwthewsey 2:f6e49378dd8a 59 //Constuct filter
mwthewsey 2:f6e49378dd8a 60
chills 6:a2737b51424c 61 void Define_Filter(); //Calculates the coefficeints of the filter
chills 6:a2737b51424c 62
chills 6:a2737b51424c 63 void Print_Filter(); //Print Filter Coefficients
mwthewsey 2:f6e49378dd8a 64
mwthewsey 2:f6e49378dd8a 65 //Setters
chills 6:a2737b51424c 66 void setvalue(float RAW_input); //xn sample input
mwthewsey 0:d39a06ca6bf1 67
mwthewsey 2:f6e49378dd8a 68 //Getters
chills 6:a2737b51424c 69 float getvalue(void); //returns yn
mwthewsey 0:d39a06ca6bf1 70 };
mwthewsey 0:d39a06ca6bf1 71
mwthewsey 0:d39a06ca6bf1 72