Chris Hills
/
2017_11_28_ELEC347_Coursework
Test
Fork of ELEC347_CourseWork by
Filter.hpp@10:3495fff88da7, 2017-11-30 (annotated)
- Committer:
- chills
- Date:
- Thu Nov 30 10:18:21 2017 +0000
- Revision:
- 10:3495fff88da7
- Parent:
- 7:6cb27cce4c50
V001. ; 2017_11_30 10:18; ; Working code from Tuesday's session.
Who changed what in which revision?
User | Revision | Line number | New 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 | |
chills | 7:6cb27cce4c50 | 65 | void Update_Fo(int Fo_New); //Update Centre Frequency |
chills | 7:6cb27cce4c50 | 66 | int Get_Fo(); |
chills | 7:6cb27cce4c50 | 67 | |
chills | 7:6cb27cce4c50 | 68 | void Update_Boost(double Boost_New); |
chills | 7:6cb27cce4c50 | 69 | double Get_Boost(); |
chills | 7:6cb27cce4c50 | 70 | |
chills | 7:6cb27cce4c50 | 71 | void Update_Q(int Q_New); |
chills | 7:6cb27cce4c50 | 72 | int Get_Q(); |
chills | 7:6cb27cce4c50 | 73 | |
mwthewsey | 2:f6e49378dd8a | 74 | //Setters |
chills | 6:a2737b51424c | 75 | void setvalue(float RAW_input); //xn sample input |
mwthewsey | 0:d39a06ca6bf1 | 76 | |
mwthewsey | 2:f6e49378dd8a | 77 | //Getters |
chills | 6:a2737b51424c | 78 | float getvalue(void); //returns yn |
mwthewsey | 0:d39a06ca6bf1 | 79 | }; |
mwthewsey | 0:d39a06ca6bf1 | 80 | |
mwthewsey | 0:d39a06ca6bf1 | 81 |