123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080 |
- //##############################################################################
- //
- // FILE: BMS_Typedefs.h
- //
- // TITLE: Global Typedefs
- //
- //
- //##############################################################################
- //
- //==============================================================================
- // Change History:
- //==============================================================================
- // Datum: | Name | Version:| Change / Cause: | No
- //------------------------------------------------------------------------------
- // | | | | 002
- //------------------------------------------------------------------------------
- // | | | | 001
- //------------------------------------------------------------------------------
- // 05.07.13 | VR | 1.0 | New Build | 000
- //==============================================================================
- //==============================================================================
- // Comment Change / Cause:
- //==============================================================================
- // Change: 003 // 003
- //----------------------
- //
- //
- //==============================================================================
- // Change: 002 // 002
- //----------------------
- //
- //
- //==============================================================================
- // Change: 001 // 001
- //----------------------
- //
- //
- //==============================================================================
- #ifndef __BMS_TYPEDEFS_H__
- #define __BMS_TYPEDEFS_H__
- #include "BMS_Defines.h"
- // ***** Slave_Status_Flags ****************************************************
- typedef union {
- uint16_t R;
- struct { //Big Endian
- //High Byte
- uint16_t rsvd_h:8;
-
- //Low Byte
- uint16_t LTC_PEC_NOK:1;
- uint16_t LTC_Timeout:1;
- uint16_t LTC2_THSD:1;
- uint16_t LTC1_THSD:1;
- uint16_t LTC2_Temp_above80:1;
- uint16_t LTC1_Temp_above80:1;
- uint16_t LTC2_Temp_belowM40:1;
- uint16_t LTC1_Temp_belowM40:1;
- } B;
- } Slave_Status_Flags_t;
-
- // ***** Slave_Self_Test_Flags *************************************************
- typedef union {
- uint16_t R;
- struct { //Big Endian
- //High Byte
- uint16_t rsvd:1;
- uint16_t LTC2_Mux_NOK:1;
- uint16_t LTC2_RefH_NOK:1;
- uint16_t LTC2_RefL_NOK:1;
- uint16_t LTC2_TST2_NOK:1;
- uint16_t LTC2_TST1_NOK:1;
- uint16_t LTC2_VST2_NOK:1;
- uint16_t LTC2_VST1_NOK:1;
-
- //Low Byte
- uint16_t LTC_PEC_NOK:1;
- uint16_t LTC1_Mux_NOK:1;
- uint16_t LTC1_RefH_NOK:1;
- uint16_t LTC1_RefL_NOK:1;
- uint16_t LTC1_TST2_NOK:1;
- uint16_t LTC1_TST1_NOK:1;
- uint16_t LTC1_VST2_NOK:1;
- uint16_t LTC1_VST1_NOK:1;
- } B;
- } Slave_Self_Test_Flags_t;
-
-
-
- // ***** Slave_Control *********************************************************
- typedef struct {
- uint16_t Balancing_dV[MAX_CELLS];
- uint32_t Balancing_OnOff_Flags[MAX_SLAVES];
- union {
- uint8_t R[MAX_SLAVES];
- struct {
- uint8_t rsvd:5;
- uint8_t Fan2_RightLeft:1;
- uint8_t Fan2_OnOff:1;
- uint8_t Fan1_OnOff:1;
- } B[MAX_SLAVES];
- } FanCtrl;
- uint8_t Relais_OnOff[MAX_SLAVES];
- } Slave_Control_t;
-
-
- // ****** Slave_Status *********************************************************
- typedef struct {
- Slave_Status_Flags_t StatusFlags;
- Slave_Self_Test_Flags_t SelfTest_Flags;
- uint8_t LTC_PEC_FailCount;
- int8_t HeatSink_Temp;
- } Slave_Status_t;
-
-
- // ***** BSD (Battery Management System Slave Data ) ***************************
- typedef struct {
- uint16_t BlockVoltage [MAX_COUNT_UI];
- int16_t BlockCurrent [MAX_COUNT_UI];
- int32_t BlockCurrentSum;
- uint8_t BlockCounter [MAX_COUNT_UI];
- uint16_t CellVoltage [MAX_COUNT_VOLTAGE] [MAX_CELLS];
- int8_t CellTemperature [MAX_COUNT_TEMPERATURE] [MAX_CELLS];
- Slave_Status_t Slave_Status [MAX_COUNT_STATUS] [MAX_SLAVES];
- Slave_Control_t Balancer;
- uint16_t r_UI;
- uint16_t w_UI;
- uint16_t r_Voltage;
- uint16_t w_Voltage;
- uint16_t r_Temperature;
- uint16_t w_Temperature;
- uint16_t r_Status;
- uint16_t w_Status;
- uint16_t r_Balancer;
- uint16_t w_Balancer;
- } BSD_t;
- // ***** BSE ( Battery Management System Slave Errors ) ************************
- typedef struct {
- int16_t ErrorCell [MAX_CELLS];
- int16_t ErrorSlave [MAX_SLAVES];
- int16_t ErrorBMS;
- uint32_t CountVoltage;
- uint32_t CountTemperature;
- uint32_t CountStatus;
- } BSE_t;
- // ***** Main Contactor Feedback ***********************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t free :6;
- uint8_t b_MainContactorError :1;
- uint8_t b_MainContactorSwitch :1;
-
-
- } B;
- } b_MC_Fb_BMU_t;
- // ***** BMU_DICO ( Battery Management Unit to DICO ) **************************
- typedef struct {
- uint8_t voltageBattMax; // Maximum Battery Voltage
- uint8_t voltageBattMin; // Minimum Battery Voltage
- uint8_t currentBatMaxCharge; // Maximum Charge Current
- uint8_t currentBatMaxDischarge; // Maximum Discharge Current
- uint8_t batterySOC; // State Of Charge
- uint8_t voltageBattFb; // Total Battery Voltage
- uint8_t currentBattFb; // Total Battery Current
- b_MC_Fb_BMU_t b_MC_Fb_BMU; // Main Contactor Feedback
- } BMU_DICO_t;
- // ***** StatusByte_1_DCU ******************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t b_motDir :1; // Direction Vehicle
- uint8_t b_reverse :1; // Reverse Active
- uint8_t b_neutral :1; // Neutral Active
- uint8_t b_drive :1; // Drive Active
- uint8_t b_PC_Activ :1; // Precharging Active
- uint8_t b_keyStart_DICO1:1; // Key Start Acknowledge
- uint8_t b_ini :1; // Initialisation Active
- uint8_t b_pulsEnGlobalFb:1; // Drive System Active
- } B;
- } b_StatusByte_1_DCU_t;
- // ***** StatusByte_2_DCU ******************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t b_MC_Rq :1; // Main Contactor Request
- uint8_t b_PC_Rq :1; // Precharge Contactor Request
- uint8_t b_fan_Rq :1; // Fan Control Request
- uint8_t b_pumpOn_Rq :1; // Pump On Request
- uint8_t b_errorGen1SAE :1; // Charging Error
- uint8_t b_perfRedSys :1; // Performing Reduction System
- uint8_t b_warningSys :1; // Red Lamp Flashing System
- uint8_t b_errorSys :1; // Red Lamp System
- } B;
- } b_StatusByte_2_DCU_t;
- // ***** ErrorBuffer ***********************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t b_errBufferIndication :1; // Error Buffer Indication
- uint8_t Reserved :3;
- uint8_t errCountMark :4; // Online Diagnoses Error Buffer Number
- } B;
- } b_ErrorBuffer_t;
- // ***** DICO1_EVCU ( DICO1 to Electronic Vehicle Control Unit ) ***************
- typedef struct {
- b_StatusByte_1_DCU_t b_StatusByte_1_DCU;
- b_StatusByte_2_DCU_t b_StatusByte_2_DCU;
- uint16_t rpmSys; // Drive Motor Speed;
- uint8_t tqRefSys; // Drive Motor Torque Reference;
- uint8_t tqSys; // Actual Drive Motor Torque Feedback;
- uint8_t powerBR_fb; // Brake Resistor Power Feedback;
- b_ErrorBuffer_t b_ErrorBufferIndication;
- } DICO1_EVCU_t;
- // ***** DiagnosticInverter1 ***************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t diagnMotor1 :2; // Diagnostic / Inverter Motor 1
- uint8_t diagnMotor2 :2; // Diagnostic / Inverter Motor 2
- uint8_t diagnMotor3 :2; // Diagnostic / Inverter Motor 3
- uint8_t diagnMotor4 :2; // Diagnostic / Inverter Motor 4
- } B;
- } b_DiagnosticInverter1_t;
- // ***** DiagnosticInverter2 ***************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t diagnGenerator1 :2; // Diagnostic Inverter / Generator 1
- uint8_t diagnGenerator2 :2; // Diagnostic Inverter / Generator 2
- uint8_t emergency_MC_Off :2; // Emergency Main Contactor Off
- uint8_t b_emergencyEngineOff:2; // Emergency Engine Off
- } B;
- } b_DiagnosticInverter2_t;
- // ***** DiagnosticInverter3 ***************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t diagnAux1 :2; // Diagnostic Inverter / AUX-Mot 1
- uint8_t diagnAux2 :2; // Diagnostic Inverter / AUX-Mot 2
- uint8_t diagnDCDC1 :2; // Diagnostic DC/DC 1
- uint8_t diagnDCDC2 :2; // Diagnostic DC/DC 2
- } B;
- } b_DiagnosticInverter3_t;
- // ***** Current_HEV_Mode ******************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t operationModeFb :4; // Current HEV Mode
- uint8_t diagnDICO :2; // Diagnostic DICO Master
- uint8_t b_startCE_extHyMode :2; // Engine start with 24 V starter
- } B;
- } b_Current_HEV_Mode_t;
- // ***** DICO2_EVCU ( DICO2 to Electronic Vehicle Control Unit ) ***************
- typedef struct {
- b_DiagnosticInverter1_t b_DiagnosticInverter1;
- b_DiagnosticInverter2_t b_DiagnosticInverter2;
- b_DiagnosticInverter3_t b_DiagnosticInverter3;
- b_Current_HEV_Mode_t b_Current_HEV_Mode;
- uint16_t powerGenerator1Fb; // Power Generator 1
- uint16_t rpmGenerator1Fb; // Speed Generator 1
- } DICO2_EVCU_t;
- // ***** ModeFeedback **********************************************************
- typedef union {
- uint16_t R;
- struct {
- uint16_t Reserved :13;
- uint16_t BMS_EoC :1;
- uint16_t Mode_Feedback :2;
- } B;
- } ModeFeedback_t;
- // ***** BMU1_EVCU ( Battery Management Unit to Electronic Vehicle Control Unit ) *
- typedef struct {
- ModeFeedback_t ModeFeedBack;
- } BMU1_EVCU_t;
- // ***** ModeRequest ***********************************************************
- typedef union {
- uint16_t R;
- struct {
- uint16_t Reserved :14;
- uint16_t Mode_Request :2;
- } B;
- } ModeRequest_t;
- // ***** EVCU1_BMU ( Electronic Vehicle Control Unit to Battery Management Unit ) *
- typedef struct {
- ModeRequest_t ModeRequest;
- } EVCU1_BMU_t;
- // ***** NLG5 Control Bitmap ***************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t Reserved :5;
- uint8_t NLG5_C_CP_V :1; // Control Pilot Ventilation Request
- uint8_t NLG5_C_C_EL :1; // Clear Error Latch
- uint8_t NLG5_C_C_EN :1; // CAN enable
- } B;
- } NLG5_CTLB_t;
- // ***** NLG5 Control BMU to BRUSA *********************************************
- typedef struct {
- NLG5_CTLB_t NLG5_CTLB; // NLG5 Control Bitmap
- uint16_t NLG5_MC_MAX; // Mains Current Maximum
- uint16_t NLG5_OV_COM; // Output Voltage Command
- uint16_t NLG5_OC_COM; // Output Current Command
- } NLG5_CTL_t;
- // ***** NLG5 Status Bitmap 1 **************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t NLG5_S_CP_DT :1; // Control pilot detected
- uint8_t NLG5_S_UM_II :1; // USA mains LEVEL II , 240V/32A/60Hz
- uint8_t NLG5_S_UM_I :1; // USA mains LEVEL I, 120V/12A/60Hz
- uint8_t NLG5_S_EUM :1; // Europe mains (230V/50Hz)
- uint8_t NLG5_S_FAN :1; // NLG5 Fan active
- uint8_t NLG5_S_WAR :1; // NLG5 general limit warning
- uint8_t NLG5_S_ERR :1; // NLG5 general error latch
- uint8_t NLG5_S_HE :1; // NLG5 power enable
- } B;
- } NLG5_STB1_t;
- // ***** NLG5 Status Bitmap 2 **************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t NLG5_S_L_PMAX :1; // Limitation by NLG5 maximum power
- uint8_t NLG5_S_L_CP :1; // Limitation by control pilot
- uint8_t NLG5_S_L_PI :1; // Limitation by power indicator
- uint8_t NLG5_S_L_MC :1; // Limitation by mains current
- uint8_t NLG5_S_L_OC :1; // Limitation by output current
- uint8_t NLG5_S_L_OV :1; // Limitation by output voltage
- uint8_t NNLG5_S_BPD_II :1; // Limitation by output voltage
- uint8_t NLG5_S_BPD_I :1; // Bypass detection I
- } B;
- } NLG5_STB2_t;
- // ***** NLG5 Status Bitmap 3 **************************************************
- typedef union {
- uint8_t R;
- struct {
- uint8_t NLG5_S_L_T_BATT :1; // Limitation by battery temperature
- uint8_t NLG5_S_L_T_TR :1; // Limitation by temperature transformer
- uint8_t NLG5_S_L_T_DIO :1; // Limitation by temperature diodes
- uint8_t NLG5_S_L_T_POW :1; // Limitation by temperature power stage
- uint8_t NLG5_S_L_T_CPRIM:1; // Limitation by temperature Capacitors prim.
- uint8_t NLG5_S_L_MO_MAX :1; // Limitation by NLG5 maximum output voltage
- uint8_t NLG5_S_L_OC_MAX :1; // Limitation by NLG5 maximum output current
- uint8_t NLG5_S_L_MC_MAX :1; // Limitation by NLG5 maximum mains current
- } B;
- } NLG5_STB3_t;
- // ***** NLG5 Status BRUSA to BMU **********************************************
- typedef struct {
- NLG5_STB1_t NLG5_STB1; // NLG5 Status Bitmap 1/4
- NLG5_STB2_t NLG5_STB2; // NLG5 Status Bitmap 2/4
- NLG5_STB3_t NLG5_STB3; // NLG5 Status Bitmap 3/4
- uint8_t NLG5_STB4; // NLG5 Status Bitmap 4/4
- } NLG5_ST_t;
- // ***** CAN0 REQUEST TELEGRAM ****************
- typedef struct {
- union {
- uint8_t Byte[4];
- struct {
- uint8_t MasterAlive:3;
- uint8_t SetMode:5;
- uint8_t BalancingCell0_7;
- uint8_t BalancingCell8_15;
- uint8_t BalancingCell16_23;
- }Values;
- };
- }MASTER_X_BMS_TELEGRAM;
- // ***** CAN0 SLAVE 0 - 5 Telegram
- typedef struct{
- uint16_t SlaveAlive:3;
- uint16_t Vcell0:13;
- uint16_t Vcell1;
- uint16_t Vcell2;
- uint16_t Vcell3;
- }SLAVE_X0_5_BMS_TELEGRAM;
- // ***** CAN0 SLVAE 6 TELEGRAM
- typedef struct{
- uint8_t SlaveAlive:3;
- uint8_t SlaveMode:5;
- uint8_t reserved1:2;
- uint8_t SlaveError:6;
- uint16_t reserved2;
- uint16_t reserved3;
- uint16_t reserved4;
- }SLAVE_X6_BMS_TELEGRAM;
- // ***** CAN0 SLVAE 7 TELEGRAM
- typedef struct{
- uint8_t SlaveAlive:3;
- uint8_t MuxCounter:3;
- uint8_t reserverd1:2;
- int8_t TempHeatSink;
- int8_t TempSens0;
- int8_t TempSens1;
- int8_t TempSens2;
- int8_t TempSens3;
- uint16_t reserved2;
- }SLAVE_X7_BMS_TELEGRAM;
- // ***** CAN0 UI TELEGRAM
- typedef struct{
- uint8_t UIAlive:3;
- uint8_t UIMode:5;
- uint16_t Ubatt;
- uint16_t Ibatt;
- uint16_t reserved;
- uint8_t Checksum;
- }SLAVE_UI_BMS_TELEGRAM;
- typedef struct {
- uint8_t HS_closed:1;
- uint8_t LS_closed:1;
- uint8_t PRECHARGE_closed:1;
- uint8_t reseved:5;
- }BMS_MASTER_RELAY_STATE;
- typedef enum {
- BMS_CAN_ID_SEARCH_INIT=0,
- BMS_CAN_ID_SEARCH_CHECK_COMMUNICATION,
- BMS_CAN_ID_SEARCH_RECONFIGURE_CAN0_IDS,
- BMS_CAN_ID_SEARCH_SAFE_CONFIGURATION
- }BMS_CAN_ID_SEARCH_FSM_t;
- typedef union{
- uint16_t word;
- struct{
- uint16_t SOC_Initialized:1;
- uint16_t Slave_Can_Id_valid:1;
- uint16_t reserved:14;
- }Bit;
- }MASTER_STARTUP_STATE;
- typedef struct {
- uint8_t CanId;
- uint8_t SerialNr[8];
- }SLAVE_ID_t;
- typedef struct {
- MASTER_STARTUP_STATE state;
- BMS_CAN_ID_SEARCH_FSM_t fsmState;
- SLAVE_ID_t SlaveConfig[CAN0_MAX_NR_OF_SLAVES];
- float maxBatteryVoltage;
- float minBatteryVoltage;
- float startSoC;
- }MASTER_STARTUP_CONFIG_t;
- // states of RUNNING_MODE_FSM
- typedef enum {
- RUN_MODE_INIT=0,
- RUN_MODE_CHECK_FOR_ACTIVE_ERRORS,
- RUN_MODE_ES3_FSM,
- RUN_MODE_ES2_FSM,
- RUN_MODE_ES1_FSM,
- RUN_MODE_OPERATION,
- RUN_MODE_SYSTEM_POWER_DOWN
- }MASTER_RUNNING_MODE;
- // states of Master CAN0 Fsm
- typedef enum{
- OP_MODE_INIT=0,
- OP_MODE_CHECK_STARTUP_CONDITIONS,
- OP_MODE_SET_PRECHARGE_RELAY,
- OP_MODE_SET_MAIN_RELAY,
- OP_MODE_NORMAL,
- OP_MODE_SOC_LOW,
- OP_MODE_ERROR
- }MASTER_CAN0_OPERATION_MODE;
- typedef enum{
- ES1_FSM_INIT=0,
- ES1_FSM_CHECK_IF_ERROR_VALID,
- ES1_FSM_ERROR_REVOKED
- }MASTER_CAN0_ES1_STATE;
- typedef enum{
- ES2_FSM_INIT=0,
- ES2_FSM_CHECK_IF_ERROR_VALID,
- ES2_FSM_WAIT_FOR_SHUTDOWN,
- ES2_FSM_ERROR_REVOKED,
- ES2_FSM_SYSTEM_SHUTDOWN
- }MASTER_CAN0_ES2_STATE;
- typedef enum{
- ES3_FSM_INIT=0,
- ES3_FSM_CONNECT_TO_SERVICE_TOOL,
- ES3_FSM_SYSTEM_SHUTDOWN,
- ES3_FSM_SYSTEM_REPAIR,
- ES3_FSM_ERROR_REVOKED
- }MASTER_CAN0_ES3_STATE;
- typedef enum{
- RCT_INV_INACTIVE=0,
- RCT_INV_CAN_CONNECTED,
- RCT_INV_RELALY_CONNECTED,
- RCT_INV_RELAY_DISCONNECT
- }BMS_RCT_INVERTER_FSM_STATE_t;
- typedef struct {
- BMS_RCT_INVERTER_FSM_STATE_t state;
- uint8_t inverterCanOnline;
- uint8_t inverterIsCharging;
- float startupPwr;
- }BMS_RCT_INVERTER_t;
- typedef enum { INIT=0,
- CHECK_IF_SLAVE_ACTIVE,
- SEND_REQUEST_TELEGRAM,
- WAIT_FOR_SLAVE_RESPONSE,
- CHECK_CAN_DATA,
- DO_CALCULATIONS,
- RUNNING_MODE_FSM,
- HANDLE_CAN_ERROR,
- WAIT_FOR_NEXT_SLAVE_TIMESLOT,
- SEND_RECEIVE_INVERTER_DATA,
- WAIT_FOR_NEXT_COMMUNICATION_CYCLE,
- SHUT_DOWN_BMS,
- ERROR_UNKNOWN_STATE
- }MASTER_CAN0_FSM_STATE_t;
- typedef enum { ERROR_INIT=0,
- ERROR_CHECK_IF_SLAVE_ACTIVE,
- ERROR_SEND_REQUEST_TELEGRAM,
- ERROR_WAIT_FOR_SLAVE_RESPONSE,
- ERROR_CHECK_CAN_DATA,
- ERROR_DO_CALCULATIONS,
- ERROR_HANDLE_CAN_ERROR,
- ERROR_WAIT_FOR_NEXT_SLAVE_TIMESLOT,
- ERROR_SEND_RECEIVE_INVERTER_DATA,
- ERROR_WAIT_FOR_NEXT_COMMUNICATION_CYCLE,
- ERROR_SHUT_DOWN_BMS,
- ERROR_ERROR_UNKNOWN_STATE
- }MASTER_CAN0_ERROR_FSM_STATE_t;
- // states of Master CAN1 Fsm
- typedef enum { CAN1_INIT=0,
- CAN1_SEND_DATA,
- CAN1_WAIT_TILL_NEXT_TRANSMIT,
- CAN1_REQUEST_DATA,
- CAN1_WAIT_FOR_REQUEST_RESPONSE,
- CAN1_WAIT_FOR_NEXT_CYCLE
- }MASTER_CAN1_FSM_STATE_t;
- typedef enum { CAN1_FSM_INIT=0,
- CAN1_FSM_SEND_HIGH_PRIO_DATA,
- CAN1_FSM_SEND_LOW_PRIO_DATA,
- CAN1_FSM_SEND_REQUEST_DATA,
- CAN1_FSM_WAIT_FOR_RESPONSE,
- CAN1_FSM_SEND_ES_1,
- CAN1_FSM_SEND_ES_2,
- CAN1_FSM_SEND_ES_3,
- CAN1_FSM_ERROR
- }MASTER_CAN1_FSM_INVERTER_STATE_t;
- typedef enum { CAN1_FAST_RX_FSM_REQUEST_BATTERY_CURRENT=0,
- CAN1_FAST_RX_FSM_REQUEST_BATTERY_VOLTAGE,
- CAN1_FAST_RX_FSM_REQUEST_COMPLETE
- }MASTER_CAN1_FSM_FAST_REQUEST_STATE_t;
- // CONNECTIONS STATUS OF SLAVE
- typedef enum {
- NOT_CONNECTED=0,
- CONNECTED,
- DEBUG_SLAVE_SIMULATED,
- DEBUG_DATA_SIMULATED,
- TIMEOUT,
- TELEGRAM_LOST
- }SLAVE_CAN0_CONNECT_STATUS_t;
- typedef enum { MASTER_OPERATION_INIT=0,
- SET_PRECHARGE_RELAIS,
- SET_MAIN_RELAIS,
- MASTER_OPERATION_COMPLETE
- }MASTER_OPERATION_FSM_STATE_t;
- typedef struct{
- uint16_t SlaveErrorCounterRegister;
- uint32_t SlaveErrorStateRegister;
- uint8_t FailedComCnt;
- uint8_t WrongAliveCnt;
- }SLAVE_ERROR_STRUCT_t;
- typedef enum {
- SLAVE=0,
- UI
- }SLAVE_CAN0_TYPE_t;
- typedef enum {
- BMS_BALANCE_INIT=0,
- BMS_BALANCE_GET_VOLTAGE,
- BMS_BALANCE_BALANCE_CELLS,
- BMS_BALANCE_COOL,
- BMS_BALANCE_OFF
- }BMS_BALANCE_STATE_t;
- // fsm struct for running mode fsm
- typedef struct {
- MASTER_RUNNING_MODE RunningMode;
- MASTER_CAN0_OPERATION_MODE OperationMode;
- uint64_t OperationModeTimestamp;
- MASTER_CAN0_ES1_STATE ErrorState1fsm;
- uint64_t ErrorState2Timestamp;
- uint64_t ErrorState3Timestamp;
- MASTER_CAN0_ES2_STATE ErrorState2fsm;
- MASTER_CAN0_ES3_STATE ErrorState3fsm;
- uint32_t onCounter; // counter for relay closed time
- }BMS_RUNNING_MODE_t;
- // connection status of cells
- typedef enum {
- CELL_NOT_CONNECTED=0,
- CELL_BYPASSED,
- CELL_CONNECTED
- }CELL_STATE_t;
- typedef enum {
- TEMP_SENSOR_NOT_CONNECTED=0,
- TEMP_SENSOR_CONNECTED
- }TEMP_SENSOR_STATE_t;
- typedef struct {
- uint32_t valueId;
- float value;
- }BMS_CAN1_INVERTER_FLOAT_t;
- typedef struct {
- uint32_t valueId;
- uint32_t payload;
- }BMS_CAN1_INVERTER_CELL_DATA_t;
- typedef struct {
- uint32_t valueId;
- uint32_t value;
- }BMS_CAN1_INVERTER_INTEGER_32_t;
- typedef struct {
- uint32_t valueId;
- uint32_t value;
- }BMS_CAN1_INVERTER_INTEGER_16_t;
- typedef struct {
- uint32_t valueId;
- uint8_t globalBatteryStatus;
- uint8_t errorCode;
- uint8_t byte6;
- uint8_t byte7;
- }BMS_CAN1_INVERTER_BATTERY_STATUS_t;
- typedef struct {
- union {
- uint8_t Byte[14][8];
- struct {
- BMS_CAN1_INVERTER_INTEGER_32_t batteryModeExtra;
- BMS_CAN1_INVERTER_FLOAT_t maxBatteryChargeCurrent;
- BMS_CAN1_INVERTER_FLOAT_t maxBatteryChargeVoltage;
- BMS_CAN1_INVERTER_FLOAT_t maxBatteryDischargeCurrent;
- BMS_CAN1_INVERTER_FLOAT_t minBatteryDischargeVoltage;
- BMS_CAN1_INVERTER_FLOAT_t batteryCurrent;
- BMS_CAN1_INVERTER_FLOAT_t batteryVoltage;
- BMS_CAN1_INVERTER_FLOAT_t batterySOCtarget;
- BMS_CAN1_INVERTER_FLOAT_t batterySOC;
- BMS_CAN1_INVERTER_FLOAT_t batteryCapacity;
- BMS_CAN1_INVERTER_FLOAT_t batteryTemperature;
- BMS_CAN1_INVERTER_FLOAT_t batterySOH;
- BMS_CAN1_INVERTER_INTEGER_32_t batteryMode;
- BMS_CAN1_INVERTER_BATTERY_STATUS_t batteryStatus;
-
- }Values;
- };
- }BMS_CAN1_INVERTER_TX;
- typedef struct {
- union {
- uint8_t Byte[8];
- struct {
- uint32_t valueId;
- uint32_t requestId;
- };
- };
- }BMS_CAN1_INVERTER_REQUEST;
- /// Error handling
- typedef struct {
- union {
- uint32_t Word;
- struct{
- uint32_t SubsystemNr:5;
- uint32_t ErrorType:21;
- uint32_t CellNr:5;
- uint32_t active:1;
- }Slave;
- struct{
- uint32_t SubsystemNr:5;
- uint32_t ErrorCode:26;
- uint32_t active:1;
- }Master;
- struct{
- uint32_t SubsystemNr:5;
- uint32_t ErrorCode:26;
- uint32_t active:1;
- }UI;
- };
- }BMS_ERROR_STATE_t;
- typedef struct {
- uint8_t recoveryPending;
- uint64_t recoveryTimestamp;// used to determine timespan for inverter to be able to fix errors
- }BMS_ERROR_RECOVERY_STRUCT_t;
- typedef struct {
- BMS_ERROR_STATE_t ES1_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 1 errors
- BMS_ERROR_STATE_t ES2_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 2 errors
- BMS_ERROR_STATE_t ES3_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 3 errors
- BMS_ERROR_RECOVERY_STRUCT_t ES1_Error_Recovery[BMS_ERROR_ERROR_STACK_SIZE];
- BMS_ERROR_RECOVERY_STRUCT_t ES2_Error_Recovery[BMS_ERROR_ERROR_STACK_SIZE];
- uint8_t ES1_ErrorCounter;//Number of Class 1 errors
- uint8_t ES2_ErrorCounter;//Number of Class 2 errors
- uint8_t ES2_New_Error; // flag to mark newly occured errors
- uint8_t ES3_ErrorCounter;//Number of Class 3 errors
- }BMS_ERROR_BUFFER_t;
- typedef struct {
- BMS_ERROR_STATE_t ES1_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 1 errors
- BMS_ERROR_STATE_t ES2_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 2 errors
- BMS_ERROR_STATE_t ES3_Error[BMS_ERROR_ERROR_STACK_SIZE]; // Class 3 errors
- uint32_t counter;
- }BMS_ERROR_FRAM_DEBUG_t;
- typedef struct {
- float actualACpower;
- float phaseL1Voltage;
- float phaseL2Voltage;
- float phaseL3Voltage;
- float DCinputA_voltage;
- float DCinputB_voltage;
- uint16_t islandMode;
- float DCinputA_power;
- float DCinputB_power;
- float expectedInputPower;
- float batteryVoltage;
- float batteryCurrent;
- }BMS_CAN1_INVERTER_RX;
- typedef struct {
- BMS_CAN1_INVERTER_TX txStruct;
- BMS_CAN1_INVERTER_RX rxStruct;
- }BMS_CAN1_INVERTER;
- // ***** struct for selecting pending Master or Slave Telegram ********
- typedef struct {
- uint8_t nrOfRecTelegrams;
- uint8_t transmission_pending;
- uint32_t timestamp;
- MASTER_CAN0_FSM_STATE_t state;
- uint8_t slaveSelect;
- uint8_t telegramSelect;
- } MASTER_CAN0_STATE_t ;
- typedef struct {
- float I_max_charge_temp_max;
- float I_max_charge_temp_min;
- float I_max_charge_SoC ;
- float I_max_discharge_temp_max;
- float I_max_discharge_temp_min;
- float I_max_discharge_SoC ;
- float I_max_charge_derate;
- float I_max_discharge_derate;
- }MASTER_OVER_CURRENT_LIMITS_t;
- // ***** struct to contain slave DATA and status and to acess Mailboxes and registers*******
- typedef struct {
- SLAVE_CAN0_CONNECT_STATUS_t SlaveConnectionState;
- SLAVE_CAN0_TYPE_t SlaveType;
- CAN_MAILBOX* TxMailbox_ptr;
- MASTER_X_BMS_TELEGRAM* TxTelegram_ptr;
- uint16_t CellVoltage[MAX_SLAVE_CELLS];
- uint16_t minCellVoltage;
- uint16_t maxCellVoltage;
- uint32_t BlockVoltage;
- int8_t CellTemp[MAX_SLAVE_CELLS];
- CELL_STATE_t CellConnectionState[MAX_SLAVE_CELLS];
- TEMP_SENSOR_STATE_t TempSensConnectionState[MAX_SLAVE_CELLS];
- int8_t HeatSinkTemp;
- int8_t maxCellTemp;
- int8_t minCellTemp;
- uint8_t SlaveAliveCnt[CAN0_NR_OF_TELEGRAMS];
- uint8_t SlaveMode;
- uint8_t SlaveError;
- uint8_t SlaveTelegramsRecFlag;
- uint8_t Set_Mode;
- uint8_t Balance_Cell_0_7;
- uint8_t Balance_Cell_8_15;
- uint8_t Balance_Cell_16_23;
- uint8_t MuxCounter;
- uint8_t MasterAliveCnt;
- SLAVE_ERROR_STRUCT_t SlaveCanCommuniationError;
- }BMS_CAN0_SLAVE_t;
- typedef struct {
- uint8_t OffsetError:1;
- uint8_t SupplyError:1;
- uint8_t RelayOpen:1;
- uint8_t reserved:5;
- }BMS_CAN0_UI_ERRORS_t;
- typedef struct {
- uint16_t Ubatt;
- int16_t Ibatt;
- uint8_t Checksum;
- BMS_CAN0_UI_ERRORS_t Errors;
- uint32_t UbattFiFo[UI_VOLTAGE_FIFO_SIZE];
- uint32_t SystemVoltageFiFo[UI_VOLTAGE_FIFO_SIZE];
- int16_t IbattFiFo[UI_CURRENT_FIFO_SIZE];
- float Ibatt_Inverter_FIFO[UI_CURRENT_FIFO_SIZE];
- }BMS_CAN0_UI_t;
- typedef struct {
- uint8_t slaveNr;
- SLAVE_CAN0_TYPE_t type;
- SLAVE_CAN0_CONNECT_STATUS_t connectionSate;
- CELL_STATE_t cellConnectionState[MAX_SLAVE_CELLS];
- TEMP_SENSOR_STATE_t tempSensConnectionState[MAX_SLAVE_CELLS];
- }BMS_SLAVE_CONFIGURATION_t;
- typedef struct {
- uint8_t slaveNr;
- SLAVE_CAN0_TYPE_t type;
- SLAVE_CAN0_CONNECT_STATUS_t connectionSate;
- }BMS_UI_CONFIGURATION_t;
- typedef struct {
- uint32_t timestamp;
- MASTER_OPERATION_FSM_STATE_t FsmState;
- }BMS_MASTER_OPERATION_t;
- typedef struct {
- MASTER_CAN1_FSM_STATE_t fsmState;
- uint8_t txMsgNr;
- uint32_t timestamp;
- uint32_t delay;
- } MASTER_CAN1_STRUCT_t;
- typedef struct {
- MASTER_CAN1_FSM_INVERTER_STATE_t fsmState;
- MASTER_CAN1_FSM_FAST_REQUEST_STATE_t fastRxState;
- uint8_t fastRequestFsmRunning;
- uint8_t slowRequestFsmRunning;
- uint32_t highPrioMsgNr;
- uint8_t lowPrioMsgNr;
- uint8_t transmitErrorNrEs1;
- uint8_t transmitErrorNrEs2;
- uint8_t transmitErrorNrEs3;
- uint32_t requestTelegramNr;
- uint32_t timeoutCyclesCnt;
- uint32_t receivedTelegrams;
- uint32_t nrOfRecCurrentSamples;
- } MASTER_CAN1_INVERTER_STRUCT_t;
- typedef enum {
- BMS_SOC_IDLE=0,
- BMS_SOC_CHECK_CURRENT,
- BMS_SOC_CHARGE,
- BMS_SOC_CHARGE_AREA_FULL,
- BMS_SOC_CHARGE_AREA_HIGH,
- BMS_SOC_CHARGE_WAIT_FOR_RELAXATION,
- BMS_SOC_CHARGE_AREA_CHARGE,
- BMS_SOC_CHARGE_C_CNT,
- BMS_SOC_CHARGE_SMOOTHING,
- BMS_SOC_CHARGE_DERATE,
- BMS_SOC_DISCHARGE,
- BMS_SOC_DISCHARGE_AREA_EMPTY,
- BMS_SOC_DISCHARGE_AREA_LOW,
- BMS_SOC_DISCHARGE_WAIT_FOR_RELAXATION,
- BMS_SOC_DISCHARGE_AREA_DISCHARGE,
- BMS_SOC_DISCHARGE_C_CNT,
- BMS_SOC_DISCHARGE_SMOOTHING,
- BMS_SOC_DISCHARGE_DERATE,
- BMS_SOC_REST,
- BMS_SOC_READY
- }MASTER_SOC_ESTIMATOR_STATE_t;
- typedef enum {
- BMS_MASTER_TEMP_SENSOR_INITIATE_MEASUREMENT=0,
- BMS_MASTER_TEMP_SENSOR_UPDATE_MEASUREMENT
- }MASTER_TEMP_SENSOR_FSM_t;
- /*
- * Voltage Areas assigned with State of charge Area to support coulumb counting
- */
- typedef struct {
- float SoC_limit_high; // upper limit for SOC in Area [0...1]
- float SoC_limit_low; // lower limit of SOC in Area [0 ...1]
- uint16_t OCV_limit_high; // upper limit of Open Clamp Voltage in Area [mV]
- uint16_t OCV_limit_low; // lower limit of Open Clamp Voltage in Area [mV]
- uint16_t OCV_hysteresis; // hyseresis for detection of new Area [mV]
- } MASTER_SOC_ESTIMATOR_AREA_t;
- typedef struct {
- uint16_t U_bat_max; // Maximum Clamp Voltage => SoC = 100%
- uint16_t U_ocv_correct; // Open Clamp Voltage used to Correct Columb counting
- float Ri_charge; // Ri of cell at charging
- float U_ocv_SoC; // SoC @ U_ocv_correct
- } MASTER_SOC_ESTIMATOR_CHARGE_THRESHOLD_t;
- typedef struct {
- uint16_t U_bat_min; // Minimum Clamp Voltage => SoC = 0%
- uint16_t U_ocv_correct; // Open Clamp Voltage used to Correct Columb counting
- float Ri_discharge; // Ri of cell at discharging
- float U_ocv_SoC; // SoC @ U_ocv_correct
- } MASTER_SOC_ESTIMATOR_DISCHARGE_THRESHOLD_t;
- typedef struct {
- float SoC;
- uint16_t OCV;
- }MASTER_SOC_ESTIMATOR_INIT_SOC_LUT_t;
- /*
- *
- */
- typedef struct {
- float capacity;
- float SoC_Ah;
- float SoC_percentage;
- float SoC_percentage_smooth;
- float SoC_Ah_smooth;
- float delta_t;
- float MaxBatteryChargeCurrent;
- float MaxBatteryDischargeCurrent;
- float SoC_percentage_smooth_FiFo[SOC_SMOOTH_FIFO_SIZE];
- uint16_t Ocv_calc;
- uint16_t ChargeRelaxationWaitCnt;
- uint16_t DischargeRelaxationWaitCnt;
- uint16_t flags;
- uint16_t ChargeSmoothFlags;
- MASTER_SOC_ESTIMATOR_STATE_t state;
- MASTER_SOC_ESTIMATOR_CHARGE_THRESHOLD_t ChargeThreshold;
- MASTER_SOC_ESTIMATOR_DISCHARGE_THRESHOLD_t DischargeThreshold;
- } MASTER_SOC_ESTIMATOR_t;
- typedef struct {
- MASTER_OVER_CURRENT_LIMITS_t currentLimits;
- MASTER_STARTUP_CONFIG_t startupConfig;
- BMS_MASTER_RELAY_STATE relayState;
- MASTER_TEMP_SENSOR_FSM_t MasterTempSensState;
- int16_t masterTemp;
- BMS_RUNNING_MODE_t RunMode;
- uint32_t winterModeTimestamp;
- BMS_CAN0_SLAVE_t Slave[CAN0_MAX_NR_OF_SLAVES];
- BMS_CAN0_UI_t UI_Board;
- BMS_CAN0_SLAVE_t tempSlave;
- BMS_CAN0_UI_t temp_UI_Board;
- uint64_t reset_test_timestamp;
- uint32_t StateOfCharge; // SOC in mAs
- uint16_t minCellVoltage;
- uint16_t maxCellVoltage;
- int8_t minCellTemp;
- int8_t maxCellTemp;
- int8_t maxHeatSinkTemp;
- int8_t minHeatSinkTemp;
- float SoC_outside;
- MASTER_CAN0_FSM_STATE_t FsmState;
- MASTER_CAN0_ERROR_FSM_STATE_t FsmErrorState;
- BMS_ERROR_BUFFER_t ErrorBuffer;
- BMS_CAN1_INVERTER inverter;
- BMS_RCT_INVERTER_t inverterState;
- uint8_t slaveSelect;
- uint64_t timestamp;
- uint64_t time;
- uint64_t cycleTimestamp;
- uint64_t test_timestamp;
- uint8_t shutdown_initiated;
- uint8_t transmission_pending;
- uint8_t cycleCounter;
- uint32_t systemVoltage;
- uint8_t allValuesInitialized;
- uint8_t startCan1Comm;
- uint8_t NrOfSlaves;
- BMS_BALANCE_STATE_t balancerState;
- MASTER_SOC_ESTIMATOR_t SoC_estimator;
- uint8_t SoC_initialized;
- uint8_t ErrorFlags;
- MASTER_CAN1_INVERTER_STRUCT_t CAN1_fsmStruct;
- float UiInverterInconsistency;
- float UiSlaveInconsistency;
- } MASTER_CAN0_STRUCT_t;
- #endif /* ifndef*/
|