ArmfulKST / Mbed 2 deprecated PE_11-01_DSPInOut

Dependencies:   mbed

Fork of PE_11-01_DSPInOut by Rob Toulson

Revision:
1:92e81744d2f8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPF.cpp	Fri Dec 12 12:43:12 2014 +0000
@@ -0,0 +1,19 @@
+/*Program Example 11.2 Low pass filter function 
+                                              */
+float LPF(float LPF_in){
+    
+  float a[4]={1,2.6235518066,-2.3146825811,0.6855359773};
+  float b[4]={0.0006993496,0.0020980489,0.0020980489,0.0006993496};
+  static float LPF_out;
+  static float x[4], y[4];  
+
+  x[3] = x[2]; x[2] = x[1]; x[1] = x[0];  //move x values by one sample
+  y[3] = y[2]; y[2] = y[1]; y[1] = y[0];  //move y values by one sample
+ 
+  x[0] = LPF_in;                          // new value for x[0] 
+  y[0] =   (b[0]*x[0]) + (b[1]*x[1]) + (b[2]*x[2]) + (b[3]*x[3])                       
+            + (a[1]*y[1]) + (a[2]*y[2]) + (a[3]*y[3]);
+
+  LPF_out = y[0]; 
+  return LPF_out;                         // output filtered value
+}
\ No newline at end of file