Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format todo as TODO: #95

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Software/src/battery/BMW-I3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../lib/miwagner-ESP32-Arduino-CAN/CAN_config.h"
#include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h"

//TODO before using
//TODO: before using
// Map the final values in update_values_i3_battery, set some to static values if not available (current, discharge max , charge max)
// Check if I3 battery stays alive with only 10B and 512. If not, add 12F. If that doesn't help, add more from CAN log (ask Dala)

Expand Down Expand Up @@ -80,24 +80,24 @@ void update_values_i3_battery() { //This function maps all the values fetched v
{
max_target_charge_power = 0;
} else {
max_target_charge_power = 5000; //Hardcoded value for testing. TODO, read real value from battery when discovered
max_target_charge_power = 5000; //Hardcoded value for testing. TODO: read real value from battery when discovered
}

if (SOC < 500) //If Soc is under 5%, stop dicharging
{
max_target_discharge_power = 0;
} else {
max_target_discharge_power =
5000; //Hardcoded value for testing. TODO, read real value from battery when discovered
5000; //Hardcoded value for testing. TODO: read real value from battery when discovered
}

Battery_Power = (Battery_Current * (Battery_Volts / 10));

stat_batt_power = Battery_Power; //TODO, is mapping OK?
stat_batt_power = Battery_Power; //TODO:, is mapping OK?

temperature_min; //hardcoded to 5*C in startup, TODO, find from battery CAN later
temperature_min; //hardcoded to 5*C in startup, TODO:, find from battery CAN later

temperature_max; //hardcoded to 6*C in startup, TODO, find from battery CAN later
temperature_max; //hardcoded to 6*C in startup, TODO:, find from battery CAN later

/* Check if the BMS is still sending CAN messages. If we go 60s without messages we raise an error*/
if (!CANstillAlive) {
Expand Down
2 changes: 1 addition & 1 deletion Software/src/battery/CHADEMO-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void update_values_chademo_battery() { //This function maps all the values fetc

max_target_discharge_power = (MaximumDischargeCurrent * MaximumBatteryVoltage); //In Watts, Convert A to P

battery_voltage = TargetBatteryVoltage; //Todo, scaling?
battery_voltage = TargetBatteryVoltage; //TODO: scaling?

capacity_Wh = ((RatedBatteryCapacity / 0.11) *
1000); //(Added in CHAdeMO v1.0.1), maybe handle hardcoded on lower protocol version?
Expand Down
8 changes: 4 additions & 4 deletions Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ static double voltage2 = 0;
static double BMU_Current = 0;
static double BMU_PackVoltage = 0;
static double BMU_Power = 0;
static double cell_voltages[89]; //array with all the cellvoltages //Todo, what is max array size? 80/88 cells?
static double cell_temperatures[89]; //array with all the celltemperatures //Todo, what is max array size? 80/88cells?
static double cell_voltages[89]; //array with all the cellvoltages //TODO: what is max array size? 80/88 cells?
static double cell_temperatures[89]; //array with all the celltemperatures //TODO: what is max array size? 80/88cells?
static double max_volt_cel = 3.70;
static double min_volt_cel = 3.70;
static double max_temp_cel = 20.00;
Expand Down Expand Up @@ -65,7 +65,7 @@ void update_values_imiev_battery() { //This function maps all the values fetche
max_target_discharge_power = 10000; //Otherwise we can discharge 10kW from the pack!
}

stat_batt_power = BMU_Power; //TODO, Scaling?
stat_batt_power = BMU_Power; //TODO: Scaling?

static int n = sizeof(cell_voltages) / sizeof(cell_voltages[0]);
max_volt_cel = cell_voltages[0]; // Initialize max with the first element of the array
Expand Down Expand Up @@ -164,7 +164,7 @@ void update_values_imiev_battery() { //This function maps all the values fetche

void receive_can_imiev_battery(CAN_frame_t rx_frame) {
CANstillAlive =
12; //Todo, move this inside a known message ID to prevent CAN inverter from keeping battery alive detection going
12; //TODO: move this inside a known message ID to prevent CAN inverter from keeping battery alive detection going
switch (rx_frame.MsgID) {
case 0x374: //BMU message, 10ms - SOC
temp_value = ((rx_frame.data.u8[1] - 10) / 2);
Expand Down
4 changes: 2 additions & 2 deletions Software/src/battery/TESLA-MODEL-3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void update_values_tesla_model_3_battery() { //This function maps all the value
max_target_charge_power = 15000; //Otherwise we can push 15kW into the pack!
}

stat_batt_power = (volts * amps); //TODO, check if scaling is OK
stat_batt_power = (volts * amps); //TODO: check if scaling is OK

min_temp = (min_temp * 10);
temperature_min = convert2unsignedInt16(min_temp);
Expand Down Expand Up @@ -232,7 +232,7 @@ void update_values_tesla_model_3_battery() { //This function maps all the value

cell_deviation_mV = (cell_max_v - cell_min_v);

//Determine which chemistry battery pack is using (crude method, TODO, replace with real CAN data later)
//Determine which chemistry battery pack is using (crude method, TODO: replace with real CAN data later)
if (soc_vi > 900) { //When SOC% is over 90.0%, we can use max cell voltage to estimate what chemistry is used
if (cell_max_v < 3450) {
LFP_Chemistry = 1;
Expand Down
8 changes: 4 additions & 4 deletions Software/src/inverter/LUNA2000-MODBUS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ void handle_update_data_modbus39500() {
system_data[9] =
1; //Running status, equiv to register 37762, 0 = Offline, 1 = Standby,2 = Running, 3 = Fault, 4 = sleep mode
system_data[10] = battery_voltage; //Battery bus voltage (766.5V = 7665)
system_data[11] = 9; //TODO, GOES LOWER WITH LOW SOC
system_data[11] = 9; //TODO: GOES LOWER WITH LOW SOC
system_data[12] = 0;
system_data[13] = 699; //TODO, GOES LOWER WITH LOW SOC
system_data[13] = 699; //TODO: GOES LOWER WITH LOW SOC
system_data[14] = 1; //Always 1 in logs
system_data[15] = 18; //Always 18 in logs
system_data[16] = 8066; //TODO, GOES HIGHER WITH LOW SOC (max allowed charge W?)
system_data[16] = 8066; //TODO: GOES HIGHER WITH LOW SOC (max allowed charge W?)
system_data[17] = 17;
system_data[18] = 44027; //TODO, GOES LOWER WITH LOW SOC
system_data[18] = 44027; //TODO: GOES LOWER WITH LOW SOC
system_data[19] = 0;
system_data[20] = 435; //Always 435 in logs
system_data[21] = 0;
Expand Down
2 changes: 1 addition & 1 deletion Software/src/inverter/PYLON-CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void update_values_can_pylon() { //This function maps all the values fetched fr
PYLON_4211.data.u8[0] = (battery_voltage >> 8);
PYLON_4211.data.u8[1] = (battery_voltage & 0x00FF);

//Current (TODO, SIGNED? Or looks like it could be just offset, in that case the below line wont work)
//Current (TODO: SIGNED? Or looks like it could be just offset, in that case the below line wont work)
PYLON_4210.data.u8[2] = (battery_current >> 8);
PYLON_4210.data.u8[3] = (battery_current & 0x00FF);
PYLON_4211.data.u8[2] = (battery_current >> 8);
Expand Down
6 changes: 3 additions & 3 deletions Software/src/inverter/SMA-CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../lib/miwagner-ESP32-Arduino-CAN/CAN_config.h"
#include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h"

//TODO, change CAN sending routine once confirmed that 500ms interval is OK for this battery type
//TODO: change CAN sending routine once confirmed that 500ms interval is OK for this battery type

/* Do not change code below unless you are sure what you are doing */
static unsigned long previousMillis1s = 0; // will store last time a Xs CAN Message was send
Expand Down Expand Up @@ -167,7 +167,7 @@ void update_values_can_sma() { //This function maps all the values fetched from
//Voltage (370.0)
SMA_4D8.data.u8[0] = (battery_voltage >> 8);
SMA_4D8.data.u8[1] = (battery_voltage & 0x00FF);
//Current (TODO, signed OK?)
//Current (TODO: signed OK?)
SMA_4D8.data.u8[2] = (battery_current >> 8);
SMA_4D8.data.u8[3] = (battery_current & 0x00FF);
//Temperature average
Expand All @@ -176,7 +176,7 @@ void update_values_can_sma() { //This function maps all the values fetched from

//Error bits
//SMA_158.data.u8[0] = //bit12 Fault high temperature, bit34Battery cellundervoltage, bit56 Battery cell overvoltage, bit78 batterysystemdefect
//TODO, add all error bits
//TODO: add all error bits
}

void receive_can_sma(CAN_frame_t rx_frame) {
Expand Down
2 changes: 1 addition & 1 deletion Software/src/inverter/SOFAR-CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void update_values_can_sofar() { //This function maps all the values fetched fr
}

void receive_can_sofar(CAN_frame_t rx_frame) {
switch (rx_frame.MsgID) { //In here we need to respond to the inverter. TODO make logic
switch (rx_frame.MsgID) { //In here we need to respond to the inverter. TODO: make logic
case 0x605:
//frame1_605 = rx_frame.data.u8[1];
//frame3_605 = rx_frame.data.u8[3];
Expand Down
22 changes: 11 additions & 11 deletions Software/src/inverter/SOLAX-CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ void update_values_can_solax() { //This function maps all the values fetched fr

//Put the values into the CAN messages
//BMS_Limits
SOLAX_1872.data.u8[0] = (uint8_t)max_voltage; //Todo, scaling OK?
SOLAX_1872.data.u8[0] = (uint8_t)max_voltage; //TODO: scaling OK?
SOLAX_1872.data.u8[1] = (max_voltage >> 8);
SOLAX_1872.data.u8[2] = (uint8_t)min_voltage; //Todo, scaling OK?
SOLAX_1872.data.u8[2] = (uint8_t)min_voltage; //TODO: scaling OK?
SOLAX_1872.data.u8[3] = (min_voltage >> 8);
SOLAX_1872.data.u8[4] = (uint8_t)(max_charge_rate_amp * 10); //Todo, scaling OK?
SOLAX_1872.data.u8[4] = (uint8_t)(max_charge_rate_amp * 10); //TODO: scaling OK?
SOLAX_1872.data.u8[5] = ((max_charge_rate_amp * 10) >> 8);
SOLAX_1872.data.u8[6] = (uint8_t)(max_discharge_rate_amp * 10); //Todo, scaling OK?
SOLAX_1872.data.u8[6] = (uint8_t)(max_discharge_rate_amp * 10); //TODO: scaling OK?
SOLAX_1872.data.u8[7] = ((max_discharge_rate_amp * 10) >> 8);

//BMS_PackData
Expand All @@ -166,7 +166,7 @@ void update_values_can_solax() { //This function maps all the values fetched fr
SOLAX_1873.data.u8[3] = (battery_current >> 8);
SOLAX_1873.data.u8[4] = (uint8_t)(SOC / 100); //SOC (100.00%)
//SOLAX_1873.data.u8[5] = //Seems like this is not required? Or shall we put SOC decimals here?
SOLAX_1873.data.u8[6] = (uint8_t)(remaining_capacity_Wh / 100); //Todo, scaling OK?
SOLAX_1873.data.u8[6] = (uint8_t)(remaining_capacity_Wh / 100); //TODO: scaling OK?
SOLAX_1873.data.u8[7] = ((remaining_capacity_Wh / 100) >> 8);

//BMS_CellData
Expand All @@ -175,10 +175,10 @@ void update_values_can_solax() { //This function maps all the values fetched fr
SOLAX_1874.data.u8[2] = (uint8_t)temperature_min;
SOLAX_1874.data.u8[3] = (temperature_min >> 8);
SOLAX_1874.data.u8[4] =
(uint8_t)(cell_max_voltage); //Todo, scaling OK? Supposed to be alarm trigger absolute cell max?
(uint8_t)(cell_max_voltage); //TODO: scaling OK? Supposed to be alarm trigger absolute cell max?
SOLAX_1874.data.u8[5] = (cell_max_voltage >> 8);
SOLAX_1874.data.u8[6] =
(uint8_t)(cell_min_voltage); //Todo, scaling OK? Supposed to be alarm trigger absolute cell min?
(uint8_t)(cell_min_voltage); //TODO: scaling OK? Supposed to be alarm trigger absolute cell min?
SOLAX_1874.data.u8[7] = (cell_min_voltage >> 8);

//BMS_Status
Expand All @@ -188,10 +188,10 @@ void update_values_can_solax() { //This function maps all the values fetched fr
SOLAX_1875.data.u8[4] = (uint8_t)0; // Contactor Status 0=off, 1=on.

//BMS_PackTemps (strange name, since it has voltages?)
SOLAX_1876.data.u8[2] = (uint8_t)cell_max_voltage; //Todo, scaling OK?
SOLAX_1876.data.u8[2] = (uint8_t)cell_max_voltage; //TODO: scaling OK?
SOLAX_1876.data.u8[3] = (cell_min_voltage >> 8);

SOLAX_1876.data.u8[6] = (uint8_t)cell_min_voltage; //Todo, scaling OK?
SOLAX_1876.data.u8[6] = (uint8_t)cell_min_voltage; //TODO: scaling OK?
SOLAX_1876.data.u8[7] = (cell_min_voltage >> 8);

//Unknown
Expand All @@ -201,10 +201,10 @@ void update_values_can_solax() { //This function maps all the values fetched fr
(uint8_t)0x02; // The above firmware version applies to:02 = Master BMS, 10 = S1, 20 = S2, 30 = S3, 40 = S4

//BMS_PackStats
SOLAX_1878.data.u8[0] = (uint8_t)(battery_voltage); //TODO, should this be max or current voltage?
SOLAX_1878.data.u8[0] = (uint8_t)(battery_voltage); //TODO: should this be max or current voltage?
SOLAX_1878.data.u8[1] = ((battery_voltage) >> 8);

SOLAX_1878.data.u8[4] = (uint8_t)capacity_Wh; //TODO, scaling OK?
SOLAX_1878.data.u8[4] = (uint8_t)capacity_Wh; //TODO: scaling OK?
SOLAX_1878.data.u8[5] = (capacity_Wh >> 8);

// BMS_Answer
Expand Down