Non-variable (TESTEDandWORKING)

Dependencies:   mbed-rtos mbed

Fork of ELEC347_Coursework by CMST

Revision:
11:7efb6e4759cc
Parent:
8:192b376a6da7
Child:
13:db76473a3d76
diff -r 3495fff88da7 -r 7efb6e4759cc Filter.cpp
--- a/Filter.cpp	Thu Nov 30 10:18:21 2017 +0000
+++ b/Filter.cpp	Sat Dec 02 13:35:40 2017 +0000
@@ -7,12 +7,14 @@
 
 FILTER::FILTER(int Fs, int Fo, double Boost, int Q) //Constuctor
 {
+    //Storing Paremeters into the Class
     this-> _Fs = Fs;
     this-> _Fo = Fo;
     this-> _Boost = Boost;
     this-> _Q = Q;
-
-
+    
+    //Initializing Variables
+    
     _centreTap = 1;
     _G = 0;
     _k = 0;
@@ -35,11 +37,13 @@
     _ynm2 = 0;
 }
 
-FILTER::~FILTER() {}
+FILTER::~FILTER()//Destructor 
+{
+    
+}
 
-void FILTER::setvalue(float RAW_input)
-{
-            
+void FILTER::setvalue(float RAW_input)//Sets the raw input value to the class
+{  
     _xn = RAW_input;
     _centreTap = _xn*_b0 + _xnm1*_b1 + _xnm2*_b2; //IIR Filter
     _yn = _centreTap*_a0 - _a1*_ynm1 - _a2*_ynm2; //Result in yn
@@ -53,21 +57,21 @@
     //THESE NEED TO BE LOADED IN THIS ORDER OTHERWISE ALL ynm VALUES WILL BECOME THE SAME AS yn
     _ynm2 = _ynm1;
     _ynm1 = _yn;
-
 }
 
-float FILTER::getvalue(void)
+float FILTER::getvalue(void)//Returns the current filter output value
 {
     return _FilterOutput;  
 }
 
 void FILTER::Define_Filter()//Define the filter coefficients
 {
+    //Calculate the values for the equation parameters
     _G = pow(10,_Boost/20.0);
     _k = 3 * ((_G - 1) / (_G+1));
     _Wo = 2 * PI * _Fo;
     _Wo_d = tan(_Wo / (2*_Fs));
-    _Wo_d2 = (_Wo_d * _Wo_d);                   //Omega-Dash-Naught-Squared
+    _Wo_d2 = (_Wo_d * _Wo_d);//Omega-Dash-Naught-Squared
     _Com_Den = 1 + ((3-_k)*_Wo_d/_Q) + _Wo_d2;
     _NC0 = 1 + ((3+_k)*_Wo_d/_Q) + _Wo_d2;
     _NC1 = -2 + (2 * _Wo_d2);
@@ -85,7 +89,7 @@
     _a2 = _DC2 / _Com_Den;
 }
 
-void FILTER::Print_Filter()                //Print Filter Coefficients
+void FILTER::Print_Filter()//Print Filter Coefficients
 {
     printf("Num 1 = %f\t", _b0);
     printf("Num 2 = %f\t", _b1);