Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: MotorDriver.cpp
- Revision:
- 8:73c8188916dc
- Parent:
- 7:b5bf886ae13c
- Child:
- 11:68ee67d17320
- Child:
- 15:31d09ee65cf1
diff -r b5bf886ae13c -r 73c8188916dc MotorDriver.cpp --- a/MotorDriver.cpp Mon Apr 30 13:55:37 2018 +0000 +++ b/MotorDriver.cpp Mon May 07 16:30:51 2018 +0000 @@ -49,7 +49,7 @@ break; case 3: - Speed = 80.0f; + Speed = 60.0f; break; @@ -59,12 +59,12 @@ } //Fährt bis Anzahl umdrehungen erreicht sind - while(((abs(counterLeft.read())+abs(counterRight.read()))/2)<= 1000*NumbField) { + while(((abs(counterLeft.read())+abs(counterRight.read()))/2)<= 990*NumbField) { distance_side= readSensorValue(1); //Distanz zur linken Wand wird gemessen distance_front = readSensorValue(2); //Distanz zur vorderen Wand wird gemessen AnzahlZyklen = AnzahlZyklen+1; //Anzahl Regelvorgänge werden gezählt - distance_side = distance_side - 7.8f; //Distanz zwischen Position und Ideallinie wird berechnet - CorrectFactor = distance_side*0.8f; //P Faktor des P-Reglers + distance_side = distance_side - 6.9f; //Distanz zwischen Position und Ideallinie wird berechnet + CorrectFactor = distance_side*1.0f; //P Faktor des P-Reglers //printf("%f\n",CorrectFactor); if(abs(CorrectFactor) <= 5.0f) { //erkennt Wand oder Lücke auf linker Seite @@ -83,13 +83,13 @@ } stop(); - printf("Das Programm wurde: %d durchlaufen\n", AnzahlZyklen); + //printf("Das Programm wurde: %d durchlaufen\n", AnzahlZyklen); } int turnRight(int direction) { - controller.setDesiredSpeedLeft(15.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min - controller.setDesiredSpeedRight(15.0f); + controller.setDesiredSpeedLeft(40.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min + controller.setDesiredSpeedRight(40.0f); while(((abs(counterLeft.read())+abs(counterRight.read()))/2)<= 590) { //do nothing } @@ -104,8 +104,8 @@ int turnLeft(int direction) { - controller.setDesiredSpeedRight(-15.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min - controller.setDesiredSpeedLeft(-15.0f); + controller.setDesiredSpeedRight(-40.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min + controller.setDesiredSpeedLeft(-40.0f); while(((abs(counterLeft.read())+abs(counterRight.read()))/2)<= 590) { //do nothing }