Joao Luiz Almeida de Souza Ramos / Mbed 2 deprecated furutacontroller

Dependencies:   QEI mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
jaoramos
Date:
Wed Dec 04 20:26:08 2013 +0000
Parent:
12:d09b8ffa176f
Commit message:
swing up and swing down

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Dec 04 04:36:27 2013 +0000
+++ b/main.cpp	Wed Dec 04 20:26:08 2013 +0000
@@ -15,7 +15,7 @@
 #define BUFFER_SIZE 4200
 #define MAX_VOLTAGE 3.3
 #define VOLTS_PER_AMP 0.14
-#define PROGRAM_RUNTIME 15.0
+#define PROGRAM_RUNTIME 30.0
 
 Serial pc(USBTX, USBRX);
 
@@ -153,7 +153,7 @@
         {
             // z1 and z2 are in the beginning the same as the angle so that dtheta1 and dtheta2 are zero
             z1 = theta1;
-            z2 = 1.001*theta2;
+            z2 = 1.002*theta2;
             firstTime = false;
         }
         //calculate dtheta1 
@@ -191,6 +191,10 @@
             inputVoltage = -(k1*theta1 + k2*theta2 + k3*dtheta1 + k4*dtheta2 + k5*mCurrent);
         }
         
+        //Swing-Down
+        if (t > PROGRAM_RUNTIME - 5.0)
+            inputVoltage = 1.8*dtheta2*(0.0372 - currentEnergy); 
+        
         setVoltage(inputVoltage);
         
         t0 = t;