for Bertl2014 HTL-Graz-Göoesting

Files at this revision

API Documentation at this revision

Comitter:
hemmer_matthias
Date:
Mon Jan 18 10:36:13 2016 +0000
Parent:
1:18c4a2bc1228
Commit message:
K?ck;

Changed in this revision

Steuerung.cpp Show diff for this revision Revisions of this file
Steuerung.h Show diff for this revision Revisions of this file
Steuerung_PWM.cpp Show annotated file Show diff for this revision Revisions of this file
Steuerung_PWM.h Show annotated file Show diff for this revision Revisions of this file
--- a/Steuerung.cpp	Mon Jan 11 12:16:19 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-#include "mbed.h"
-
-// decleration for left engine
-PwmOut MotorL_EN(P1_15);    
-DigitalOut MotorL_FORWARD(P1_1);   
-DigitalOut MotorL_REVERSE(P1_0); 
-  
-// decleration for right engine
-PwmOut MotorR_EN(P0_21);     
-DigitalOut MotorR_FORWARD(P1_3); 
-DigitalOut MotorR_REVERSE(P1_4);
-
-void period_ms(int ms) 
-{
-    MotorL_EN.period_ms(ms);
-    MotorR_EN.period_ms(ms);
-}
-
-void bertl_engine(int left, int right, int seconds)
-{          
-    
-   /* int index_Engine = 0;
-                
-    // decleration for left and right engine
-         if (left > 0 && right > 0)  
-            index_Engine = 1;
-        
-        else if (left < 0 && right > 0)
-            index_Engine = 2;
-    
-        else if (left > 0 && right < 0)
-            index_Engine = 3;
-        
-        else if (left < 0 && right < 0)
-            index_Engine = 4;
-    
-        else if (left == 0 && right < 0)
-            index_Engine = 5;
-     
-        else if (left == 0 && right > 0)
-             index_Engine = 6;    
-        
-        else if (left < 0 && right == 0)
-             index_Engine = 7;
-    
-        else if (left > 0 && right == 0)
-             index_Engine = 8;
-        else
-            index_Engine = 9;    
-             
-switch (index_Engine)  //begin Switch
-   { 
-        case 1:
-            MotorR_EN.pulsewidth_ms(seconds); 
-            MotorL_EN.pulsewidth_ms(seconds);
-            MotorL_REVERSE = 0;
-            MotorR_REVERSE = 0;
-            MotorL_FORWARD = 1;
-            MotorR_FORWARD = 1;    
-       
-        break;
-            
-        case 2:
-            MotorR_EN = 1;
-            MotorL_EN = 1;
-            MotorL_FORWARD = 0;
-            MotorR_REVERSE = 0;
-            MotorL_REVERSE = 1;
-            MotorR_FORWARD = 1;           
-        break;
-
-        case 3:
-            MotorR_EN = 1;
-            MotorL_EN = 1;
-            MotorL_REVERSE = 0;
-            MotorR_FORWARD = 0;
-            MotorL_FORWARD = 1;
-            MotorR_REVERSE = 1;            
-        break;
-            
-        case 4:
-            MotorR_EN = 1;
-            MotorL_EN = 1;
-            MotorL_FORWARD = 0;
-            MotorR_FORWARD = 0;
-            MotorL_REVERSE = 1;
-            MotorR_REVERSE = 1;       
-        break;  
-            
-        case 5:
-            MotorL_EN = 0;
-            MotorR_EN = 1;
-            MotorR_FORWARD = 0;
-            MotorR_REVERSE = 1;
-        break;  
-        
-        case 6:
-            MotorL_EN = 0;
-            MotorR_EN = 1;
-            MotorR_REVERSE = 0;
-            MotorR_FORWARD = 1;
-        break; 
-    
-         case 7:
-            MotorR_EN = 0;
-            MotorL_EN = 1;
-            MotorL_FORWARD = 0;
-            MotorL_REVERSE = 1;          
-        break;    
- 
-         case 8:
-            MotorR_EN = 0;
-            MotorL_EN = 1;
-            MotorL_REVERSE = 0;
-            MotorL_FORWARD = 1;                    
-         break;    
-         
-        case 9:
-            MotorR_EN = 0;
-            MotorL_EN = 0;
-         break;
-    }//end Switch */
-}//end bertl_engine 
\ No newline at end of file
--- a/Steuerung.h	Mon Jan 11 12:16:19 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-
-void bertl_engine (int left, int right, int seconds); // underprogramm
-void period_ms(int ms);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Steuerung_PWM.cpp	Mon Jan 18 10:36:13 2016 +0000
@@ -0,0 +1,122 @@
+#include "mbed.h"
+
+// decleration for left engine
+PwmOut MotorL_EN(P1_15);    
+DigitalOut MotorL_FORWARD(P1_1);   
+DigitalOut MotorL_REVERSE(P1_0); 
+  
+// decleration for right engine
+PwmOut MotorR_EN(P0_21);     
+DigitalOut MotorR_FORWARD(P1_3); 
+DigitalOut MotorR_REVERSE(P1_4);
+
+void period_us(int periode)     // underprogramm fot the periode
+{
+    MotorL_EN.period_us(periode);        // declaration for the Periode of the left egngine
+    MotorR_EN.period_us(periode);        // declaration for the Periode of the right egngine
+}
+
+void bertl_engine(int left, int right)
+{             
+   int index_Engine = 0;    // agrument for the Switch
+                
+    // decleration for left and right engine
+         if (left > 0 && right > 0)             // all arguments are positive
+            index_Engine = 1;
+        
+        else if (left < 0 && right > 0)         // left argument is negative and right is positive
+            index_Engine = 2;
+    
+        else if (left > 0 && right < 0)         // left argument is positive and right is negative
+            index_Engine = 3;
+            
+        else if (left < 0 && right < 0)         // left argument is negative and right is negative
+            index_Engine = 4;
+    
+        else if (left == 0 && right < 0)        // left argument is zero and right is negative
+            index_Engine = 5;
+     
+        else if (left == 0 && right > 0)        // left argument is zero and right is positive
+             index_Engine = 6;    
+        
+        else if (left < 0 && right == 0)        // left argument is negative and right is is zero
+             index_Engine = 7;
+    
+        else if (left > 0 && right == 0)        // left argument is positive and right is is zero
+             index_Engine = 8;
+        else                                    // all egines are zero
+            index_Engine = 9;    
+             
+switch (index_Engine)  //begin Switch
+   { 
+        case 1:
+            MotorR_EN.pulsewidth_us(right);         // to declratate the speed of the right engine (-us - +us)
+            MotorL_EN.pulsewidth_us(left);          // to declratate the speed of the left engine (-us - +us)
+            MotorL_REVERSE = 0;
+            MotorR_REVERSE = 0;
+            MotorL_FORWARD = 1;
+            MotorR_FORWARD = 1;    
+       
+        break;
+            
+        case 2:
+            MotorR_EN.pulsewidth_us(right); 
+            MotorL_EN.pulsewidth_us(-left);
+            MotorL_FORWARD = 0;
+            MotorR_REVERSE = 0;
+            MotorL_REVERSE = 1;
+            MotorR_FORWARD = 1;           
+        break;
+
+        case 3:
+            MotorR_EN.pulsewidth_us(-right); 
+            MotorL_EN.pulsewidth_us(left);
+            MotorL_REVERSE = 0;
+            MotorR_FORWARD = 0;
+            MotorL_FORWARD = 1;
+            MotorR_REVERSE = 1;            
+        break;
+            
+        case 4:
+            MotorR_EN.pulsewidth_us(-right); 
+            MotorL_EN.pulsewidth_us(-left);
+            MotorL_FORWARD = 0;
+            MotorR_FORWARD = 0;
+            MotorL_REVERSE = 1;
+            MotorR_REVERSE = 1;       
+        break;  
+            
+        case 5:
+            MotorL_EN = 0;
+            MotorR_EN.pulsewidth_us(-right); 
+            MotorR_FORWARD = 0;
+            MotorR_REVERSE = 1;
+        break;  
+        
+        case 6:
+            MotorL_EN = 0;
+            MotorR_EN.pulsewidth_us(right); 
+            MotorR_REVERSE = 0;
+            MotorR_FORWARD = 1;
+        break; 
+    
+         case 7:
+            MotorR_EN = 0; 
+            MotorL_EN.pulsewidth_us(-left);
+            MotorL_FORWARD = 0;
+            MotorL_REVERSE = 1;          
+        break;    
+ 
+         case 8:
+            MotorR_EN = 0;
+            MotorL_EN.pulsewidth_us(left);
+            MotorL_REVERSE = 0;
+            MotorL_FORWARD = 1;                    
+         break;    
+         
+        case 9:
+            MotorR_EN = 0;
+            MotorL_EN = 0;
+         break;
+    }//end Switch 
+}//end bertl_engine 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Steuerung_PWM.h	Mon Jan 18 10:36:13 2016 +0000
@@ -0,0 +1,3 @@
+
+void bertl_engine (int left, int right); // underprogramm for the engines
+void period_us(int periode);    // underprogramm for the periode
\ No newline at end of file