added battery voltage calibration, see config.h

This commit is contained in:
larsm
2018-07-21 13:56:23 +02:00
parent 38cb5992f2
commit dd5a128199
4 changed files with 9 additions and 6 deletions

View File

@@ -161,8 +161,8 @@ void DMA1_Channel1_IRQHandler() {
return;
}
if (buzzerTimer % 100 == 0) {
batteryVoltage = batteryVoltage * 0.999 + ((float)adc_buffer.batt1 * ADC_BATTERY_VOLT) * 0.001;
if (buzzerTimer % 100 == 0) { // because you get float rounding errors if it would run every time
batteryVoltage = batteryVoltage * 0.999 + ((float)adc_buffer.batt1 * ((float)BAT_CALIB_REAL_VOLTAGE / (float)BAT_CALIB_ADC)) * 0.001;
}

View File

@@ -217,8 +217,8 @@ int main(void) {
#endif
setScopeChannel(2, (int)speedR);
setScopeChannel(3, (int)speedL);
// setScopeChannel(4, (int));
// setScopeChannel(5, (int));
setScopeChannel(4, (int)adc_buffer.batt1); // for battery voltage calibration
setScopeChannel(5, (int)(batteryVoltage * 100.0f)); // for verifying battery voltage calibration
// setScopeChannel(6, (int));
// setScopeChannel(7, (int));