12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 |
- //##############################################################################
- //
- // 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;
- uint32_t OperationModeTimestamp;
- MASTER_CAN0_ES1_STATE ErrorState1fsm;
- uint32_t ErrorState2Timestamp;
- uint32_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;
- uint32_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 {
- uint16_t Ubatt;
- int16_t Ibatt;
- uint8_t Checksum;
- 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;
- uint32_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;
- uint32_t timestamp;
- uint32_t time;
- uint32_t cycleTimestamp;
- 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*/
|