gpa in double prescision

Dependencies:   mbed

Committer:
pmic
Date:
Tue Apr 10 12:25:03 2018 +0000
Revision:
28:c71b6856652e
Parent:
27:061dede7880c
correct new functinality

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmic 10:b7f142952df9 1 /*
pmic 10:b7f142952df9 2 GPA: frequency point wise gain and phase analyser to measure the frequency
pmic 24:55b11670959e 3 respone of a dynamical system
pmic 12:e54941459353 4
pmic 10:b7f142952df9 5 hint: the measurements should only be perfomed in closed loop
pmic 10:b7f142952df9 6 assumption: the system is at the desired steady state of interest when
pmic 10:b7f142952df9 7 the measurment starts
pmic 12:e54941459353 8
pmic 10:b7f142952df9 9 exc(2) C: controller
pmic 10:b7f142952df9 10 | P: plant
pmic 12:e54941459353 11 v
pmic 10:b7f142952df9 12 exc(1) --> o ->| C |--->o------->| P |----------> out
pmic 26:0ebd540ec659 13 ^ - | |
pmic 10:b7f142952df9 14 | --> inp | exc: excitation signal (E)
pmic 10:b7f142952df9 15 | | inp: input plant (U)
pmic 10:b7f142952df9 16 -------------------------------- out: output plant (Y)
pmic 12:e54941459353 17
pmic 27:061dede7880c 18 instantiate option 1: (logarithmic equaly spaced frequency points)
pmic 25:6f12f60821a3 19
pmic 10:b7f142952df9 20 GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 25:6f12f60821a3 21
pmic 10:b7f142952df9 22 fMin: minimal desired frequency that should be measured in Hz
pmic 10:b7f142952df9 23 fMax: maximal desired frequency that should be measured in Hz
pmic 10:b7f142952df9 24 NfexcDes: number of logarithmic equaly spaced frequency points
pmic 10:b7f142952df9 25 NperMin: minimal number of periods that are used for each frequency point
pmic 24:55b11670959e 26 NmeasMin: minimal number of samples that are used for each frequency point
pmic 10:b7f142952df9 27 Ts: sampling time
pmic 12:e54941459353 28 Aexc0: excitation amplitude at fMin
pmic 10:b7f142952df9 29 Aexc1: excitation amplitude at fMax
pmic 25:6f12f60821a3 30
pmic 25:6f12f60821a3 31 instantiate option 2: (for a second, refined frequency grid measurement)
pmic 25:6f12f60821a3 32
pmic 28:c71b6856652e 33 GPA(float f0, float f1, float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 25:6f12f60821a3 34
pmic 25:6f12f60821a3 35 f0: frequency point for the calculation of Aexc0 in Hz (should be chosen like in the first measurement)
pmic 25:6f12f60821a3 36 f1: frequency point for the calculation of Aexc1 in Hz (should be chosen like in the first measurement)
pmic 25:6f12f60821a3 37 *fexcDes: sorted frequency point array in Hz
pmic 28:c71b6856652e 38 NfexcDes: length of fexcDes
pmic 27:061dede7880c 39
pmic 27:061dede7880c 40 instantiate option 3: (for an arbitary but sorted frequency grid measurement)
pmic 27:061dede7880c 41
pmic 28:c71b6856652e 42 GPA(float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 27:061dede7880c 43
pmic 27:061dede7880c 44 *fexcDes: sorted frequency point array in Hz
pmic 27:061dede7880c 45 Aexc0: excitation amplitude at fexcDes[0]
pmic 27:061dede7880c 46 Aexc1: excitation amplitude at fexcDes[NfexcDes-1]
pmic 28:c71b6856652e 47 NfexcDes: length of fexcDes
pmic 12:e54941459353 48
pmic 25:6f12f60821a3 49 hints: the amplitude drops with 1/fexc, if you're using Axc1 = Aexc0/fMax then d/dt exc = const.,
pmic 25:6f12f60821a3 50 this is recommended if your controller does not have a rolloff. if a desired frequency point
pmic 25:6f12f60821a3 51 is not measured try to increase Nmeas.
pmic 12:e54941459353 52
pmic 24:55b11670959e 53 pseudo code for a closed loop measurement with a controller C:
pmic 12:e54941459353 54
pmic 10:b7f142952df9 55 excitation input at (1):
pmic 14:9627301c7983 56
pmic 14:9627301c7983 57 - measuring the plant P and the closed loop tf T = PC/(1 + PC):
pmic 14:9627301c7983 58 desTorque = pi_w(omega_desired - omega + excWobble);
pmic 14:9627301c7983 59 inpWobble = desTorque;
pmic 14:9627301c7983 60 outWobble = omega;
pmic 14:9627301c7983 61 excWobble = Wobble(excWobble, outWobble);
pmic 14:9627301c7983 62
pmic 14:9627301c7983 63 - measuring the controller C and the closed loop tf SC = C/(1 + PC)
pmic 14:9627301c7983 64 desTorque = pi_w(omega_desired - omega + excWobble);
pmic 14:9627301c7983 65 inpWobble = n_soll + excWobble - omega;
pmic 14:9627301c7983 66 outWobble = desTorque;
pmic 14:9627301c7983 67 excWobble = Wobble(inpWobble, outWobble);
pmic 12:e54941459353 68
pmic 10:b7f142952df9 69 excitation input at (2):
pmic 14:9627301c7983 70
pmic 14:9627301c7983 71 - measuring the plant P and the closed loop tf SP = P/(1 + PC):
pmic 14:9627301c7983 72 desTorque = pi_w(omega_desired - omega) + excWobble;
pmic 14:9627301c7983 73 inpWobble = desTorque;
pmic 14:9627301c7983 74 outWobble = omega;
pmic 14:9627301c7983 75 excWobble = Wobble(excWobble, outWobble);
pmic 12:e54941459353 76
pmic 10:b7f142952df9 77 usage:
pmic 14:9627301c7983 78 exc(k+1) = myGPA(inp(k), out(k)) does update the internal states of the
pmic 14:9627301c7983 79 gpa at the timestep k and returns the excitation signal for the timestep
pmic 14:9627301c7983 80 k+1. the results are plotted to a terminal (putty) over a serial
pmic 14:9627301c7983 81 connection and look as follows:
pmic 10:b7f142952df9 82 -----------------------------------------------------------------------------------------
pmic 10:b7f142952df9 83 fexc[Hz] |Gyu| ang(Gyu) |Gye| ang(Gye) |E| |U| |Y|
pmic 10:b7f142952df9 84 -----------------------------------------------------------------------------------------
pmic 14:9627301c7983 85 1.000e+00 2.924e+01 -1.572e+00 1.017e+00 -4.983e-02 5.000e+00 1.739e-01 5.084e+00
pmic 12:e54941459353 86
pmic 10:b7f142952df9 87 in matlab you can use:
pmic 10:b7f142952df9 88 dataNucleo = [... insert measurement data here ...];
pmic 10:b7f142952df9 89 g = frd(dataNucleo(:,2).*exp(1i*dataNucleo(:,3)), dataNucleo(:,1), Ts, 'Units', 'Hz');
pmic 10:b7f142952df9 90 gcl = frd(dataNucleo(:,4).*exp(1i*dataNucleo(:,5)), dataNucleo(:,1), Ts, 'Units', 'Hz');
pmic 12:e54941459353 91
pmic 10:b7f142952df9 92 if you're evaluating more than one measurement which contain equal frequency points try:
pmic 10:b7f142952df9 93 dataNucleo = [dataNucleo1; dataNucleo2];
pmic 10:b7f142952df9 94 [~, ind] = unique(dataNucleo(:,1),'stable');
pmic 10:b7f142952df9 95 dataNucleo = dataNucleo(ind,:);
pmic 12:e54941459353 96
pmic 10:b7f142952df9 97 autor: M.E. Peter
pmic 12:e54941459353 98 */
pmic 10:b7f142952df9 99
pmic 8:3b98b6e1ead3 100 #include "GPA.h"
pmic 8:3b98b6e1ead3 101 #include "mbed.h"
pmic 8:3b98b6e1ead3 102 #include "math.h"
pmic 13:66c98113dc13 103 #define pi 3.141592653589793
pmic 8:3b98b6e1ead3 104
pmic 8:3b98b6e1ead3 105 using namespace std;
pmic 8:3b98b6e1ead3 106
pmic 9:4e6f3404d473 107 GPA::GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 8:3b98b6e1ead3 108 {
pmic 9:4e6f3404d473 109 this->NfexcDes = NfexcDes;
pmic 9:4e6f3404d473 110 this->NperMin = NperMin;
pmic 8:3b98b6e1ead3 111 this->NmeasMin = NmeasMin;
pmic 13:66c98113dc13 112 this->Ts = (double)Ts;
pmic 9:4e6f3404d473 113
pmic 9:4e6f3404d473 114 // calculate logarithmic spaced frequency points
pmic 13:66c98113dc13 115 fexcDes = (double*)malloc(NfexcDes*sizeof(double));
pmic 13:66c98113dc13 116 fexcDesLogspace((double)fMin, (double)fMax, NfexcDes);
pmic 9:4e6f3404d473 117
pmic 9:4e6f3404d473 118 // calculate coefficients for decreasing amplitude (1/fexc)
pmic 13:66c98113dc13 119 this->aAexcDes = ((double)Aexc1 - (double)Aexc0)/(1.0/fexcDes[NfexcDes-1] - 1.0/fexcDes[0]);
pmic 13:66c98113dc13 120 this->bAexcDes = (double)Aexc0 - aAexcDes/fexcDes[0];
pmic 8:3b98b6e1ead3 121
pmic 13:66c98113dc13 122 fnyq = 1.0/2.0/(double)Ts;
pmic 13:66c98113dc13 123 pi2 = 2.0*pi;
pmic 13:66c98113dc13 124 pi2Ts = pi2*(double)Ts;
pmic 13:66c98113dc13 125 piDiv2 = pi/2.0;
pmic 8:3b98b6e1ead3 126
pmic 13:66c98113dc13 127 sU = (double*)malloc(3*sizeof(double));
pmic 13:66c98113dc13 128 sY = (double*)malloc(3*sizeof(double));
pmic 8:3b98b6e1ead3 129 reset();
pmic 8:3b98b6e1ead3 130 }
pmic 8:3b98b6e1ead3 131
pmic 28:c71b6856652e 132 GPA::GPA(float f0, float f1, float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 25:6f12f60821a3 133 {
pmic 25:6f12f60821a3 134 // convert fexcDes from float to double, it is assumed that it is sorted
pmic 28:c71b6856652e 135 this->NfexcDes = NfexcDes;
pmic 25:6f12f60821a3 136 this->fexcDes = (double*)malloc(NfexcDes*sizeof(double));
pmic 25:6f12f60821a3 137 for(int i = 0; i < NfexcDes; i++) {
pmic 25:6f12f60821a3 138 this->fexcDes[i] = (double)fexcDes[i];
pmic 25:6f12f60821a3 139 }
pmic 25:6f12f60821a3 140 this->NperMin = NperMin;
pmic 25:6f12f60821a3 141 this->NmeasMin = NmeasMin;
pmic 25:6f12f60821a3 142 this->Ts = (double)Ts;
pmic 25:6f12f60821a3 143
pmic 25:6f12f60821a3 144 // calculate coefficients for decreasing amplitude (1/fexc)
pmic 25:6f12f60821a3 145 this->aAexcDes = ((double)Aexc1 - (double)Aexc0)/(1.0/(double)f1 - 1.0/(double)f0);
pmic 25:6f12f60821a3 146 this->bAexcDes = (double)Aexc0 - aAexcDes/fexcDes[0];
pmic 25:6f12f60821a3 147
pmic 25:6f12f60821a3 148 fnyq = 1.0/2.0/(double)Ts;
pmic 25:6f12f60821a3 149 pi2 = 2.0*pi;
pmic 25:6f12f60821a3 150 pi2Ts = pi2*(double)Ts;
pmic 25:6f12f60821a3 151 piDiv2 = pi/2.0;
pmic 25:6f12f60821a3 152
pmic 25:6f12f60821a3 153 sU = (double*)malloc(3*sizeof(double));
pmic 25:6f12f60821a3 154 sY = (double*)malloc(3*sizeof(double));
pmic 25:6f12f60821a3 155 reset();
pmic 25:6f12f60821a3 156 }
pmic 25:6f12f60821a3 157
pmic 28:c71b6856652e 158 GPA::GPA(float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1)
pmic 27:061dede7880c 159 {
pmic 27:061dede7880c 160 // convert fexcDes from float to double, it is assumed that it is sorted
pmic 28:c71b6856652e 161 this->NfexcDes = NfexcDes;
pmic 27:061dede7880c 162 this->fexcDes = (double*)malloc(NfexcDes*sizeof(double));
pmic 27:061dede7880c 163 for(int i = 0; i < NfexcDes; i++) {
pmic 27:061dede7880c 164 this->fexcDes[i] = (double)fexcDes[i];
pmic 27:061dede7880c 165 }
pmic 27:061dede7880c 166 this->NperMin = NperMin;
pmic 27:061dede7880c 167 this->NmeasMin = NmeasMin;
pmic 27:061dede7880c 168 this->Ts = (double)Ts;
pmic 27:061dede7880c 169
pmic 27:061dede7880c 170 // calculate coefficients for decreasing amplitude (1/fexc)
pmic 27:061dede7880c 171 this->aAexcDes = ((double)Aexc1 - (double)Aexc0)/(1.0/this->fexcDes[NfexcDes-1] - 1.0/this->fexcDes[0]);
pmic 27:061dede7880c 172 this->bAexcDes = (double)Aexc0 - aAexcDes/fexcDes[0];
pmic 27:061dede7880c 173
pmic 27:061dede7880c 174 fnyq = 1.0/2.0/(double)Ts;
pmic 27:061dede7880c 175 pi2 = 2.0*pi;
pmic 27:061dede7880c 176 pi2Ts = pi2*(double)Ts;
pmic 27:061dede7880c 177 piDiv2 = pi/2.0;
pmic 27:061dede7880c 178
pmic 27:061dede7880c 179 sU = (double*)malloc(3*sizeof(double));
pmic 27:061dede7880c 180 sY = (double*)malloc(3*sizeof(double));
pmic 27:061dede7880c 181 reset();
pmic 27:061dede7880c 182 }
pmic 27:061dede7880c 183
pmic 8:3b98b6e1ead3 184 GPA::~GPA() {}
pmic 8:3b98b6e1ead3 185
pmic 8:3b98b6e1ead3 186 void GPA::reset()
pmic 8:3b98b6e1ead3 187 {
pmic 8:3b98b6e1ead3 188 Nmeas = 0;
pmic 9:4e6f3404d473 189 Nper = 0;
pmic 13:66c98113dc13 190 fexc = 0.0;
pmic 13:66c98113dc13 191 fexcPast = 0.0;
pmic 8:3b98b6e1ead3 192 ii = 1; // iterating through desired frequency points
pmic 8:3b98b6e1ead3 193 jj = 1; // iterating through measurement points w.r.t. reachable frequency
pmic 13:66c98113dc13 194 scaleG = 0.0;
pmic 13:66c98113dc13 195 cr = 0.0;
pmic 13:66c98113dc13 196 ci = 0.0;
pmic 8:3b98b6e1ead3 197 for(int i = 0; i < 3; i++) {
pmic 13:66c98113dc13 198 sU[i] = 0.0;
pmic 13:66c98113dc13 199 sY[i] = 0.0;
pmic 8:3b98b6e1ead3 200 }
pmic 13:66c98113dc13 201 sinarg = 0.0;
pmic 8:3b98b6e1ead3 202 NmeasTotal = 0;
pmic 13:66c98113dc13 203 Aexc = 0.0;
pmic 13:66c98113dc13 204 pi2Tsfexc = 0.0;
pmic 8:3b98b6e1ead3 205 }
pmic 8:3b98b6e1ead3 206
pmic 13:66c98113dc13 207 float GPA::update(double inp, double out)
pmic 8:3b98b6e1ead3 208 {
pmic 8:3b98b6e1ead3 209 // a new frequency point has been reached
pmic 8:3b98b6e1ead3 210 if(jj == 1) {
pmic 9:4e6f3404d473 211 // get a new unique frequency point
pmic 8:3b98b6e1ead3 212 while(fexc == fexcPast) {
pmic 8:3b98b6e1ead3 213 // measurement finished
pmic 9:4e6f3404d473 214 if(ii > NfexcDes) {
pmic 8:3b98b6e1ead3 215 return 0.0f;
pmic 8:3b98b6e1ead3 216 }
pmic 8:3b98b6e1ead3 217 calcGPAmeasPara(fexcDes[ii - 1]);
pmic 8:3b98b6e1ead3 218 // secure fexc is not higher or equal to nyquist frequency
pmic 8:3b98b6e1ead3 219 if(fexc >= fnyq) {
pmic 8:3b98b6e1ead3 220 fexc = fexcPast;
pmic 8:3b98b6e1ead3 221 }
pmic 8:3b98b6e1ead3 222 // no frequency found
pmic 8:3b98b6e1ead3 223 if(fexc == fexcPast) {
pmic 8:3b98b6e1ead3 224 ii += 1;
pmic 9:4e6f3404d473 225 } else {
pmic 9:4e6f3404d473 226 Aexc = aAexcDes/fexc + bAexcDes;
pmic 9:4e6f3404d473 227 pi2Tsfexc = pi2Ts*fexc;
pmic 8:3b98b6e1ead3 228 }
pmic 8:3b98b6e1ead3 229 }
pmic 12:e54941459353 230 // secure sinarg starts at 0 (numerically maybe not given)
pmic 13:66c98113dc13 231 sinarg = 0.0;
pmic 8:3b98b6e1ead3 232 // filter scaling
pmic 13:66c98113dc13 233 scaleG = 1.0/sqrt((double)Nmeas);
pmic 8:3b98b6e1ead3 234 // filter coefficients
pmic 9:4e6f3404d473 235 cr = cos(pi2Tsfexc);
pmic 9:4e6f3404d473 236 ci = sin(pi2Tsfexc);
pmic 8:3b98b6e1ead3 237 // filter storage
pmic 8:3b98b6e1ead3 238 for(int i = 0; i < 3; i++) {
pmic 13:66c98113dc13 239 sU[i] = 0.0;
pmic 13:66c98113dc13 240 sY[i] = 0.0;
pmic 8:3b98b6e1ead3 241 }
pmic 8:3b98b6e1ead3 242 }
pmic 8:3b98b6e1ead3 243 // filter step for signal su
pmic 13:66c98113dc13 244 sU[0] = scaleG*inp + 2.0*cr*sU[1] - sU[2];
pmic 8:3b98b6e1ead3 245 sU[2] = sU[1];
pmic 8:3b98b6e1ead3 246 sU[1] = sU[0];
pmic 8:3b98b6e1ead3 247 // filter step for signal sy
pmic 13:66c98113dc13 248 sY[0] = scaleG*out + 2.0*cr*sY[1] - sY[2];
pmic 8:3b98b6e1ead3 249 sY[2] = sY[1];
pmic 8:3b98b6e1ead3 250 sY[1] = sY[0];
pmic 9:4e6f3404d473 251 // measurement of frequencypoint is finished
pmic 8:3b98b6e1ead3 252 if(jj == Nmeas) {
pmic 8:3b98b6e1ead3 253 jj = 1;
pmic 10:b7f142952df9 254 ii += 1;
pmic 12:e54941459353 255 fexcPast = fexc;
pmic 8:3b98b6e1ead3 256 // calculate the one point dft
pmic 13:66c98113dc13 257 double Ureal = 2.0*scaleG*(cr*sU[1] - sU[2]);
pmic 13:66c98113dc13 258 double Uimag = 2.0*scaleG*ci*sU[1];
pmic 13:66c98113dc13 259 double Yreal = 2.0*scaleG*(cr*sY[1] - sY[2]);
pmic 13:66c98113dc13 260 double Yimag = 2.0*scaleG*ci*sY[1];
pmic 8:3b98b6e1ead3 261 // calculate magnitude and angle
pmic 13:66c98113dc13 262 float Umag = (float)(sqrt(Ureal*Ureal + Uimag*Uimag));
pmic 13:66c98113dc13 263 float Ymag = (float)(sqrt(Yreal*Yreal + Yimag*Yimag));
pmic 13:66c98113dc13 264 float absGyu = (float)(Ymag/Umag);
pmic 13:66c98113dc13 265 float angGyu = (float)(atan2(Yimag, Yreal) - atan2(Uimag, Ureal));
pmic 13:66c98113dc13 266 float absGye = (float)(Ymag/Aexc);
pmic 13:66c98113dc13 267 float angGye = (float)(atan2(Yimag, Yreal) + piDiv2);
pmic 8:3b98b6e1ead3 268 // user info
pmic 12:e54941459353 269 if(ii == 2) {
pmic 8:3b98b6e1ead3 270 printLine();
pmic 9:4e6f3404d473 271 printf(" fexc[Hz] |Gyu| ang(Gyu) |Gye| ang(Gye) |E| |U| |Y|\r\n");
pmic 8:3b98b6e1ead3 272 printLine();
pmic 8:3b98b6e1ead3 273 }
pmic 15:9ae07af93eeb 274 printf("%11.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e\r\n", (float)fexc, absGyu, angGyu, absGye, angGye, (float)Aexc, Umag, Ymag);
pmic 8:3b98b6e1ead3 275 } else {
pmic 8:3b98b6e1ead3 276 jj += 1;
pmic 8:3b98b6e1ead3 277 }
pmic 9:4e6f3404d473 278 sinarg = fmod(sinarg + pi2Tsfexc, pi2);
pmic 8:3b98b6e1ead3 279 NmeasTotal += 1;
pmic 13:66c98113dc13 280 return (float)(Aexc*sin(sinarg));
pmic 8:3b98b6e1ead3 281 }
pmic 8:3b98b6e1ead3 282
pmic 13:66c98113dc13 283 void GPA::fexcDesLogspace(double fMin, double fMax, int NfexcDes)
pmic 9:4e6f3404d473 284 {
pmic 9:4e6f3404d473 285 // calculate logarithmic spaced frequency points
pmic 13:66c98113dc13 286 double Gain = log10(fMax/fMin)/((double)NfexcDes - 1.0);
pmic 13:66c98113dc13 287 double expon = 0.0;
pmic 9:4e6f3404d473 288 for(int i = 0; i < NfexcDes; i++) {
pmic 13:66c98113dc13 289 fexcDes[i] = fMin*pow(10.0, expon);
pmic 9:4e6f3404d473 290 expon += Gain;
pmic 9:4e6f3404d473 291 }
pmic 9:4e6f3404d473 292 }
pmic 9:4e6f3404d473 293
pmic 13:66c98113dc13 294 void GPA::calcGPAmeasPara(double fexcDes_i)
pmic 9:4e6f3404d473 295 {
pmic 9:4e6f3404d473 296 // Nmeas has to be an integer
pmic 9:4e6f3404d473 297 Nper = NperMin;
pmic 13:66c98113dc13 298 Nmeas = (int)floor((double)Nper/fexcDes_i/Ts + 0.5);
pmic 9:4e6f3404d473 299 // secure that the minimal number of measurements is fullfilled
pmic 9:4e6f3404d473 300 int Ndelta = NmeasMin - Nmeas;
pmic 9:4e6f3404d473 301 if(Ndelta > 0) {
pmic 13:66c98113dc13 302 Nper = (int)ceil((double)NmeasMin*fexcDes_i*Ts);
pmic 13:66c98113dc13 303 Nmeas = (int)floor((double)Nper/fexcDes_i/Ts + 0.5);
pmic 9:4e6f3404d473 304 }
pmic 9:4e6f3404d473 305 // evaluating reachable frequency
pmic 13:66c98113dc13 306 fexc = (double)Nper/(double)Nmeas/Ts;
pmic 9:4e6f3404d473 307 }
pmic 9:4e6f3404d473 308
pmic 9:4e6f3404d473 309 void GPA::printLine()
pmic 9:4e6f3404d473 310 {
pmic 9:4e6f3404d473 311 printf("-----------------------------------------------------------------------------------------\r\n");
pmic 9:4e6f3404d473 312 }
pmic 9:4e6f3404d473 313
pmic 9:4e6f3404d473 314 void GPA::printGPAfexcDes()
pmic 9:4e6f3404d473 315 {
pmic 9:4e6f3404d473 316 printLine();
pmic 9:4e6f3404d473 317 for(int i = 0; i < NfexcDes; i++) {
pmic 13:66c98113dc13 318 printf("%9.4f\r\n", (float)fexcDes[i]);
pmic 9:4e6f3404d473 319 }
pmic 9:4e6f3404d473 320 }
pmic 9:4e6f3404d473 321
pmic 9:4e6f3404d473 322 void GPA::printGPAmeasPara()
pmic 9:4e6f3404d473 323 {
pmic 9:4e6f3404d473 324 printLine();
pmic 9:4e6f3404d473 325 printf(" fexcDes[Hz] fexc[Hz] Aexc Nmeas Nper\r\n");
pmic 9:4e6f3404d473 326 printLine();
pmic 9:4e6f3404d473 327 for(int i = 0; i < NfexcDes; i++) {
pmic 9:4e6f3404d473 328 calcGPAmeasPara(fexcDes[i]);
pmic 9:4e6f3404d473 329 if(fexc == fexcPast || fexc >= fnyq) {
pmic 13:66c98113dc13 330 fexc = 0.0;
pmic 9:4e6f3404d473 331 Nmeas = 0;
pmic 9:4e6f3404d473 332 Nper = 0;
pmic 13:66c98113dc13 333 Aexc = 0.0;
pmic 9:4e6f3404d473 334 } else {
pmic 9:4e6f3404d473 335 Aexc = aAexcDes/fexc + bAexcDes;
pmic 9:4e6f3404d473 336 fexcPast = fexc;
pmic 9:4e6f3404d473 337 }
pmic 9:4e6f3404d473 338 NmeasTotal += Nmeas;
pmic 13:66c98113dc13 339 printf("%12.2e %9.2e %10.2e %7i %6i \r\n", (float)fexcDes[i], (float)fexc, (float)Aexc, Nmeas, Nper);
pmic 9:4e6f3404d473 340 }
pmic 9:4e6f3404d473 341 printGPAmeasTime();
pmic 9:4e6f3404d473 342 reset();
pmic 9:4e6f3404d473 343 }
pmic 9:4e6f3404d473 344
pmic 8:3b98b6e1ead3 345 void GPA::printGPAmeasTime()
pmic 8:3b98b6e1ead3 346 {
pmic 8:3b98b6e1ead3 347 printLine();
pmic 8:3b98b6e1ead3 348 printf(" number of data points: %9i\r\n", NmeasTotal);
pmic 13:66c98113dc13 349 printf(" measurment time in sec: %9.2f\r\n", (float)((double)NmeasTotal*Ts));
pmic 28:c71b6856652e 350 }
pmic 28:c71b6856652e 351
pmic 28:c71b6856652e 352 void GPA::printNfexcDes()
pmic 28:c71b6856652e 353 {
pmic 28:c71b6856652e 354 printLine();
pmic 28:c71b6856652e 355 printf(" number of frequancy points: %2i\r\n", NfexcDes);
pmic 28:c71b6856652e 356 }