Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of QM_BAE_review_1 by
EPS.h
00001 #include <mbed.h> 00002 00003 #define tstart -40 00004 #define tstep 8 00005 #define tstep_thermistor 8 //verify everything!! 00006 #define tstart_thermistor -40 00007 #define vstart 3.3 00008 #define vstep 0.84667 00009 #define cstart 0.0691 00010 #define cstep 0.09133 00011 #define vcell_start 5 //check 00012 #define vcell_step 0.0133 //check 00013 #define soc_start 0 00014 #define soc_step 0.3921 00015 #define crate_start 0 //check 00016 #define crate_step 1 //check 00017 #define AngularSpeed_start 0 //check 00018 #define AngularSpeed_step 0.1 //check 00019 #define rsens 0.095 00020 00021 00022 #define m_ADDR (0x6C) //slave address 00023 00024 //I2C register addresses 00025 #define REG_VCELL 0x02 00026 #define REG_SOC 0x04 00027 #define REG_MODE 0x06 00028 #define REG_VERSION 0x08 00029 #define REG_HIBRT 0x0A 00030 #define REG_CONFIG 0x0C 00031 #define REG_VALRT 0x14 00032 #define REG_CRATE 0x16 00033 #define REG_VRESET_ID 0x18 00034 #define REG_STATUS 0x1A 00035 #define REG_TABLE 0x40 00036 #define REG_CMD 0xFE 00037 00038 //.............Power switching.......... 00039 #define TRXY_DR_EN PIN82 //torque rod driver enable 00040 #define TRZ_DR_EN PIN88 00041 #define ENBL3V3A PIN33 00042 //#define VBATT PIN20 00043 #define BATT_HEAT PIN96 00044 //#define BATT_HEAT_OUTPUT 00045 extern void FCTN_CONVERT_FLOAT(float input, uint8_t* output); 00046 00047 void FCTN_EPS_INIT(); 00048 00049 void FCTN_EPS_POWERMODE(float soc) ; 00050 00051 void FCTN_HK_MAIN(); 00052 void FCTN_APPEND_HKDATA(); 00053 uint8_t quantiz(float start,float step,float x); 00054 00055 void saveMin(); 00056 void saveMax(); 00057 void minMaxHkData(); 00058 00059 void FCTN_BATTERYGAUGE_INIT(); 00060 void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters); 00061 00062 // unsigned short read_soc(char , bool ); 00063 unsigned short read_soc(char,bool ack); 00064 unsigned short read(char reg); 00065 void write(char reg, unsigned short data); 00066 void reset(); //not used 00067 void quickStart(); //not used 00068 void disable_sleep(); 00069 void disable_hibernate(); 00070 void socChangeAlertEnabled(bool); 00071 void compensation(char rcomp); 00072 void tempCompensation(float temp); 00073 void clearAlert(); 00074 void emptyAlertThreshold(char threshold); 00075 void vAlertMinMaxThreshold(); 00076 void vResetThresholSet(); 00077 void vResetAlertEnabled(bool enabled); 00078 char alertFlags(); 00079 void clearAlertFlags(); 00080 float vcell(); 00081 float soc(); 00082 float crate(); 00083 bool alerting(); 00084 void vResetThresholdSet(); 00085 00086 void FCTN_BATTTEMP_INIT(); 00087 void FCTN_BATT_TEMP_SENSOR_MAIN(float*); 00088 00089 typedef struct BAE_HK_actual{ 00090 float voltage_actual[16]; 00091 float current_actual[12]; 00092 float Batt_temp_actual[2]; 00093 float Batt_gauge_actual[4]; 00094 float BAE_temp_actual; 00095 char power_mode; 00096 uint8_t faultPoll_status; 00097 uint8_t faultIr_status; 00098 float AngularSpeed_actual[3]; 00099 float Bvalue_actual[3]; 00100 float Batt_voltage_actual; 00101 00102 }BAE_HK_actual; 00103 00104 typedef struct BAE_HK_quant{ 00105 uint8_t voltage_quant[16]; //power_mode + faults should be appended to sd card 00106 uint8_t current_quant[12]; 00107 uint8_t Batt_temp_quant[2]; 00108 uint8_t Batt_gauge_quant[3]; // why only 3 here?? 00109 float Batt_gauge_alerts; //why is this float?? 00110 uint8_t BAE_temp_quant; 00111 float AngularSpeed_quant[3]; 00112 float Bvalue_quant[3]; 00113 uint8_t Batt_voltage_quant; 00114 }BAE_HK_quant; 00115 00116 typedef struct BAE_HK_arch{ //power_mode + faults should be appended to sd card 00117 00118 uint8_t Batt_1_temp; //verify if uint8_t is right 00119 uint8_t Batt_2_temp; 00120 uint8_t EPS_PCB_temp; 00121 uint8_t Batt_SOC; 00122 char power_mode; 00123 uint8_t faultPoll_status; 00124 uint8_t faultIr_status; 00125 uint8_t Batt_voltage; 00126 00127 //char Batt_voltage2; 00128 // char Digital power bus voltage; 00129 00130 00131 }BAE_HK_arch; 00132 00133 typedef struct BAE_HK_min_max{ 00134 uint8_t voltage_max[16]; 00135 uint8_t current_max[12]; 00136 uint8_t Batt_temp_max[2]; 00137 uint8_t Batt_gauge_max[3]; 00138 uint8_t BAE_temp_max; 00139 float AngularSpeed_max[3]; 00140 float Bvalue_max[3]; 00141 uint8_t Batt_voltage_max; 00142 00143 uint8_t voltage_min[16]; 00144 uint8_t current_min[12]; 00145 uint8_t Batt_temp_min[2]; 00146 uint8_t Batt_gauge_min[3]; 00147 uint8_t BAE_temp_min; 00148 float AngularSpeed_min[3]; 00149 float Bvalue_min[3]; 00150 uint8_t Batt_voltage_min; 00151 00152 }BAE_HK_min_max; 00153
Generated on Tue Jul 12 2022 17:24:01 by
1.7.2
