Some small cleanups and fixes to shooter stuff.
diff --git a/bot3/input/gyro_sensor_receiver.cc b/bot3/input/gyro_sensor_receiver.cc
index 784827c..81e4190 100644
--- a/bot3/input/gyro_sensor_receiver.cc
+++ b/bot3/input/gyro_sensor_receiver.cc
@@ -32,6 +32,10 @@
}
inline double shooter_translate(int32_t in) {
+ LOG(DEBUG, "raw %" PRId32 "\n", in);
+ if (in == 0) {
+ return 0;
+ }
return 1.0 / (static_cast<double>(in) / (10 ^ 8)/*ticks per sec*/)
/ (1 - (kTapeThickness / (2 * kWheelRadius * M_PI))) * (2 * M_PI);
}
@@ -63,6 +67,7 @@
.left_encoder(0)
.Send();*/
+ LOG(DEBUG, "shooter: %f\n", shooter_translate(data()->bot3.shooter_cycle_ticks));
shooter.position.MakeWithBuilder()
.velocity(shooter_translate(data()->bot3.shooter_cycle_ticks))
.Send();
diff --git a/gyro_board/src/usb/encoder.c b/gyro_board/src/usb/encoder.c
index df1031f..45374e9 100644
--- a/gyro_board/src/usb/encoder.c
+++ b/gyro_board/src/usb/encoder.c
@@ -79,7 +79,8 @@
}
static inline void reset_TC(void) {
- TIM2->TCR |= (1 << 1); // Put it into reset.
+ TIM2->TCR = (1 << 1); // Put it into reset and disabled.
+ while (TIM2->TC != 0);
TIM2->TCR = 1; // Take it out of reset + make sure it's enabled.
}
@@ -91,7 +92,7 @@
// Capture
TIM2->IR = (1 << 4); // Clear the interrupt.
- shooter_cycle_ticks = TIM2->CR0;
+ shooter_cycle_ticks = TIM2->CR0 + 2;
reset_TC();
} else if (TIM2->IR & 1) {
@@ -99,10 +100,10 @@
TIM2->IR = 1; // Clear the interrupt
// Assume shooter is stopped.
- shooter_cycle_ticks = 0;
+ //shooter_cycle_ticks = 1;
// Disable timer.
- TIM2->TCR = 0;
+ //TIM2->TCR = 0;
}
// It will only handle one interrupt per run.
@@ -445,8 +446,6 @@
// Set up timer for bot3 photosensor.
// Make sure timer two is powered.
SC->PCONP |= (1 << 22);
- // Rate of clock signal is just CCLK.
- SC->PCLKSEL1 |= (1 << 12);
// Select capture 2.0 function on pin 0.4.
PINCON->PINSEL0 |= (0x3 << 8);
// Set timer to capture and interrupt on rising edge.