Template for group 4

Dependencies:   mbed

Fork of RT2_P3_students by RT2_P3_students

Revision:
6:8ed679044a72
Parent:
5:72982ede2ff6
Child:
7:01a7363583b2
--- a/main.cpp	Tue Apr 17 09:06:47 2018 +0000
+++ b/main.cpp	Tue Apr 17 11:47:35 2018 +0000
@@ -8,6 +8,7 @@
 #include "IIR_filter.h"
 #include "LinearCharacteristics.h"
 #include "PI_Cntrl.h"
+#include "GPA.h"
 /* Cuboid balance on one edge on Nucleo F446RE
 
  **** IMPORTANT: use ..\Labormodelle\RT-MOD054 - Würfel\Escon_Parameter_4nucleo.edc 
@@ -50,7 +51,7 @@
 //------------------------------------------
 // ... here define variables like gains etc.
 //------------------------------------------
-LinearCharacteristics i2u(1.5f,2.5f);
+LinearCharacteristics i2u(0.8f,-2.0f);
 
 //------------------------------------------
 Ticker  ControllerLoopTimer;            // interrupt for control loop
@@ -59,7 +60,10 @@
 //------------------------------------------
 // ... here define instantiate classes
 //------------------------------------------
-
+PI_Cntrl vel_cntrl(0.5f,.05f,Ts,0.4f);
+GPA gpa1(1.0f, 200.0f,      150,       4,      400, Ts, 10.0f, 0.3f);
+float excWobble = 0.0f;
+// GPA(t fMin, t fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1)
 // ... define some linear characteristics -----------------------------------------
 
 // ----- User defined functions -----------
@@ -85,10 +89,18 @@
 void updateControllers(void){
     short counts = counter1;            // get counts from Encoder
     float vel = diff(counts);           // motor velocity 
-     // ... your code 
+     /* desTorque = pi_w(omega_desired - omega + excWobble);
+            outWobble = omega;
+            excWobble = Wobble(excWobble, outWobble); */
+    
+    float torq_des = vel_cntrl(excWobble + w_soll - vel);
+    excWobble = gpa1(torq_des,vel);
+    out.write(i2u(torq_des/0.217f));     // the controller! convert torque to Amps km = 0.217 Nm/A
+    
+    
   //  if(++k >= 249){
   //      k = 0;
-        pc.printf("i2u(8): %3.3f\r\n",i2u(8.0f));
+        //pc.printf("Des. velocity: %3.3f, Velocity: %3.3f\r\n",w_soll,vel);
     //}
 }
 //******************************************************************************