You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
voltage = analogRead_noISR(voltage_in)*voltage_amplitude+voltage_offset; //check with multimeter, change in config.h if needed!
564
-
#if HARDWARE_REV <= 2
565
-
// Read in current and auto-calibrate the shift offset:
566
-
// There is a constant offset depending on the
567
-
// Arduino / resistor value, so we automatically
568
-
// shift it to zero on the scale.
569
-
int raw_current = analogRead_noISR(current_in);
570
-
if (raw_current < lowest_raw_current)
571
-
lowest_raw_current = raw_current;
572
-
current = (raw_current-lowest_raw_current)*current_amplitude_R11; //check with multimeter, change in config.h if needed!
573
-
current = constrain(current,0,30);
574
-
#endif
575
-
#if HARDWARE_REV >= 3
576
-
current = (analogRead_noISR(current_in)-512)*current_amplitude_R13+current_offset; //check with multimeter, change in config.h if needed!
577
-
current = constrain(current,-30,30);
576
+
#else
577
+
voltage = analogRead_noISR(external_voltage_in)*external_voltage_amplitude+external_voltage_offset; //check with multimeter, change in config.h if needed!
578
+
#endif
579
+
580
+
#ifndef USE_EXTERNAL_CURRENT_SENSOR
581
+
#if HARDWARE_REV <= 2
582
+
// Read in current and auto-calibrate the shift offset:
583
+
// There is a constant offset depending on the
584
+
// Arduino / resistor value, so we automatically
585
+
// shift it to zero on the scale.
586
+
int raw_current = analogRead_noISR(current_in);
587
+
if (raw_current < lowest_raw_current)
588
+
lowest_raw_current = raw_current;
589
+
current = (raw_current-lowest_raw_current)*current_amplitude_R11; //check with multimeter, change in config.h if needed!
590
+
current = constrain(current,0,30);
591
+
#endif
592
+
#if HARDWARE_REV >= 3
593
+
current = (analogRead_noISR(current_in)-512)*current_amplitude_R13+current_offset; //check with multimeter, change in config.h if needed!
594
+
current = constrain(current,-30,30);
595
+
#endif
596
+
#else//using external current sensor
597
+
current = analogRead_noISR(external_current_in)*external_current_amplitude+external_current_offset;
578
598
#endif
579
599
580
600
voltage_display = 0.99*voltage_display + 0.01*voltage; //averaged voltage for display
0 commit comments