@@ -25,6 +25,8 @@ Edrumulus::Edrumulus()
25
25
error_LED_blink_time = round ( error_LED_blink_time_s * Fs );
26
26
dc_offset_est_len = round ( dc_offset_est_len_s * Fs );
27
27
samplerate_max_cnt = round ( samplerate_max_cnt_len_s * Fs );
28
+ dc_offset_min_limit = round (ADC_MAX_RANGE / 2 - ADC_MAX_RANGE * dc_offset_max_rel_error);
29
+ dc_offset_max_limit = round (ADC_MAX_RANGE / 2 + ADC_MAX_RANGE * dc_offset_max_rel_error);
28
30
overload_LED_cnt = 0 ;
29
31
error_LED_cnt = 0 ;
30
32
status_is_overload = false ;
@@ -337,7 +339,7 @@ Serial.println ( serial_print );
337
339
}
338
340
339
341
340
- // Sampling rate check -------------- -----------------------------------------
342
+ // Sampling rate and DC offset check -----------------------------------------
341
343
// (i.e. if CPU is overloaded, the sample rate will drop which is bad)
342
344
if ( samplerate_prev_micros_cnt >= samplerate_max_cnt )
343
345
{
@@ -357,26 +359,23 @@ Serial.println ( serial_print );
357
359
samplerate_prev_micros_cnt = 0 ;
358
360
samplerate_prev_micros = samplerate_cur_micros;
359
361
360
- /*
361
- // TEST check DC offset values
362
- String serial_print;
363
- String serial_print2;
364
- for ( int i = 0; i < number_pads; i++ )
365
- {
366
- if ( !pad[i].get_is_control() )
367
- {
368
- for ( int j = 0; j < number_inputs[i]; j++ )
362
+ // DC offset check
363
+ for ( int i = 0 ; i < number_pads; i++ )
369
364
{
370
- serial_print += String ( sample_org[i][j] ) + "\t" + String ( dc_offset[i][j] ) + "\t";
371
- serial_print2 += String ( sample_org[i][j] - dc_offset[i][j] ) + "\t";
365
+ if ( !pad[i].get_is_control () )
366
+ {
367
+ for ( int j = 0 ; j < number_inputs[i]; j++ )
368
+ {
369
+ const float & cur_dc_offset = dc_offset[i][j];
370
+ // Serial.println ( cur_dc_offset ); // TEST for plotting all DC offsets
371
+ if ( ( cur_dc_offset < dc_offset_min_limit ) || ( cur_dc_offset > dc_offset_max_limit ) )
372
+ {
373
+ status_is_error = true ;
374
+ }
375
+ }
376
+ }
372
377
}
373
378
}
374
- }
375
- //Serial.println ( serial_print );
376
- Serial.println ( serial_print2 );
377
- */
378
-
379
- }
380
379
samplerate_prev_micros_cnt++;
381
380
error_LED_cnt++;
382
381
}
0 commit comments