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: btbee m3pi_ng mbed FatFileSystem MSCFileSystem
Diff: main.cpp
- Revision:
- 15:3e3f1b42cc23
- Parent:
- 14:5b3cc7741bdf
- Child:
- 16:caa77287cc25
--- a/main.cpp Mon Jun 01 09:33:43 2015 +0000
+++ b/main.cpp Mon Jun 01 11:25:46 2015 +0000
@@ -18,7 +18,7 @@
DigitalIn m3pi_IN[]= {(p12),(p21)}; // IR sensor and Knopf
Timer timer;
Timer time_wait;
-#define MAX .35
+#define MAX .95
#define MIN 0
#define PI 3.14159265
@@ -30,9 +30,9 @@
int main()
{
- float P_TERM = 1;
- float I_TERM = 0;
- float D_TERM = 0;
+ float P_TERM = 2.5;
+ float I_TERM = .5;
+ float D_TERM = 25;
btbee.reset();
robot.sensor_auto_calibrate();
@@ -64,16 +64,16 @@
vector<float> Uvalue, lineposval, setPointVals;
vector<float> sweepData;
FILE *fp = fopen( "/" FSNAME "/data.txt", "w");
- FILE *sweep = fopen("/" FSNAME "/sweep1.txt","r");
+ //FILE *sweep = fopen("/" FSNAME "/sweep1.txt","r");
//Manual implementation of sweep function
- if (sweep == NULL){
+ /*if (sweep == NULL){
robot.printf("Nope.");
y = 0;
- }
+ }*/
/* for (int i = 0; i <5; ++i)
@@ -119,13 +119,14 @@
}
else if (lap == 1) {
+ robot.printf("Success.");
robot.stop();
robot.printf("Size: %d", Uvalue.size());
if(fp != NULL){
for (int i = 0; i < Uvalue.size(); ++i)
fprintf(fp,"%f %f %f\n", setPointVals[i], Uvalue[i], lineposval[i]);
fclose(fp);
- fclose(sweep);
+ //fclose(sweep);
robot.cls();
robot.locate(0,0);
robot.printf("Doner");
@@ -157,6 +158,7 @@
count = 0;
timer.stop();
timer.reset();
+ y = 0;
continue;
} else {
@@ -204,15 +206,16 @@
current_pos = robot.line_position();
- if (fgets(sweepValue, 100, sweep) != NULL){
+ //if (fgets(sweepValue, 100, sweep) != NULL){
- proportional = atof(sweepValue) + current_pos;
+ // proportional = atof(sweepValue) + current_pos;
+ proportional = current_pos;
- }
+ /* }
else{
fclose(sweep);
FILE *sweep = fopen("/" FSNAME "/sweep1.txt","r");
- }
+ }*/
derivative = current_pos - previous_pos;
@@ -252,7 +255,7 @@
//btbee.printf("%f %f %f\n", left, right, robot.line_position());
Uvalue.push_back(power);
lineposval.push_back(robot.line_position());
- setPointVals.push_back(atof(sweepValue));
+ setPointVals.push_back(0);
//}