Regler von Kellep15

Dependencies:   mbed

Revision:
2:394782101261
Parent:
1:92f175969d90
--- a/main.cpp	Fri May 10 14:25:24 2019 +0000
+++ b/main.cpp	Thu May 16 15:34:29 2019 +0000
@@ -35,9 +35,11 @@
 void updateLoop(void);   // loop for State machine (via interrupt)
 float Ts = 0.0005f;                     // sample time of main loop
 uint16_t k = 0;
+float w = 1; 
 // initiate PIDT1 controller objects
-// ???
-// ???
+PID_Cntrl dt1(0.0, 0.0, 0.0116, 0.000625, Ts, -3.0, 3.0);
+PID_Cntrl pi1(3.59, 13.5, 0.0, 1.0, Ts, -3.0, 3.0);
+// 
 //******************************************************************************
 //---------- main loop -------------
 //******************************************************************************
@@ -61,13 +63,14 @@
     float i_des = 0.0f;         // default: set motor current to zero (will be overwritten)
     if(controller_active) {
         // controller update
-        // ???
+        i_des = -dt1(x);
+        //i_des = pi1(w-x)-dt1(x); 
     }
     out.write(i2u(i_des));
     if(++k>1000) {
         pc.printf("x: %1.3f, i: %1.4f\r\n",x,i_des);
         k = 0;
-
+        w = -w;
     }
 } // END OF updateLoop(void)
 
@@ -91,7 +94,7 @@
         if(controller_active) {
             pc.printf("Controller actived\r\n");
             // reset controller here!!!
-            // ???
+            dt1.reset(0.0);
         } else
             pc.printf("Controller disabled\r\n");
     }