Browse Source

add debug mode that keeps uv leds on longer.

Thomas Buck 1 year ago
parent
commit
72a8108141
2 changed files with 29 additions and 0 deletions
  1. 3
    0
      firmware/OpenChrono/config.h
  2. 26
    0
      firmware/OpenChrono/timing.cpp

+ 3
- 0
firmware/OpenChrono/config.h View File

102
 #define MIN_SPEED 0.3 /* in m/s */
102
 #define MIN_SPEED 0.3 /* in m/s */
103
 #define MAX_SPEED 2000.0 /* in m/s */
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
 // placeholder data for debugging purposes
110
 // placeholder data for debugging purposes

+ 26
- 0
firmware/OpenChrono/timing.cpp View File

31
 volatile uint8_t trigger_a = 0, trigger_b = 0;
31
 volatile uint8_t trigger_a = 0, trigger_b = 0;
32
 volatile uint16_t time_a = 0, time_b = 0;
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
 void interrupt_init() {
38
 void interrupt_init() {
35
     // trigger both on rising edge
39
     // trigger both on rising edge
36
     EICRA = (1 << ISC00) | (1 << ISC01);
40
     EICRA = (1 << ISC00) | (1 << ISC01);
130
     // initial value we count up from
134
     // initial value we count up from
131
     TCNT2 = 0xFF - pulse_length;
135
     TCNT2 = 0xFF - pulse_length;
132
 
136
 
137
+#ifdef DEBUG_LONG_UV_TIME
138
+    led_runs = 0;
139
+#endif
140
+
133
     // prescaler 64
141
     // prescaler 64
134
     TCCR2B = (1 << CS22);
142
     TCCR2B = (1 << CS22);
135
 }
143
 }
136
 
144
 
137
 ISR(TIMER2_OVF_vect) {
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
     // turn off UV LED
164
     // turn off UV LED
139
     digitalWrite(UV_LED_PIN, LOW);
165
     digitalWrite(UV_LED_PIN, LOW);
140
 
166
 

Loading…
Cancel
Save