From 0b9473dbcd0be82716e53f0bcd62d8eac60a7d04 Mon Sep 17 00:00:00 2001 From: ShadedSelf Date: Tue, 11 Jul 2023 14:51:56 +0200 Subject: [PATCH] Add voltage offset --- sunray/config_example.h | 2 ++ sunray/src/driver/AmRobotDriver.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sunray/config_example.h b/sunray/config_example.h index 32fc412f4..4eedba979 100644 --- a/sunray/config_example.h +++ b/sunray/config_example.h @@ -295,6 +295,8 @@ Also, you may choose the serial port below for serial monitor output (CONSOLE). //#define CURRENT_FACTOR 1.98 // PCB1.4 (non-bridged INA169, max. 2.5A) //#define CURRENT_FACTOR 2.941 // PCB1.4 (bridged INA169, max. 5A) +#define BATT_VOLTAGE_OFFSET 0.0 // offset to apply to the PCB voltage readings + #define GO_HOME_VOLTAGE 21.5 // start going to dock below this voltage // The battery will charge if both battery voltage is below that value and charging current is above that value. #define BAT_FULL_VOLTAGE 28.7 // start mowing again at this voltage diff --git a/sunray/src/driver/AmRobotDriver.cpp b/sunray/src/driver/AmRobotDriver.cpp index bba2f78d9..18678c5f5 100644 --- a/sunray/src/driver/AmRobotDriver.cpp +++ b/sunray/src/driver/AmRobotDriver.cpp @@ -581,12 +581,12 @@ void AmBatteryDriver::run(){ float AmBatteryDriver::getBatteryVoltage(){ float voltage = ((float)ADC2voltage(analogRead(pinBatteryVoltage))) * batteryFactor; - return voltage; + return voltage + BATT_VOLTAGE_OFFSET; } float AmBatteryDriver::getChargeVoltage(){ float voltage = ((float)ADC2voltage(analogRead(pinChargeVoltage))) * batteryFactor; - return voltage; + return voltage + BATT_VOLTAGE_OFFSET; }