Cornelius Bezuidenhout / Mbed OS Heiko

Dependencies:   BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG SDFileSystem TS_DISCO_F746NG ResistiveTouchController Map CYS8218Controller MedianFilter

Files at this revision

API Documentation at this revision

Comitter:
Kerneels Bezuidenhout
Date:
Wed Oct 19 22:13:09 2016 +0200
Parent:
60:b6352a55d850
Child:
62:58e846621435
Commit message:
hg update

Changed in this revision

Screens/AutomaticMoreScreen.cpp Show annotated file Show diff for this revision Revisions of this file
Screens/AutomaticSettingsScreen.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Screens/AutomaticMoreScreen.cpp	Wed Oct 19 20:07:26 2016 +0000
+++ b/Screens/AutomaticMoreScreen.cpp	Wed Oct 19 22:13:09 2016 +0200
@@ -4,8 +4,8 @@
   Screen(),
   _lbTitle( SCREEN_W/2, 0, "More", Label::CENTER, Font24),
   _btBack(0,SCREEN_H-30,100,30,"Back"),
-  _btManualSP(0, 27, SCREEN_W, 30, "Manual Tracking"),
-  _btSquare(0,27+35, SCREEN_W, 30, "Square")
+  _btManualSP(0, 27, SCREEN_W/2-5, SCREEN_H-35-27, "Manual Tracking"),
+  _btSquare(SCREEN_W/2+5,27, SCREEN_W/2-5, SCREEN_H-35-27, "Square")
 {
   _nextScreen = nextScreen;
 }
--- a/Screens/AutomaticSettingsScreen.cpp	Wed Oct 19 20:07:26 2016 +0000
+++ b/Screens/AutomaticSettingsScreen.cpp	Wed Oct 19 22:13:09 2016 +0200
@@ -10,8 +10,8 @@
   _btI(SCREEN_W/2, 61, 100, 30, "Change"),
   _nlbD(0,96, "D =%.3f", *D, Label::LEFT, Font20),
   _btD(SCREEN_W/2, 96, 100, 30, "Change"),
-  _nlbTs(0,131, "Sample Time (ms)=%.0f", *Ts,  Label::LEFT, Font20),
-  _btTs(SCREEN_W/2, 155, 100, 30, "Change")
+  _nlbTs(0,131, "Ts (ms)=%.0f", *Ts,  Label::LEFT, Font20),
+  _btTs(SCREEN_W/2, 131, 100, 30, "Change")
   //TODO Improve layout of this screen
 {
   _nextScreen = nextScreen;
--- a/main.cpp	Wed Oct 19 20:07:26 2016 +0000
+++ b/main.cpp	Wed Oct 19 22:13:09 2016 +0200
@@ -45,9 +45,9 @@
 
 
 //-- Controller Variables
-float P = 0;
+float P = 0.1;
 float I = 0;
-float D = 0;
+float D = 10;
 float Ts = 0.004;
 Timer cycleTimer;
 //-----------------------
@@ -106,8 +106,9 @@
         Automatic();
         break;
       default :
-        xMotor.Off();
-        yMotor.Off();
+        xMotor.Set(0);
+        yMotor.Set(0);
+        Thread::wait(20);
         break;
     }
   }
@@ -257,6 +258,11 @@
     xMotor.Set(alpha);
     yMotor.Set(-beta);
 
+    if( Ts > 0)
+      Ts /= 1000;
+
+    while( cycleTimer.read() > Ts);
+
     cycleTimer.stop();
     measuredTs = cycleTimer.read_ms();
     cycleTimer.reset();