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
Diff: GPA.cpp
- Revision:
- 24:308f40175b27
- Parent:
- 20:1d5e89b2f22e
- Child:
- 25:13af44aeabbd
--- a/GPA.cpp Thu May 31 13:51:07 2018 +0000
+++ b/GPA.cpp Mon Oct 15 17:33:18 2018 +0000
@@ -175,6 +175,8 @@
pi2 = 2.0*pi;
pi2Ts = pi2*(double)Ts;
piDiv2 = pi/2.0;
+
+ scaleH = 2.0;
sU = (double*)malloc(3*sizeof(double));
sY = (double*)malloc(3*sizeof(double));
@@ -192,6 +194,7 @@
ii = 1; // iterating through desired frequency points
jj = 1; // iterating through measurement points w.r.t. reachable frequency
scaleG = 0.0;
+ wk = 0.0;
cr = 0.0;
ci = 0.0;
for(int i = 0; i < 3; i++) {
@@ -240,12 +243,13 @@
sY[i] = 0.0;
}
}
+ calcHann();
// filter step for signal su
- sU[0] = scaleG*inp + 2.0*cr*sU[1] - sU[2];
+ sU[0] = wk*scaleG*inp + 2.0*cr*sU[1] - sU[2];
sU[2] = sU[1];
sU[1] = sU[0];
// filter step for signal sy
- sY[0] = scaleG*out + 2.0*cr*sY[1] - sY[2];
+ sY[0] = wk*scaleG*out + 2.0*cr*sY[1] - sY[2];
sY[2] = sY[1];
sY[1] = sY[0];
// measurement of frequencypoint is finished
@@ -254,10 +258,10 @@
ii += 1;
fexcPast = fexc;
// calculate the one point dft
- double Ureal = 2.0*scaleG*(cr*sU[1] - sU[2]);
- double Uimag = 2.0*scaleG*ci*sU[1];
- double Yreal = 2.0*scaleG*(cr*sY[1] - sY[2]);
- double Yimag = 2.0*scaleG*ci*sY[1];
+ double Ureal = 2.0*scaleH*scaleG*(cr*sU[1] - sU[2]);
+ double Uimag = 2.0*scaleH*scaleG*ci*sU[1];
+ double Yreal = 2.0*scaleH*scaleG*(cr*sY[1] - sY[2]);
+ double Yimag = 2.0*scaleH*scaleG*ci*sY[1];
// calculate magnitude and angle
float Umag = (float)(sqrt(Ureal*Ureal + Uimag*Uimag));
float Ymag = (float)(sqrt(Yreal*Yreal + Yimag*Yimag));
@@ -306,6 +310,11 @@
fexc = (double)Nper/(double)Nmeas/Ts;
}
+void GPA::calcHann()
+{
+ wk = 0.5 - 0.5*cos(2.0*pi*((double)jj-1.0)/(double)Nmeas);
+}
+
void GPA::printLine()
{
printf("-----------------------------------------------------------------------------------------\r\n");