|
|
@@ -7,7 +7,7 @@
|
|
|
#include "src/controller/controller.h"
|
|
|
|
|
|
|
|
|
-//Pi: Battery Limits:: w 3000 4200 20 2000 75 0
|
|
|
+//Pi: Battery Limits:: w 3000 4200 25 500 75 0
|
|
|
|
|
|
static BatteryChargingState charging_state= STATE_IDLE; //Default value of the charging state
|
|
|
static bool battery_discharge= false;
|
|
|
@@ -153,8 +153,8 @@ void CC_CV_ControlCharging(uint8_t slot_id) {
|
|
|
uint8_t charge_fraction= battery->charge_fraction;
|
|
|
|
|
|
//setting charge and discharge current:
|
|
|
- int16_t charge_current= 100;
|
|
|
-
|
|
|
+ int16_t charge_current= ((batt_capacitance * charge_fraction)/100);
|
|
|
+ printf("Charge Current set to %d\n", charge_current);
|
|
|
switch (charging_state) {
|
|
|
// PRE CHARGE STATE: Battery Voltage is lesser than 3000 mVolts
|
|
|
case STATE_PRE_CHARGE:
|
|
|
@@ -182,14 +182,14 @@ void CC_CV_ControlCharging(uint8_t slot_id) {
|
|
|
chargeCurrent_initialized= true;
|
|
|
}
|
|
|
//batt_cutoff_current: 75, BATTERY_THRESHOLD: 20
|
|
|
- if (batt_current >= batt_cutoff_current - BATTERY_THRESHOLD) {
|
|
|
+ if (batt_current >= batt_cutoff_current + BATTERY_THRESHOLD) {
|
|
|
// Detect steep voltage drop:
|
|
|
/*if (last_voltage != 0 && (last_voltage - batt_voltage) > 250) {
|
|
|
printf("!!! CV CHARGING: Voltage dropped too fast: %d -> %d mV.\n", last_voltage, batt_voltage);
|
|
|
charging_state= STATE_ERROR;
|
|
|
break;
|
|
|
}*/
|
|
|
- if(cvChargingPhaseCurrent >= BATTERY_THRESHOLD){
|
|
|
+ if(cvChargingPhaseCurrent >= batt_cutoff_current){
|
|
|
printf("DAC CV Current: %d\n", cvChargingPhaseCurrent);
|
|
|
cvChargingPhaseCurrent-= 5;
|
|
|
controller_SetCurrent(slot_id, cvChargingPhaseCurrent);
|