diff --git a/Core/Inc/soc_estimation.h b/Core/Inc/soc_estimation.h index 237d92e..bf99cf1 100644 --- a/Core/Inc/soc_estimation.h +++ b/Core/Inc/soc_estimation.h @@ -8,7 +8,7 @@ extern uint8_t current_soc; #define N_MODELPARAMETERS 11 #define BATTERYCAPACITYAs (20000.0*3600) //TODO Check if value is correct Cap in Ah * 3600 (Convert to As) - +#define SOAP_MINIMUM_VOLTAGE 2.5 void soc_init(); void soc_update(int32_t shunt_current); diff --git a/Core/Src/soc_estimation.c b/Core/Src/soc_estimation.c index cae26e1..ea07344 100644 --- a/Core/Src/soc_estimation.c +++ b/Core/Src/soc_estimation.c @@ -66,7 +66,15 @@ float soe_update() } void soap_update() { - // + float r0 = soc_approxparameterbysoc(current_floatsoc, R0, N_MODELPARAMETERS); + float r1 = soc_approxparameterbysoc(current_floatsoc, R1, N_MODELPARAMETERS); + float ocv = soc_approxparameterbysoc(current_floatsoc, OCV_Data, N_MODELPARAMETERS); + + float allowedvoltagedrop = ocv - SOAP_MINIMUM_VOLTAGE; + float rin = r0+r1; + float maxcurrent = allowedvoltagedrop/rin; + //TODO think about how to pass parameters + } float soc_approxparameterbysoc(float soc,float* lut, uint8_t lutlen)