From 179ed918aed1c9f190ae6846ea4bcccccbeab18f Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Mon, 21 Nov 2022 16:34:17 -0600 Subject: Added Pre-Charge functionality and made thing prettier. --- battery.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'battery.cpp') diff --git a/battery.cpp b/battery.cpp index e0b7c26..d4a8ae7 100644 --- a/battery.cpp +++ b/battery.cpp @@ -4,6 +4,7 @@ Battery::Battery() : activeBattery(batteries[LiionPhosphate]), systemVoltage(0), peakPower(0), + minimumAllowableSOC(0), packDischargeRate(0), packChargeRate(0), packWeight(0), @@ -26,6 +27,10 @@ void Battery::setPeakSystemPower(double power) { peakPower = power; } +void Battery::setMinimumSOC(double SOC) +{ + minimumAllowableSOC = SOC; +} void Battery::calculate() { @@ -43,7 +48,8 @@ int Battery::parallelCells(void) float Battery::minimumPackVoltage(void) { - return seriesCells()*activeBattery.minimumVoltage; + float min = seriesCells()*activeBattery.minimumVoltage; + return (min) + (maximumPackVoltage()-min)*(minimumAllowableSOC*0.01); } float Battery::maximumPackVoltage(void) -- cgit v1.2.3