Add dummy SoC, replace ID

This commit is contained in:
Dmitriy Semenov
2023-04-06 21:23:19 +03:00
parent 9c2667bbe5
commit 8ea5166aa1
6 changed files with 37 additions and 10 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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");

View File

@@ -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) {

View File

@@ -5,6 +5,7 @@
#ifndef BMS_V3_CAN_MESSENGER_H
#define BMS_V3_CAN_MESSENGER_H
#include <stdbool.h>
#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();