Fertig

Dependencies:   mbed

Fork of RT2_P3_students by RT2_P3_students

Revision:
9:dc0eb7dd0d92
Parent:
8:8ed679044a72
Child:
10:ddbc7e4c41a0
--- a/main.cpp	Tue Apr 17 11:47:35 2018 +0000
+++ b/main.cpp	Tue Apr 17 13:30:52 2018 +0000
@@ -45,13 +45,14 @@
 AnalogOut out(PA_5);                    // Analog OUT on PA_5   1.6 V -> 0A 3.2A -> 2A (see ESCON)
 float out_value = 1.6f;                 // set voltage on 1.6 V (0 A current)
 float w_soll = 10.0f;                   // desired velocity
-float Ts = 0.2f;                      // sample time of main loops
+float Ts = 0.002f;                      // sample time of main loops
 int k = 0;
 
 //------------------------------------------
 // ... here define variables like gains etc.
 //------------------------------------------
-LinearCharacteristics i2u(0.8f,-2.0f);
+//LinearCharacteristics i2u(0.8f,-2.0f);
+LinearCharacteristics i2u(-2.0f,2.0f,0.0f,3.2f);
 
 //------------------------------------------
 Ticker  ControllerLoopTimer;            // interrupt for control loop
@@ -61,8 +62,8 @@
 // ... 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 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 -----------------------------------------
 
@@ -89,19 +90,18 @@
 void updateControllers(void){
     short counts = counter1;            // get counts from Encoder
     float vel = diff(counts);           // motor velocity 
-     /* desTorque = pi_w(omega_desired - omega + excWobble);
-            outWobble = omega;
+      //desTorque = vel_cntrl(w_soll - vel);
+     /*       outWobble = omega;
             excWobble = Wobble(excWobble, outWobble); */
     
-    float torq_des = vel_cntrl(excWobble + w_soll - vel);
-    excWobble = gpa1(torq_des,vel);
+    float torq_des = vel_cntrl(w_soll - 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("Des. velocity: %3.3f, Velocity: %3.3f\r\n",w_soll,vel);
-    //}
+    if(++k >= 249){
+        k = 0;
+        pc.printf("Des. velocity: %3.3f, Velocity: %3.3f\r\n",w_soll,vel);
+    }
 }
 //******************************************************************************
 //********** User functions like buttens handle etc. **************