latest BAE code 10 dec

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of RAJANGAM_REVIEW_BAE_CODE by Team Fox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EPS.h Source File

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.025
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 //PARAMETER VALUE //change
00047 //#define EPS_BAT_TEMP_LOW 0
00048 //#define EPS_BAT_TEMP_HIGH 55
00049 //#define EPS_BAT_TEMP_DEFAULT 20 
00050 
00051 void FCTN_EPS_INIT();
00052 void FCTN_EPS_HANDLE_CDMS_FAULT();
00053 void FCTN_EPS_HANDLE_HW_FAULTS();
00054 
00055 void FCTN_EPS_POWERMODE(float soc) ;
00056 
00057 void FCTN_HK_MAIN();
00058 void FCTN_APPEND_HKDATA();
00059 uint8_t quantiz(float start,float step,float x);
00060 
00061 void saveMin();
00062 void saveMax();
00063 void minMaxHkData();
00064 
00065 void FCTN_BATTERYGAUGE_INIT();
00066 int FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters, float temp);
00067 
00068 // unsigned short read_soc(char , bool );
00069 unsigned short read_soc(char,bool ack);
00070 unsigned short read(char reg);
00071 int write(char reg, unsigned short data);
00072 void reset();       //not used
00073 void quickStart();      //not used
00074 void disable_sleep();
00075 void disable_hibernate();
00076 void socChangeAlertEnabled(bool);
00077 int compensation(char rcomp);
00078 int tempCompensation(float temp);
00079 void clearAlert();
00080 void emptyAlertThreshold(char threshold);
00081 void vAlertMinMaxThreshold();
00082 void vResetThresholSet();
00083 void vResetAlertEnabled(bool enabled);
00084 char alertFlags();
00085 void clearAlertFlags();
00086 float vcell();
00087 float soc();
00088 float crate();
00089 bool alerting();
00090 void vResetThresholdSet();
00091 
00092 void FCTN_BATTTEMP_INIT();
00093 void FCTN_BATT_TEMP_SENSOR_MAIN(float*);
00094 
00095 typedef struct BAE_HK_actual{
00096     float voltage_actual[16];
00097     float current_actual[12];
00098     float Batt_temp_actual[2];
00099     float Batt_gauge_actual[4];
00100     float BAE_temp_actual;
00101     char power_mode;      
00102     uint8_t faultPoll_status; 
00103     uint8_t faultIr_status;
00104     
00105     //changed
00106     int16_t bit_data_acs_mm[3];
00107     int16_t bit_data_acs_mg[3];
00108     
00109     float AngularSpeed_actual[3];//required for algo   
00110     float Bvalue_actual[3];//required for algo
00111     float Batt_voltage_actual;
00112     /*changed 1.0*/
00113     //uint16_t Batt_voltage_data;   
00114    
00115 }BAE_HK_actual;
00116 
00117 typedef struct BAE_HK_quant{
00118     uint8_t voltage_quant[16];      //power_mode + faults should be appended to sd card 
00119     uint8_t current_quant[12];
00120     uint8_t Batt_temp_quant[2];
00121     //uint8_t Batt_gauge_quant[3];       // why only 3 here??
00122     float Batt_gauge_alerts;  //why is this float??
00123     uint8_t BAE_temp_quant;
00124 
00125     float AngularSpeed_quant[3];   
00126     float Bvalue_quant[3];  
00127     
00128     uint8_t Batt_voltage_quant;  
00129 }BAE_HK_quant;
00130 
00131 typedef struct BAE_HK_arch{         //power_mode + faults should be appended to sd card 
00132     
00133     uint8_t Batt_1_temp;            //verify if uint8_t is right
00134     uint8_t Batt_2_temp; 
00135     uint8_t EPS_PCB_temp;
00136     uint8_t Batt_SOC;           
00137     char power_mode;
00138     uint8_t faultPoll_status; 
00139     uint8_t faultIr_status;
00140     uint8_t Batt_voltage;
00141     
00142     //char Batt_voltage2;
00143     // char Digital power bus voltage;
00144     
00145 
00146 }BAE_HK_arch;
00147 
00148 typedef struct BAE_HK_min_max{
00149     uint8_t voltage_max[16];
00150     uint8_t current_max[16];
00151     uint8_t Batt_voltage_max;
00152     uint8_t BAE_temp_max;     
00153     
00154     //battery soc  
00155     uint8_t Batt_SOC_max;
00156     
00157     uint8_t Batt_temp_max[2];//bcn temp also included?
00158     //uint8_t Batt_gauge_max[3];//what is the use.
00159     
00160     uint16_t bit_data_acs_mm_max[3];
00161     uint16_t bit_data_acs_mg_max[3];
00162     uint8_t BCN_TEMP_max;
00163     //below no longer valid
00164     /*uint16_t Bvalue_max[3];
00165     uint16_t AngularSpeed_max[3];       
00166     */  
00167 
00168     uint8_t voltage_min[16];
00169     uint8_t current_min[16];
00170     uint8_t Batt_voltage_min;
00171     uint8_t BAE_temp_min;
00172     uint8_t Batt_SOC_min;
00173     
00174     uint8_t Batt_temp_min[3];//includes bcn temp
00175     uint8_t BCN_TEMP_min;
00176     
00177     //uint8_t Batt_gauge_min[3];
00178     
00179     uint16_t bit_data_acs_mm_min[3];
00180     uint16_t bit_data_acs_mg_min[3];   
00181           
00182 
00183 }BAE_HK_min_max;
00184