mirror of
https://github.com/lucysrausch/hoverboard-firmware-hack.git
synced 2025-08-01 08:34:27 +02:00
added battery voltage calibration, see config.h
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user