GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Files at this revision

API Documentation at this revision

Comitter:
spm71
Date:
Fri Apr 27 20:14:21 2018 +0000
Parent:
77:73e1cf3a7284
Commit message:
Finished

Changed in this revision

analog.h Show annotated file Show diff for this revision Revisions of this file
stepper.cpp Show annotated file Show diff for this revision Revisions of this file
stepper.h Show annotated file Show diff for this revision Revisions of this file
wag.cpp Show annotated file Show diff for this revision Revisions of this file
wag.h Show annotated file Show diff for this revision Revisions of this file
--- a/analog.h	Thu Apr 26 16:12:09 2018 +0000
+++ b/analog.h	Fri Apr 27 20:14:21 2018 +0000
@@ -18,7 +18,7 @@
 #include "io_pins.h"
 
 #define MUX_CHANS 16
-#define PTTHRESH 1.3 /// previously 2.0
+#define PTTHRESH 0.7 /// previously 2.0
 
 void ana_init();
 void ana_scan_mux(float * an_array, int no_of_channels);
--- a/stepper.cpp	Thu Apr 26 16:12:09 2018 +0000
+++ b/stepper.cpp	Fri Apr 27 20:14:21 2018 +0000
@@ -99,7 +99,7 @@
             index++;
         wait(MOTOR_DELAY);
         spi_send(drv8806, turn[index]);
-        wait(TURN_DELAY);
+        //wait(TURN_DELAY);
     } else if (direction == STP_CCW) {
 
         if (stp_cur_pos != 0) {
@@ -117,7 +117,7 @@
             index--;
         wait(MOTOR_DELAY);
         spi_send(drv8806, turn[index]);
-        wait(TURN_DELAY);
+        //wait(TURN_DELAY);
     }
     wait(MOTOR_DELAY);
 }
--- a/stepper.h	Thu Apr 26 16:12:09 2018 +0000
+++ b/stepper.h	Fri Apr 27 20:14:21 2018 +0000
@@ -23,7 +23,7 @@
 #define STP_CCW 1
 #define STP_POS_UNKN -5
 #define TGT_SENSOR_QUAN 8
-#define MOTOR_DELAY 0.002
+#define MOTOR_DELAY 0.003
 #define TURN_DELAY 0.005
 
 
--- a/wag.cpp	Thu Apr 26 16:12:09 2018 +0000
+++ b/wag.cpp	Fri Apr 27 20:14:21 2018 +0000
@@ -73,6 +73,7 @@
             //pc.printf("led_command: %d\n", led_command);
             spi_send(as1107, led_command); // light up LED
             //pc.printf("done sent\n");
+            pc.printf("led_command: %d\n", led_command);
             wait(LED_DELAY);
             // NOTE: must put a wait() here or else the led won't light up
         } 
@@ -99,8 +100,8 @@
         if (sensor_values[whacker_no + a_num] * 3.3 > PTTHRESH) {
             hit++; // increment hit count
             pc.printf("Hit\n");
-            while(sensor_values[whacker_no + a_num] * 3.3 > PTTHRESH)
-                ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // waits for whacker laser to turn off
+            //while(sensor_values[whacker_no + a_num] * 3.3 > PTTHRESH)
+              //  ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // waits for whacker laser to turn off
         }
 
         else {
@@ -185,9 +186,10 @@
                 while (1);
             }
         }
-    
+        
+        pc.printf("stp_sensor_pos: %d\n", stp_sensor_pos[sensor_no + gnoll_sensor_indicator]);
         // point whack’s laser to the corresponding sensor on whack target array
-        turn_to_target(stp_sensor_pos[gnoll_no + gnoll_sensor_indicator ]);
+        turn_to_target(stp_sensor_pos[sensor_no + gnoll_sensor_indicator]);
     
         // turn on whacker's laser
         lzr_on();
@@ -205,7 +207,7 @@
                 if (sensor_values[i + sensor_no] * 3.3f > PTTHRESH) {
                     sensor_registered = true;
                     whack_sensor_indicator = i;
-                    pc.printf("gnoll_sensor_indicator: %d\n", gnoll_sensor_indicator);
+                    pc.printf("whack_sensor_indicator: %d\n", whack_sensor_indicator);
                 }
             }
     
@@ -220,7 +222,9 @@
     
         // activate corresponding indicator in whack LED row
         led_command = 0x0500 + led_values[whack_sensor_indicator];
+        pc.printf("led_command: %d\n", led_command);
         spi_send(as1107, led_command);
+        wait(LED_DELAY);
     
         // waiting for gnoll laser to turn off to turn off
         do {
--- a/wag.h	Thu Apr 26 16:12:09 2018 +0000
+++ b/wag.h	Fri Apr 27 20:14:21 2018 +0000
@@ -35,7 +35,7 @@
 #define NOT_CALIBRATED 0
 
 //delay times
-#define VOLLEY_DELAY 3000
+#define VOLLEY_DELAY 1000
 #define LASER_DELAY 0.125
 #define LED_DELAY 0.02