update
Dependencies: Stepper mbed SDFileSystem Ultrasonic PinDetect millis
Diff: main.cpp
- Revision:
- 4:63f0989c8d1e
- Parent:
- 3:fd2ca631ab44
- Child:
- 6:354264d1e4bb
--- a/main.cpp Sat Oct 13 02:19:16 2018 +0000 +++ b/main.cpp Fri Nov 16 21:42:21 2018 +0000 @@ -19,7 +19,7 @@ { unsigned int dist; int er = 5; - int fp = 448; //adjust if needed + int fp = 457; //adjust if needed int lp = 64; //adjust if needed int tp = 25; @@ -123,8 +123,8 @@ { unsigned int path_dist; - int err = 8; - int sens_pos = 148; //adjust if needed //535 0 plates + int err = 11; + int sens_pos = 126; //adjust if needed //535 0 plates int sheet_th = 25; pathsensor.start(); wait_ms(500); @@ -132,7 +132,7 @@ pc.printf("\nBeam Path Sensor : %ld",path_dist); path_sheets = 17; - if (path_dist >= sens_pos-err && path_dist <= sens_pos+err){ //127,143 a:152 + if (path_dist >= sens_pos-err && path_dist <= sens_pos+err){ //110,130 path_sheets = 16; } @@ -192,11 +192,11 @@ path_sheets = 2; } - if (path_dist >= sens_pos-err+15*sheet_th && path_dist <= sens_pos+err+15*sheet_th){ + if (path_dist >= sens_pos-10-err+15*sheet_th && path_dist <= sens_pos-10+err+15*sheet_th){//greater than 509 less 517 path_sheets = 1; } - if (path_dist > sens_pos-err+16*sheet_th){ + if (path_dist > sens_pos-err+16*sheet_th){ //greater than 534 path_sheets = 0; } } @@ -243,7 +243,7 @@ { in1=1; in2=0; - wait(17); + wait(14); in1=1; in2=1; } @@ -301,42 +301,18 @@ wait(0.1); internalpullups(); wait(0.1); - char command[15] = {0}; - pc.printf("\nCommands:\n\n\ts [N]\t**moves N PMMA sheets in beam path\n\tr\t\t**removes all PMMA from beam path\n\tc [N]\t**raises bar to \n\tb\t\t**reports number of plates in beam path\n\n"); while(1) { - pc.printf("\nRequests: "); - pc.scanf("%s",&command); - - if (strcmp (command, "s") == 0) - { - pc.scanf(" %d",&plates); + + plates = (rand() % 16) + 1; + wait(2); pc.printf("\nresponse recieved |"); send_error_check(); beam(); platedetect(); - } - else if (strcmp (command, "r") == 0) - { - pc.printf("\nresponse recieved |"); + wait(2); retract_error_check(); - } - else if (strcmp (command, "c") == 0) - { - pc.scanf(" %d",&plates); - pc.printf("\nresponse recieved |"); - select_error_check(); + wait(2); } - else if (strcmp (command, "b") == 0) - { - pc.printf("\nresponse recieved |"); - beam(); - platedetect(); - } - else - { - pc.printf("\nERROR: Invalid Command"); - } - } -} \ No newline at end of file + } \ No newline at end of file