Add Ah calculation

This commit is contained in:
Daniel 2023-10-12 22:53:09 +03:00
parent 7aa08fe248
commit 00674b0678

View file

@ -24,8 +24,7 @@ CAN_frame_t SMA_158 = {.FIR = {.B = {.DLC = 8,.FF = CAN_frame_std,}},.MsgID = 0x
static int discharge_current = 0; static int discharge_current = 0;
static int charge_current = 0; static int charge_current = 0;
static int temperature_average = 0; static int temperature_average = 0;
static int inverter_voltage = 0; static int ampere_hours_remaining = 0;
static int inverter_SOC = 0;
void update_values_can_sma() void update_values_can_sma()
{ //This function maps all the values fetched from battery CAN to the correct CAN messages { //This function maps all the values fetched from battery CAN to the correct CAN messages
@ -40,6 +39,7 @@ void update_values_can_sma()
temperature_average = ((temperature_max + temperature_min)/2); temperature_average = ((temperature_max + temperature_min)/2);
ampere_hours_remaining = ((remaining_capacity_Wh/battery_voltage)*100); //(WH[10000] * V+1[3600])*100 = 270 (27.0Ah)
//Map values to CAN messages //Map values to CAN messages
//Maxvoltage (eg 400.0V = 4000 , 16bits long) //Maxvoltage (eg 400.0V = 4000 , 16bits long)
@ -62,10 +62,8 @@ void update_values_can_sma()
SMA_3D8.data.u8[2] = (StateOfHealth >> 8); SMA_3D8.data.u8[2] = (StateOfHealth >> 8);
SMA_3D8.data.u8[3] = (StateOfHealth & 0x00FF); SMA_3D8.data.u8[3] = (StateOfHealth & 0x00FF);
//State of charge (AH, 0.1) //State of charge (AH, 0.1)
//SMA_3D8.data.u8[4] = //Todo, calc it SMA_3D8.data.u8[4] = (ampere_hours_remaining >> 8);
//SMA_3D8.data.u8[5] = //Todo, calc it SMA_3D8.data.u8[5] = (ampere_hours_remaining & 0x00FF);
//Todo, calc it
//Voltage (370.0) //Voltage (370.0)
SMA_4D8.data.u8[0] = (battery_voltage >> 8); SMA_4D8.data.u8[0] = (battery_voltage >> 8);