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:
- 13:060d2a90d1c5
- Parent:
- 11:68ee67d17320
diff -r 811b1364679e -r 060d2a90d1c5 MotorDriver.cpp
--- a/MotorDriver.cpp Fri May 18 11:36:48 2018 +0000
+++ b/MotorDriver.cpp Tue May 22 09:25:06 2018 +0000
@@ -3,9 +3,6 @@
#include "ReadSensor.h"
#include "mbed.h"
-#define WheelDiameter 3;
-#define ratio 0.04;
-
DigitalOut enableMotorDriver(PB_2);
DigitalIn motorDriverFault(PB_14);
DigitalIn motorDriverWarning(PB_15);
@@ -24,8 +21,8 @@
void startup (void)
{
- enableMotorDriver = 1; // Schaltet den Leistungstreiber ein
- counterLeft.reset();
+ enableMotorDriver = 1; //Schaltet den Motortreiber ein
+ counterLeft.reset(); //Counter reseten
counterRight.reset();
}
@@ -38,7 +35,7 @@
float CorrectFactor;
float Speed = 0.0f;
- switch(SpeedMode) {
+ switch(SpeedMode) { //Geschwindigkeit einstellen
case 1:
Speed = 20.0f;
break;
@@ -70,7 +67,7 @@
}
else
{
- distance_side= readSensorValue(3); //Distanz zur linken Wand wird gemessen
+ distance_side= readSensorValue(3); //Distanz zur rechten Wand wird gemessen
AnzahlZyklen = AnzahlZyklen+1; //Anzahl Regelvorgänge werden gezählt
distance_side = distance_side - 6.9f; //Distanz zwischen Position und Ideallinie wird berechnet
CorrectFactor = distance_side*-2.0f; //P Faktor des P-Reglers
@@ -94,10 +91,10 @@
}
stop();
- //printf("Das Programm wurde: %d durchlaufen\n", AnzahlZyklen);
+
}
-
-int turnRight(int direction)
+//Rechts abbiegen
+int turnRight(int direction)
{
controller.setDesiredSpeedLeft(40.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min
controller.setDesiredSpeedRight(40.0f);
@@ -112,7 +109,7 @@
}
return direction;
}
-
+//links abbigen
int turnLeft(int direction)
{
controller.setDesiredSpeedRight(-40.0f); // Drehzahl in [rpm] bei 31/1 enspricht es ca. 374/min
@@ -129,7 +126,7 @@
return direction;
}
-
+//Roboter anhalten
void stop(void)
{
controller.setDesiredSpeedRight(0.0f);