diff --git a/firmware/Core/Inc/generalDefines.h b/firmware/Core/Inc/generalDefines.h index 3db57eb..2fae6a8 100644 --- a/firmware/Core/Inc/generalDefines.h +++ b/firmware/Core/Inc/generalDefines.h @@ -30,28 +30,28 @@ // Hardware names and limits #if ENNOID_LV - #define HW_NAME "ENNOID-LV" + #define HW_NAME "CuboBMS-LV" #define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18 #define HW_LIM_CELL_MONITOR_IC_COUNT 18 #define HW_LIM_MIN_NOT_USED_DELAY 5000 #endif #if ENNOID_HV - #define HW_NAME "ENNOID-HV" + #define HW_NAME "CuboBMS-HV" #define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18 #define HW_LIM_CELL_MONITOR_IC_COUNT 18 #define HW_LIM_MIN_NOT_USED_DELAY 5000 #endif #if ENNOID_SS - #define HW_NAME "ENNOID-SS" + #define HW_NAME "CuboBMS-SS" #define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18 #define HW_LIM_CELL_MONITOR_IC_COUNT 1 #define HW_LIM_MIN_NOT_USED_DELAY 5000 #endif #if ENNOID_SS_LITE - #define HW_NAME "ENNOID-SS-LITE" + #define HW_NAME "CuboBMS-SS-LITE" #define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18 #define HW_LIM_CELL_MONITOR_IC_COUNT 1 #define HW_LIM_MIN_NOT_USED_DELAY 5000 diff --git a/firmware/Core/Src/modConfig.c b/firmware/Core/Src/modConfig.c index 1e9687d..e9721ba 100644 --- a/firmware/Core/Src/modConfig.c +++ b/firmware/Core/Src/modConfig.c @@ -268,7 +268,7 @@ void modConfigLoadDefaultConfig(modConfigGeneralConfigStructTypedef *configLocat configLocation->externalChargeUnitTable[i][j] = unitTable[i][j]; } } - + __NOP(); #elif ENNOID_HV configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack configLocation->noOfCellsParallel = 10; // Number of cells in parallel diff --git a/firmware/Core/Src/modStateOfCharge.c b/firmware/Core/Src/modStateOfCharge.c index b5aac98..cf9ba71 100644 --- a/firmware/Core/Src/modStateOfCharge.c +++ b/firmware/Core/Src/modStateOfCharge.c @@ -120,7 +120,8 @@ void modStateOfChargeProcess(void){ // Calculate state of charge // calc percent of we put/take to battery capacity - modStateOfChargeGeneralStateOfCharge.generalStateOfCharge = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh / modStateOfChargeGeneralConfigHandle->batteryCapacity * 100.0f; + modStateOfChargeGeneralStateOfCharge.generalStateOfCharge = + modStateOfChargeGeneralStateOfCharge.remainingCapacityAh / modStateOfChargeGeneralConfigHandle->batteryCapacity * 100.0f; if(SoC_Save_Flag == 0) { previous_SoC = modStateOfChargeGeneralStateOfCharge.generalStateOfCharge; diff --git a/firmware/Core/Src/modTerminal.c b/firmware/Core/Src/modTerminal.c index 7892ebd..3cae7a1 100644 --- a/firmware/Core/Src/modTerminal.c +++ b/firmware/Core/Src/modTerminal.c @@ -26,7 +26,7 @@ #include "modStateOfCharge.h" - +#include "can_messenger.h" // Private types @@ -134,6 +134,10 @@ static uint8_t SoC_Save_Flag = 0; modCommandsPrintf(" "); modCommandsPrintf("Charge Switch State: %s",charge_switch_state ? "ON" : "OFF"); modCommandsPrintf("Load Switch State: %s",load_switch_state ? "ON" : "OFF"); + modCommandsPrintf("Charge Permission: %s",packState.chargeAllowed ? "YES" : "NO"); + +// modCommandsPrintf("dummy: %s",get_dummy_soc() ? "YES" : "NO"); + //generalConfig->shuntLCFactor //export_adc_average_res @@ -192,7 +196,11 @@ uint8_t maxChargeCurrent = 0; uint8_t maxLoadCurrent = 0; */ - } else if (strcmp(argv[0], "setZeroCurrent") == 0) { + } else if (strcmp(argv[0], "socJOPA") == 0) { // Dummy SoC = 100% + + can_set_dummy_soc(); +// modCommandsPrintf("durak"); + } else if (strcmp(argv[0], "setZeroCurrent") == 0) { modCommandsPrintf(" "); modCommandsPrintf("----- setZeroCurrent -----"); @@ -365,7 +373,7 @@ uint8_t maxLoadCurrent = 0; } else if (strcmp(argv[0], "help") == 0) { modCommandsPrintf("------- Start of help -------"); - modCommandsPrintf("Valid commands for ENNOID-BMS are:"); + modCommandsPrintf("Valid commands for CUBO-BMS are:"); modCommandsPrintf("help"); modCommandsPrintf(" Show this help."); modCommandsPrintf("setZeroCurrent"); diff --git a/firmware/Libs/CAN/can_messenger.c b/firmware/Libs/CAN/can_messenger.c index 058f082..167eec2 100644 --- a/firmware/Libs/CAN/can_messenger.c +++ b/firmware/Libs/CAN/can_messenger.c @@ -39,6 +39,8 @@ static volatile CAN_MSG_t can2_tx_buf = {0,}; // Buf for 1 TX packet extern modPowerElectronicsPackStateTypedef packState; extern modConfigGeneralConfigStructTypedef *generalConfig; +static volatile bool dummy_soc = 0; + static volatile bool threshold_request = 0; static volatile bool active_request = 0; @@ -47,6 +49,18 @@ void can_msgr_init() { RingBuf_Init((void *) &can2_transmit_q_msg, 10, sizeof(CAN_MSG_t), (RINGBUF_t *) &can2_ring); } +/** + * @brief Make SoC for charging = 100% + */ +void can_set_dummy_soc(void){ + dummy_soc = 1; +} + + +bool get_dummy_soc(void){ + return dummy_soc; +} + void transmitCan1Packet() { if ((TIM_Clock - can1_transmit_clock) < 1000) { return; @@ -178,7 +192,7 @@ int getIndexByTemperature() { u16_t get_table_current() { // sending table current and end-of-charge current command - const int socIndex = getIndexBySoc(); + const int socIndex = dummy_soc ? 10 : getIndexBySoc(); const int temperatureIndex = getIndexByTemperature(); float tableCurrent = 0; if (socIndex != -1 && temperatureIndex != -1) { diff --git a/firmware/Libs/CAN/can_messenger.h b/firmware/Libs/CAN/can_messenger.h index 7d24eb8..a375d01 100644 --- a/firmware/Libs/CAN/can_messenger.h +++ b/firmware/Libs/CAN/can_messenger.h @@ -5,6 +5,7 @@ #ifndef BMS_V3_CAN_MESSENGER_H #define BMS_V3_CAN_MESSENGER_H +#include #include "../Core/Inc/main.h" /** @@ -23,6 +24,9 @@ typedef enum CAN_BMS_ID { void can_msgr_init(); +void can_set_dummy_soc(void); +bool get_dummy_soc(void); + void transmitCan1Packet(); int getIndexBySoc(); int getIndexByTemperature();