diff --git a/Software/Software.ino b/Software/Software.ino index 53072c64..5d6026e4 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -28,8 +28,7 @@ Preferences settings; // Store user settings const char* version_number = "5.6.dev"; // Interval settings -int intervalUpdateValues = 4800; // Interval at which to update inverter values / Modbus registers -const int interval10 = 10; // Interval for 10ms tasks +uint16_t intervalUpdateValues = INTERVAL_5_S; // Interval at which to update inverter values / Modbus registers unsigned long previousMillis10ms = 50; unsigned long previousMillisUpdateVal = 0; @@ -174,7 +173,7 @@ void loop() { #endif // Process - if (millis() - previousMillis10ms >= interval10) // Every 10ms + if (millis() - previousMillis10ms >= INTERVAL_10_MS) // Every 10ms { previousMillis10ms = millis(); handle_LED_state(); // Set the LED color according to state @@ -183,7 +182,7 @@ void loop() { #endif } - if (millis() - previousMillisUpdateVal >= intervalUpdateValues) // Every 4.8s + if (millis() - previousMillisUpdateVal >= intervalUpdateValues) // Every 5s normally { previousMillisUpdateVal = millis(); update_SOC(); // Check if real or calculated SOC% value should be sent diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index 4603a470..0924603e 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -15,7 +15,6 @@ static unsigned long previousMillis10s = 0; // will store last time a 1s CAN Me static uint16_t CANerror = 0; //counter on how many CAN errors encountered #define MAX_CAN_FAILURES 5000 //Amount of malformed CAN messages to allow before raising a warning static uint8_t CANstillAlive = 12; //counter for checking if CAN is still alive -static uint8_t errorCode = 0; //stores if we have an error code active from battery control logic static uint8_t mprun10r = 0; //counter 0-20 for 0x1F2 message static uint8_t mprun10 = 0; //counter 0-3 static uint8_t mprun100 = 0; //counter 0-3 @@ -268,7 +267,6 @@ void update_values_battery() { /* This function maps all the values fetched via Serial.println("Battery requesting immediate shutdown and contactors to be opened!"); #endif //Note, this is sometimes triggered during the night while idle, and the BMS recovers after a while. Removed latching from this scenario - errorCode = 1; system_max_discharge_power_W = 0; system_max_charge_power_W = 0; } @@ -296,17 +294,14 @@ void update_values_battery() { /* This function maps all the values fetched via break; case (5): //Caution Lamp Request & Normal Stop Request - errorCode = 2; set_event(EVENT_BATTERY_DISCHG_STOP_REQ, 0); break; case (6): //Caution Lamp Request & Charging Mode Stop Request - errorCode = 3; set_event(EVENT_BATTERY_CHG_STOP_REQ, 0); break; case (7): //Caution Lamp Request & Charging Mode Stop Request & Normal Stop Request - errorCode = 4; set_event(EVENT_BATTERY_CHG_DISCHG_STOP_REQ, 0); break; default: @@ -320,7 +315,6 @@ void update_values_battery() { /* This function maps all the values fetched via if (LB_StateOfHealth < 25) { //Battery is extremely degraded, not fit for secondlifestorage. Zero it all out. if (LB_StateOfHealth != 0) { //Extra check to see that we actually have a SOH Value available - errorCode = 5; set_event(EVENT_LOW_SOH, LB_StateOfHealth); } else { clear_event(EVENT_LOW_SOH); @@ -330,7 +324,6 @@ void update_values_battery() { /* This function maps all the values fetched via #ifdef INTERLOCK_REQUIRED if (!LB_Interlock) { set_event(EVENT_HVIL_FAILURE, 0); - errorCode = 6; } else { clear_event(EVENT_HVIL_FAILURE); } @@ -338,7 +331,6 @@ void update_values_battery() { /* This function maps all the values fetched via /* Check if the BMS is still sending CAN messages. If we go 60s without messages we raise an error*/ if (!CANstillAlive) { - errorCode = 7; set_event(EVENT_CAN_RX_FAILURE, 0); } else { CANstillAlive--; @@ -347,7 +339,6 @@ void update_values_battery() { /* This function maps all the values fetched via if (CANerror > MAX_CAN_FAILURES) //Also check if we have recieved too many malformed CAN messages. If so, signal via LED { - errorCode = 10; set_event(EVENT_CAN_RX_WARNING, 0); } @@ -358,10 +349,6 @@ void update_values_battery() { /* This function maps all the values fetched via /*Finally print out values to serial if configured to do so*/ #ifdef DEBUG_VIA_USB - if (errorCode > 0) { - Serial.print("ERROR CODE ACTIVE IN SYSTEM. NUMBER: "); - Serial.println(errorCode); - } Serial.println("Values going to inverter"); print_with_units("SOH%: ", (system_SOH_pptt * 0.01), "% "); print_with_units(", SOC% scaled: ", (system_scaled_SOC_pptt * 0.01), "% "); @@ -576,11 +563,9 @@ void receive_can_battery(CAN_frame_t rx_frame) { } if (min_max_voltage[1] >= MAX_CELL_VOLTAGE) { - errorCode = 8; set_event(EVENT_CELL_OVER_VOLTAGE, 0); } if (min_max_voltage[0] <= MIN_CELL_VOLTAGE) { - errorCode = 9; set_event(EVENT_CELL_UNDER_VOLTAGE, 0); } break; diff --git a/Software/src/charger/CHEVY-VOLT-CHARGER.h b/Software/src/charger/CHEVY-VOLT-CHARGER.h index 8f80797a..1ad5bc30 100644 --- a/Software/src/charger/CHEVY-VOLT-CHARGER.h +++ b/Software/src/charger/CHEVY-VOLT-CHARGER.h @@ -2,6 +2,7 @@ #define CHEVYVOLT_CHARGER_H #include #include "../../USER_SETTINGS.h" +#include "../devboard/config.h" // Needed for all defines #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" /* Charger hardware limits diff --git a/Software/src/charger/NISSAN-LEAF-CHARGER.h b/Software/src/charger/NISSAN-LEAF-CHARGER.h index 14152477..f2f3b9a0 100644 --- a/Software/src/charger/NISSAN-LEAF-CHARGER.h +++ b/Software/src/charger/NISSAN-LEAF-CHARGER.h @@ -2,6 +2,7 @@ #define NISSANLEAF_CHARGER_H #include #include "../../USER_SETTINGS.h" +#include "../devboard/config.h" // Needed for all defines #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" extern uint16_t system_battery_voltage_dV; //V+1, 0-500.0 (0-5000) diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index 7578d99a..91fdf577 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -583,8 +583,8 @@ String processor(const String& var) { #endif #ifdef NISSANLEAF_CHARGER float chgPwrDC = static_cast(charger_stat_HVcur * 100); - charger_stat_HVcur = chgPwrDC / (battery_voltage / 10); // P/U=I - charger_stat_HVvol = static_cast(battery_voltage / 10); + charger_stat_HVcur = chgPwrDC / (system_battery_voltage_dV / 10); // P/U=I + charger_stat_HVvol = static_cast(system_battery_voltage_dV / 10); float ACvol = charger_stat_ACvol; float HVvol = charger_stat_HVvol; float HVcur = charger_stat_HVcur;