|
@@ -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
|
|