Inverted Pendulum / Mbed 2 deprecated IP-Interface

Dependencies:   mbed QEI

Revision:
13:ab5a6ab6c492
Parent:
11:ed9539245ea0
Child:
15:a0b5c4306246
Child:
16:b5862ba97453
--- a/main.cpp	Mon Nov 14 21:00:01 2016 +0000
+++ b/main.cpp	Wed Nov 16 00:01:15 2016 +0000
@@ -1,6 +1,7 @@
 #include "QEI.h"
 #include "Motor.h"
 #include "pot.h"
+#include <time.h>
  
 Serial pc(USBTX, USBRX);
 //Use X4 encoding.
@@ -40,6 +41,29 @@
     }       
 }
 
+void test_speed() {
+    time_t start;
+    double elapsed_time = 0;
+    int steps = 10;
+    int wait = 1000;
+    printf("steps: %i\r\n", steps);
+            for( int i = 0; i < 3; i++){
+                encoder.reset();
+                start = time(0);
+                motor.step_clockwise(steps, wait);
+                elapsed_time = difftime( time(0), start);
+                printf("Round %i clockwise, Total duration: \t%f seconds\r\n", i, elapsed_time);
+                wait_ms(200);
+                
+                encoder.reset();
+                start = time(0);
+                motor.step_anticlockwise(steps, wait);
+                elapsed_time = difftime( time(0), start);
+                printf("Round %i counter-clockwise, Total duration: \t%f seconds\r\n", i, elapsed_time);
+                wait_ms(200);
+            }
+}
+
 
 void test_pendulum(){
     while(1){