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.
Fork of RT2_P3_students by
Diff: IIR_filter.cpp
- Revision:
- 8:72f260c467ad
- Parent:
- 7:01a7363583b2
diff -r 01a7363583b2 -r 72f260c467ad IIR_filter.cpp
--- a/IIR_filter.cpp Sun Apr 22 19:54:59 2018 +0000
+++ b/IIR_filter.cpp Tue Apr 24 09:13:59 2018 +0000
@@ -22,10 +22,10 @@
// filter coefficients
B = (double*)malloc((nb+1)*sizeof(double));
A = (double*)malloc(na*sizeof(double));
- B[0] = 2.0/(2.0*(double)T + (double)Ts);
- B[1] = -B[0];
- A[0] = -(2.0*(double)T - (double)Ts)/(2.0*(double)T + (double)Ts);
-
+ B[0] = (double)Ts/((double)Ts + 2.0*(double)T);
+ B[1] = B[0];
+ A[0] = ((double)Ts - 2.0*(double)T)/((double)Ts + 2.0*(double)T);
+
// signal arrays
uk = (double*)malloc((nb+1)*sizeof(double));
yk = (double*)malloc(na*sizeof(double));
@@ -33,7 +33,7 @@
yk[0] = 0.0;
// dc-gain
- this->K = 0.0;
+ this->K = 1.0;
}
// G(s) = K/(T*s + 1)
@@ -46,7 +46,7 @@
// filter coefficients
B = (double*)malloc((nb+1)*sizeof(double));
A = (double*)malloc(na*sizeof(double));
- B[0] = (double)Ts/((double)Ts + 2.0*(double)T);
+ B[0] = (double)K * (double)Ts/((double)Ts + 2.0*(double)T);
B[1] = B[0];
A[0] = ((double)Ts - 2.0*(double)T)/((double)Ts + 2.0*(double)T);
