Class Bertl added

Dependencies:   HCSR

Dependents:   BERTL_ButtonLeds Bertl_Arbeit FollowLine SerialPC ... more

Fork of ur_Bertl by BULME_BERTL_2CHEL

Files at this revision

API Documentation at this revision

Comitter:
bulmecisco
Date:
Fri May 08 08:39:12 2015 +0000
Parent:
13:3ce84646fd74
Commit message:
Version 3.0

Changed in this revision

config.h Show annotated file Show diff for this revision Revisions of this file
const.h Show annotated file Show diff for this revision Revisions of this file
ur_Bertl.cpp Show annotated file Show diff for this revision Revisions of this file
ur_Bertl.h Show annotated file Show diff for this revision Revisions of this file
diff -r 3ce84646fd74 -r 43d6a7e6e64a config.h
--- a/config.h	Mon Apr 27 13:13:45 2015 +0000
+++ b/config.h	Fri May 08 08:39:12 2015 +0000
@@ -18,7 +18,7 @@
 #define DEBUG 0
 //#define FRONTBUTTON       /**< Error shutoff if Bertl moves against a wall*/
 #define HCSR                /**< if ultrsonic is installed*/
-#define MOTORENC P1_12        /**< P1_12: left encoder P1_13: rigth encoder (motor) */
+#define MOTORENC P1_13        /**< P1_12: left encoder P1_13: rigth encoder (motor) */
 
 BusOut NibbleLEDs(P1_8, P1_9, P1_10, P1_11);   /**< 4 yellow LEDs as a bus defined; use it i.e.: karel.NibbleLeds(karel.GetLineValues()); to show line sensor values */
 DigitalOut LED_D10(P1_8);    /**<  wiring first LED_D10 */
@@ -34,13 +34,13 @@
 
 //------------------ CHANGE ONLY IF NESSESARY -------------------------------------
 
-DigitalOut MotorL_EN(p34);    // wiring motor left
-DigitalOut MotorL_FORWARD(P1_1);
-DigitalOut MotorL_REVERSE(P1_0);
+DigitalOut MotorL_EN(p34);          // wiring motor left
+DigitalOut MotorL_FORWARD(P1_1);    // change to P1_0 for Bertl 2015
+DigitalOut MotorL_REVERSE(P1_0);    // change to P1_1 for Bertl 2015
 
-DigitalOut MotorR_EN(p36);     // wiring motor right
-DigitalOut MotorR_FORWARD(P1_3);
-DigitalOut MotorR_REVERSE(P1_4);
+DigitalOut MotorR_EN(p36);          // wiring motor right
+DigitalOut MotorR_FORWARD(P1_3);    // change to P1_4 for Bertl 2015
+DigitalOut MotorR_REVERSE(P1_4);    // change to P1_3 for Bertl 2015
 
 I2C i2c(p28,p27);   
 BusIn linesensor(p18, p16, p19, p17);  
@@ -52,6 +52,11 @@
 
 Serial pc(USBTX, USBRX);      // tx, rx  
 
+// Bertl 2015
+DigitalOut MotorSpg (p30);
+DigitalOut IncrementalgeberSpg (P1_7);
+DigitalOut LinienSensorSpg (P1_6);
+
 #if defined(DEBUG) && DEBUG > 0
  #define DEBUG_PRINT(fmt, args...) fprintf(stderr, "DEBUG: %s:%d:%s(): " fmt, \
     __FILE__, __LINE__, __func__, ##args)
diff -r 3ce84646fd74 -r 43d6a7e6e64a const.h
--- a/const.h	Mon Apr 27 13:13:45 2015 +0000
+++ b/const.h	Fri May 08 08:39:12 2015 +0000
@@ -21,7 +21,7 @@
 /*! \var int SPEED
 \brief Bertl speed 0.2 (slow) - 1.0 (fast).
 \warning speed below 0.2 possible the motor won't start */
-const float SPEED = 0.2;    /*  Bertl speed 0.2 (slow) - 1.0 (fast) */
+const float SPEED = 0.4;    /*  Bertl speed 0.2 (slow) - 1.0 (fast) */
 /*! \var int DISTANCE
 \brief one wheel turn is appr. 24 ticks.
 \warning maybe the number has to be adjusted */
@@ -62,4 +62,5 @@
 const int West = 2; 
 const int North = 3;
 const int South = 4;
+
 #endif
\ No newline at end of file
diff -r 3ce84646fd74 -r 43d6a7e6e64a ur_Bertl.cpp
--- a/ur_Bertl.cpp	Mon Apr 27 13:13:45 2015 +0000
+++ b/ur_Bertl.cpp	Fri May 08 08:39:12 2015 +0000
@@ -16,6 +16,10 @@
 // Constructor
 ur_Bertl::ur_Bertl() : _interrupt(MOTORENC)         
 {
+    MotorSpg = 1;
+    IncrementalgeberSpg = 1;
+    LinienSensorSpg = 1;
+
     i2c.frequency(40000);                           // I2C init
     char init1[2] = {0x6, 0x00};
     char init2[2] = {0x7, 0xff};
@@ -41,16 +45,16 @@
 }
 
 // Pulblic methodes
-void ur_Bertl::Move(int move)
+void ur_Bertl::Move()
 {
     int count = _count;
     MotorR_EN=MotorL_EN=1;                  // both motor ENABLE
     MotorR_FORWARD = MotorL_FORWARD = 1;    // both motor forward ON
 #ifdef TIME
-    wait_ms(move);
+    wait_ms(MOVE);
 #else
 
-    while(_count < count+move) {
+    while(_count < count+DISTANCE) {        // DISTANCE maybe change to move
         //if(!FrontIsClear())       // more convenient because there are no accidents :-)
           //  break;
 #ifdef FRONTBUTTON
@@ -62,7 +66,7 @@
 #endif
     MotorR_FORWARD = MotorL_FORWARD = 0;    // both motor off
     MotorR_EN=MotorL_EN=0;
-    if(move == MOVE)
+    //if(move == MOVE)
         wait_ms(250);
 }
 
@@ -109,10 +113,16 @@
     wait_ms(250);           // only to step the robot
 }
 
-void ur_Bertl::ShutOff()
+void ur_Bertl::TurnOff()
 {
     MotorR_FORWARD = MotorL_FORWARD = 0;    // motor OFF
     MotorR_EN=MotorL_EN=0;                  // motor disable
+    MotorSpg = 0;
+    IncrementalgeberSpg = 0;
+    LinienSensorSpg = 0;
+    BlueLedsOFF();
+    TurnLedOff(LED_ALL);
+    NibbleLeds(0x00);
 }
 
 // Public LEDs methodes
diff -r 3ce84646fd74 -r 43d6a7e6e64a ur_Bertl.h
--- a/ur_Bertl.h	Mon Apr 27 13:13:45 2015 +0000
+++ b/ur_Bertl.h	Fri May 08 08:39:12 2015 +0000
@@ -148,11 +148,11 @@
     ur_Bertl(PinName pin);      /**< parameterized constructor; on what pin should the interrupt work; SPEED, DISTANCE or ANGLE have to bee defined in config.h */
 
     //void Move();                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
-    void Move(int move = MOVE);                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
+    void Move();                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
     void TurnLeft();            /**< Robot turns left as much as the constant ANGLE*/      
     void PutBeeper();           /**< if Robot has any Beepers in his bag he can put one or more Beeper; if not --> Error(()*/  
     void PickBeeper();          /**< if Robot stands on a black item he can pick one or more Beeper (max. 15 --> Error()); if not --> Error()*/   
-    void ShutOff();             /**<  turnes the robot off */
+    void TurnOff();             /**<  turnes the robot off */
     bool WaitUntilButtonPressed();  /**< wait until any button is pressed at the robot */
     bool FrontIsClear();        /**< returns a boolean value true if front is free; if not false */ 
     bool NextToABeeper();       /**< returns a boolean value true if the robot is on a black place or line; if not --> false */