diff --git a/Software/Software.ino b/Software/Software.ino index 52183af0..550172b4 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -67,6 +67,7 @@ uint8_t bms_status = ACTIVE; // ACTIVE - [0..5]<>[STANDBY,INACTIVE,DA uint16_t stat_batt_power = 0; // Power going in/out of battery uint16_t cell_max_voltage = 3700; // Stores the highest cell voltage value in the system uint16_t cell_min_voltage = 3700; // Stores the minimum cell voltage value in the system +uint16_t cellvoltages[120]; // Stores all cell voltages bool LFP_Chemistry = false; // Common charger parameters diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index cae083ec..673b57d2 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -239,6 +239,11 @@ void update_values_leaf_battery() { /* This function maps all the values fetched max_target_charge_power = 0; //No need to charge further, set max power to 0 } + //Map all cell voltages to the global array + for (int i = 0; i < 97; ++i) { + cellvoltages[i] = cell_voltages[i]; + } + /*Extra safety functions below*/ if (LB_GIDS < 10) //800Wh left in battery { //Battery is running abnormally low, some discharge logic might have failed. Zero it all out. diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.h b/Software/src/battery/NISSAN-LEAF-BATTERY.h index 02fe2c86..1ae3a0b3 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.h +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.h @@ -26,6 +26,7 @@ extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 funct extern uint16_t cell_max_voltage; //mV, 0-4350 extern uint16_t cell_min_voltage; //mV, 0-4350 extern uint8_t LEDcolor; //Enum, 0-10 +extern uint16_t cellvoltages[120]; //mV 0-5000 per cell extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false void update_values_leaf_battery(); diff --git a/Software/src/battery/TEST-FAKE-BATTERY.cpp b/Software/src/battery/TEST-FAKE-BATTERY.cpp index f24b8f8a..82d9aad5 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.cpp +++ b/Software/src/battery/TEST-FAKE-BATTERY.cpp @@ -33,9 +33,9 @@ void update_values_test_battery() { /* This function puts fake values onto the p remaining_capacity_Wh = 15000; // 15kWh - cell_max_voltage = 3750; + cell_max_voltage = 3596; - cell_min_voltage = 3730; + cell_min_voltage = 3500; stat_batt_power = 0; // 0W @@ -46,6 +46,10 @@ void update_values_test_battery() { /* This function puts fake values onto the p max_target_discharge_power = 5000; // 5kW max_target_charge_power = 5000; // 5kW + + for (int i = 0; i < 97; ++i) { + cellvoltages[i] = 3500+i; + } /*Finally print out values to serial if configured to do so*/ #ifdef DEBUG_VIA_USB diff --git a/Software/src/battery/TEST-FAKE-BATTERY.h b/Software/src/battery/TEST-FAKE-BATTERY.h index 5c4b54fc..986afd78 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.h +++ b/Software/src/battery/TEST-FAKE-BATTERY.h @@ -25,6 +25,7 @@ extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 funct extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385) extern uint16_t cell_max_voltage; //mV, 0-4350 extern uint16_t cell_min_voltage; //mV, 0-4350 +extern uint16_t cellvoltages[120]; //mV 0-5000 per cell extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false extern uint8_t LEDcolor; //Enum, 0-10 diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index ef93b801..5ebe4812 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -60,6 +60,10 @@ void init_webserver() { server.on("/settings", HTTP_GET, [](AsyncWebServerRequest* request) { request->send_P(200, "text/html", index_html, settings_processor); }); + // Route for going to cellmonitor web page + server.on("/cellmonitor", HTTP_GET, + [](AsyncWebServerRequest* request) { request->send_P(200, "text/html", index_html, cellmonitor_processor); }); + // Route for editing Wh server.on("/updateBatterySize", HTTP_GET, [](AsyncWebServerRequest* request) { if (request->hasParam("value")) { @@ -547,11 +551,14 @@ String processor(const String& var) { content += ""; content += " "; - content += ""; + content += ""; + content += " "; + content += ""; content += " "; content += ""; content += ""; + return content; + } + return String(); +} + + + + + void onOTAStart() { // Log when OTA has started Serial.println("OTA update started!"); diff --git a/Software/src/devboard/webserver/webserver.h b/Software/src/devboard/webserver/webserver.h index e296c086..63fe2da8 100644 --- a/Software/src/devboard/webserver/webserver.h +++ b/Software/src/devboard/webserver/webserver.h @@ -25,6 +25,7 @@ extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 funct extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385) extern uint16_t cell_max_voltage; //mV, 0-4350 extern uint16_t cell_min_voltage; //mV, 0-4350 +extern uint16_t cellvoltages[120]; //mV 0-5000 per cell extern uint8_t LEDcolor; //Enum, 0-10 extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false @@ -98,6 +99,15 @@ String processor(const String& var); */ String settings_processor(const String& var); +/** + * @brief Replaces placeholder with content section in web page + * + * @param[in] var + * + * @return String + */ +String cellmonitor_processor(const String& var); + /** * @brief Executes on OTA start *