Test program with the RT black boxes

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pmic
Date:
Wed May 15 13:58:10 2019 +0000
Parent:
40:711929f5c2a8
Commit message:
Add new instantiation option to surpress the printout for rt mbed

Changed in this revision

GPA.cpp Show annotated file Show diff for this revision Revisions of this file
GPA.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GPA.cpp	Wed May 15 12:42:46 2019 +0000
+++ b/GPA.cpp	Wed May 15 13:58:10 2019 +0000
@@ -86,10 +86,10 @@
             exc = Wobble(exc, y);
             
             Closed loop FRF calculus with a stabilizing controller C:
-                S  = 1/(1 + C*P);  % ( exc1 -> e ,   1/(1 + C*P) ) contr. error rejection, robustness (1/max|S|)
-                T  = 1 - S;        % ( w -> y    , C*P/(1 + C*P) ) tracking
-                CS = C*S;          % ( exc1 -> u ,   C/(1 + C*P) ) disturbance plant output
-                PS = P*S;          % ( exc2 -> y ,   P/(1 + C*P) ) disturbance plant input
+                S  = 1/(1 + C*P);  % ( exc1 -> e ,   1/(1 + C*P) ) sensitivity, contr. error rejection, robustness (1/max|S|)
+                T  = 1 - S;        % ( w -> y    , C*P/(1 + C*P) ) compl. sensitivity, tracking performance
+                CS = C*S;          % ( exc1 -> u ,   C/(1 + C*P) ) control effort, disturbance plant output on plant input
+                PS = P*S;          % ( exc2 -> y ,   P/(1 + C*P) ) compliance, disturbance plant input on plant output
 
 
     Pseudo code for a closed loop measurement with stabilizing controller C:
@@ -170,6 +170,7 @@
     int NstartMin = (int)ceil(3.0f/Ts);
     int NsweepMin = 0;
     
+    doPrint = true;
     assignParameters(NfexcDes, NperMin, NmeasMin, (double)Ts, NstartMin, NsweepMin);
 
     // calculate logarithmic spaced frequency points
@@ -184,6 +185,7 @@
 
 GPA::GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin)
 {
+    doPrint = true;
     assignParameters(NfexcDes, NperMin, NmeasMin, (double)Ts, NstartMin, NsweepMin);
 
     // calculate logarithmic spaced frequency points
@@ -198,6 +200,7 @@
 
 GPA::GPA(float f0, float f1, float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin)
 {
+    doPrint = true;
     assignParameters(NfexcDes, NperMin, NmeasMin, (double)Ts, NstartMin, NsweepMin);
     
     // convert fexcDes from float to double, it is assumed that it is sorted
@@ -214,6 +217,7 @@
 
 GPA::GPA(float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin)
 {
+    doPrint = true;
     assignParameters(NfexcDes, NperMin, NmeasMin, (double)Ts, NstartMin, NsweepMin);
     
     // convert fexcDes from float to double, it is assumed that it is sorted
@@ -228,6 +232,21 @@
     reset();
 }
 
+GPA::GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin, bool doPrint)
+{
+    this->doPrint = doPrint;
+    assignParameters(NfexcDes, NperMin, NmeasMin, (double)Ts, NstartMin, NsweepMin);
+
+    // calculate logarithmic spaced frequency points
+    fexcDes = (double*)malloc(NfexcDes*sizeof(double));
+    fexcDesLogspace((double)fMin, (double)fMax, NfexcDes);
+
+    calculateDecreasingAmplitudeCoefficients((double)Aexc0, (double)Aexc1);
+    initializeConstants((double)Ts);
+    assignFilterStorage();
+    reset();
+}
+
 // -----------------------------------------------------------------------------
 //      virtual and reset
 // -----------------------------------------------------------------------------
@@ -281,13 +300,11 @@
     // a new frequency point has been reached
     if(j == 1) {
         // user info
-        /*
-        if(i == 1) {
+        if(i == 1 & doPrint) {
             printLine();
             printf("  fexc[Hz]    |Gyu|    deg(Gyu)  |Gyr|    deg(Gyr)   |U|       |Y|       |R|\r\n");
             printLine();
         }
-        */
         // get a new unique frequency point
         while(fexc == fexcPast) {
             // measurement finished
@@ -363,9 +380,9 @@
         gpaData.Rmag = (float)Aexc;
         gpaData.MeasPointFinished = true;
         // user info
-        /*
+        if(doPrint) {
         printf("%11.4e %9.3e %8.3f %9.3e %8.3f %9.3e %9.3e %9.3e\r\n", gpaData.fexc, gpaData.absGyu, gpaData.angGyu, gpaData.absGyr, gpaData.angGyr, gpaData.Umag, gpaData.Ymag, gpaData.Rmag);
-        */
+        }
         i += 1;
         j = 1;
     } else {
--- a/GPA.h	Wed May 15 12:42:46 2019 +0000
+++ b/GPA.h	Wed May 15 13:58:10 2019 +0000
@@ -21,6 +21,7 @@
     GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin);
     GPA(float f0, float f1, float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin);
     GPA(float *fexcDes, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin);
+    GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1, int NstartMin, int NsweepMin, bool doPrint);
 
     float operator()(float inp, float out)
     {
@@ -84,6 +85,7 @@
     double  AexcOut;
 
     gpadata_t gpaData;
+    bool    doPrint;
 
     void    assignParameters(int NfexcDes, int NperMin, int NmeasMin, double Ts, int NstartMin, int NsweepMin);
     void    calculateDecreasingAmplitudeCoefficients(double Aexc0, double Aexc1);
--- a/main.cpp	Wed May 15 12:42:46 2019 +0000
+++ b/main.cpp	Wed May 15 13:58:10 2019 +0000
@@ -70,8 +70,8 @@
 int   NstartMin = (int)ceil(Tstart/Ts);
 float Tsweep = 0.3f;
 int   NsweepMin = (int)ceil(Tsweep/Ts);
-GPA   gpa1(fMin, fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1, NstartMin, NsweepMin);
-GPA   gpa2(fMin, fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1, NstartMin, NsweepMin);
+GPA   gpa1(fMin, fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1, NstartMin, NsweepMin, false);
+GPA   gpa2(fMin, fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1, NstartMin, NsweepMin, false);
 GPA::gpadata_t gpaData;
 int   gpaIndex = 0;
 float gpaMeasArray[NfexcDes][8];