Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of PE_11-01_DSPInOut by
Diff: LPF.cpp
- 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
