Explorar el Código

add debug mode that keeps uv leds on longer.

Thomas Buck hace 2 años
padre
commit
72a8108141
Se han modificado 2 ficheros con 29 adiciones y 0 borrados
  1. 3
    0
      firmware/OpenChrono/config.h
  2. 26
    0
      firmware/OpenChrono/timing.cpp

+ 3
- 0
firmware/OpenChrono/config.h Ver fichero

@@ -102,6 +102,9 @@
102 102
 #define MIN_SPEED 0.3 /* in m/s */
103 103
 #define MAX_SPEED 2000.0 /* in m/s */
104 104
 
105
+// enable to keep UV LED on 100x as long
106
+//#define DEBUG_LONG_UV_TIME
107
+
105 108
 // --------------------------------------
106 109
 
107 110
 // placeholder data for debugging purposes

+ 26
- 0
firmware/OpenChrono/timing.cpp Ver fichero

@@ -31,6 +31,10 @@
31 31
 volatile uint8_t trigger_a = 0, trigger_b = 0;
32 32
 volatile uint16_t time_a = 0, time_b = 0;
33 33
 
34
+#ifdef DEBUG_LONG_UV_TIME
35
+volatile static uint8_t led_runs = 0;
36
+#endif
37
+
34 38
 void interrupt_init() {
35 39
     // trigger both on rising edge
36 40
     EICRA = (1 << ISC00) | (1 << ISC01);
@@ -130,11 +134,33 @@ void timer_start() {
130 134
     // initial value we count up from
131 135
     TCNT2 = 0xFF - pulse_length;
132 136
 
137
+#ifdef DEBUG_LONG_UV_TIME
138
+    led_runs = 0;
139
+#endif
140
+
133 141
     // prescaler 64
134 142
     TCCR2B = (1 << CS22);
135 143
 }
136 144
 
137 145
 ISR(TIMER2_OVF_vect) {
146
+    /*
147
+     * When a BB is only dropped through the device it moves
148
+     * with something like 0.1m/s to 1m/s of velocity.
149
+     * So in this case it only moves the 7.5mm to the UV LEDs
150
+     * in 75ms to 7.5ms respectively.
151
+     * So our 1ms pulse is not illuminating it at all!
152
+     * In this case, we have to increase our pulse time by
153
+     * approx. factor 100.
154
+     */
155
+#ifdef DEBUG_LONG_UV_TIME
156
+    led_runs++;
157
+    if (led_runs < 100) {
158
+        // keep running for another millisecond
159
+        TCNT2 = 0xFF - 250;
160
+        return;
161
+    }
162
+#endif
163
+
138 164
     // turn off UV LED
139 165
     digitalWrite(UV_LED_PIN, LOW);
140 166
 

Loading…
Cancelar
Guardar