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@26:c8655e0ec73a, 2016-07-03 (annotated)
- Committer:
- azaddevarm
- Date:
- Sun Jul 03 19:25:48 2016 +0000
- Revision:
- 26:c8655e0ec73a
- Parent:
- 20:949d13045431
Updated with BCN v2.5, added BCN_SPND_TX
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sakthipriya | 0:7b4c00e3912f | 1 | #include <mbed.h> |
sakthipriya | 0:7b4c00e3912f | 2 | |
sakthipriya | 0:7b4c00e3912f | 3 | #define tstart -40 |
sakthipriya | 0:7b4c00e3912f | 4 | #define tstep 8 |
sakthipriya | 0:7b4c00e3912f | 5 | #define tstep_thermistor 8 //verify everything!! |
sakthipriya | 0:7b4c00e3912f | 6 | #define tstart_thermistor -40 |
sakthipriya | 0:7b4c00e3912f | 7 | #define vstart 3.3 |
sakthipriya | 0:7b4c00e3912f | 8 | #define vstep 0.84667 |
sakthipriya | 0:7b4c00e3912f | 9 | #define cstart 0.0691 |
sakthipriya | 0:7b4c00e3912f | 10 | #define cstep 0.09133 |
sakthipriya | 2:c823d84b4cb0 | 11 | #define vcell_start 5 //check |
sakthipriya | 2:c823d84b4cb0 | 12 | #define vcell_step 0.0133 //check |
sakthipriya | 2:c823d84b4cb0 | 13 | #define soc_start 0 |
sakthipriya | 2:c823d84b4cb0 | 14 | #define soc_step 0.3921 |
sakthipriya | 2:c823d84b4cb0 | 15 | #define crate_start 0 //check |
sakthipriya | 2:c823d84b4cb0 | 16 | #define crate_step 1 //check |
sakthipriya | 2:c823d84b4cb0 | 17 | #define AngularSpeed_start 0 //check |
sakthipriya | 2:c823d84b4cb0 | 18 | #define AngularSpeed_step 0.1 //check |
sakthipriya | 0:7b4c00e3912f | 19 | #define rsens 0.095 |
sakthipriya | 0:7b4c00e3912f | 20 | |
sakthipriya | 2:c823d84b4cb0 | 21 | |
sakthipriya | 0:7b4c00e3912f | 22 | #define m_ADDR (0x6C) //slave address |
sakthipriya | 0:7b4c00e3912f | 23 | |
sakthipriya | 0:7b4c00e3912f | 24 | //I2C register addresses |
sakthipriya | 0:7b4c00e3912f | 25 | #define REG_VCELL 0x02 |
sakthipriya | 0:7b4c00e3912f | 26 | #define REG_SOC 0x04 |
sakthipriya | 0:7b4c00e3912f | 27 | #define REG_MODE 0x06 |
sakthipriya | 0:7b4c00e3912f | 28 | #define REG_VERSION 0x08 |
sakthipriya | 0:7b4c00e3912f | 29 | #define REG_HIBRT 0x0A |
sakthipriya | 0:7b4c00e3912f | 30 | #define REG_CONFIG 0x0C |
sakthipriya | 0:7b4c00e3912f | 31 | #define REG_VALRT 0x14 |
sakthipriya | 0:7b4c00e3912f | 32 | #define REG_CRATE 0x16 |
sakthipriya | 0:7b4c00e3912f | 33 | #define REG_VRESET_ID 0x18 |
sakthipriya | 0:7b4c00e3912f | 34 | #define REG_STATUS 0x1A |
sakthipriya | 0:7b4c00e3912f | 35 | #define REG_TABLE 0x40 |
sakthipriya | 0:7b4c00e3912f | 36 | #define REG_CMD 0xFE |
sakthipriya | 0:7b4c00e3912f | 37 | |
sakthipriya | 0:7b4c00e3912f | 38 | //.............Power switching.......... |
sakthipriya | 0:7b4c00e3912f | 39 | #define TRXY_DR_EN PIN82 //torque rod driver enable |
sakthipriya | 0:7b4c00e3912f | 40 | #define TRZ_DR_EN PIN88 |
sakthipriya | 0:7b4c00e3912f | 41 | #define ENBL3V3A PIN33 |
sakthipriya | 3:07e15677a75c | 42 | //#define VBATT PIN20 |
sakthipriya | 0:7b4c00e3912f | 43 | #define BATT_HEAT PIN96 |
sakthipriya | 0:7b4c00e3912f | 44 | //#define BATT_HEAT_OUTPUT |
sakthipriya | 5:bb592f3185cc | 45 | extern void FCTN_CONVERT_FLOAT(float input, uint8_t* output); |
lakshya | 20:949d13045431 | 46 | //PARAMETER VALUE //change |
lakshya | 20:949d13045431 | 47 | //#define EPS_BAT_TEMP_LOW 0 |
lakshya | 20:949d13045431 | 48 | //#define EPS_BAT_TEMP_HIGH 55 |
lakshya | 20:949d13045431 | 49 | //#define EPS_BAT_TEMP_DEFAULT 20 |
sakthipriya | 5:bb592f3185cc | 50 | |
sakthipriya | 1:446a959e36ce | 51 | void FCTN_EPS_INIT(); |
sakthipriya | 0:7b4c00e3912f | 52 | |
sakthipriya | 0:7b4c00e3912f | 53 | void FCTN_EPS_POWERMODE(float soc) ; |
sakthipriya | 0:7b4c00e3912f | 54 | |
sakthipriya | 3:07e15677a75c | 55 | void FCTN_HK_MAIN(); |
sakthipriya | 5:bb592f3185cc | 56 | void FCTN_APPEND_HKDATA(); |
sakthipriya | 5:bb592f3185cc | 57 | uint8_t quantiz(float start,float step,float x); |
sakthipriya | 0:7b4c00e3912f | 58 | |
sakthipriya | 2:c823d84b4cb0 | 59 | void saveMin(); |
sakthipriya | 2:c823d84b4cb0 | 60 | void saveMax(); |
sakthipriya | 2:c823d84b4cb0 | 61 | void minMaxHkData(); |
sakthipriya | 2:c823d84b4cb0 | 62 | |
sakthipriya | 0:7b4c00e3912f | 63 | void FCTN_BATTERYGAUGE_INIT(); |
azaddevarm | 26:c8655e0ec73a | 64 | int FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters, float temp); |
sakthipriya | 0:7b4c00e3912f | 65 | |
sakthipriya | 1:446a959e36ce | 66 | // unsigned short read_soc(char , bool ); |
sakthipriya | 1:446a959e36ce | 67 | unsigned short read_soc(char,bool ack); |
sakthipriya | 0:7b4c00e3912f | 68 | unsigned short read(char reg); |
azaddevarm | 26:c8655e0ec73a | 69 | int write(char reg, unsigned short data); |
sakthipriya | 0:7b4c00e3912f | 70 | void reset(); //not used |
sakthipriya | 0:7b4c00e3912f | 71 | void quickStart(); //not used |
sakthipriya | 0:7b4c00e3912f | 72 | void disable_sleep(); |
sakthipriya | 0:7b4c00e3912f | 73 | void disable_hibernate(); |
sakthipriya | 0:7b4c00e3912f | 74 | void socChangeAlertEnabled(bool); |
sakthipriya | 0:7b4c00e3912f | 75 | void compensation(char rcomp); |
sakthipriya | 0:7b4c00e3912f | 76 | void tempCompensation(float temp); |
sakthipriya | 0:7b4c00e3912f | 77 | void clearAlert(); |
sakthipriya | 0:7b4c00e3912f | 78 | void emptyAlertThreshold(char threshold); |
sakthipriya | 0:7b4c00e3912f | 79 | void vAlertMinMaxThreshold(); |
sakthipriya | 0:7b4c00e3912f | 80 | void vResetThresholSet(); |
sakthipriya | 0:7b4c00e3912f | 81 | void vResetAlertEnabled(bool enabled); |
sakthipriya | 0:7b4c00e3912f | 82 | char alertFlags(); |
sakthipriya | 0:7b4c00e3912f | 83 | void clearAlertFlags(); |
sakthipriya | 0:7b4c00e3912f | 84 | float vcell(); |
sakthipriya | 0:7b4c00e3912f | 85 | float soc(); |
sakthipriya | 0:7b4c00e3912f | 86 | float crate(); |
sakthipriya | 0:7b4c00e3912f | 87 | bool alerting(); |
sakthipriya | 0:7b4c00e3912f | 88 | void vResetThresholdSet(); |
sakthipriya | 0:7b4c00e3912f | 89 | |
sakthipriya | 2:c823d84b4cb0 | 90 | void FCTN_BATTTEMP_INIT(); |
sakthipriya | 3:07e15677a75c | 91 | void FCTN_BATT_TEMP_SENSOR_MAIN(float*); |
sakthipriya | 2:c823d84b4cb0 | 92 | |
sakthipriya | 0:7b4c00e3912f | 93 | typedef struct BAE_HK_actual{ |
sakthipriya | 0:7b4c00e3912f | 94 | float voltage_actual[16]; |
sakthipriya | 0:7b4c00e3912f | 95 | float current_actual[12]; |
sakthipriya | 0:7b4c00e3912f | 96 | float Batt_temp_actual[2]; |
sakthipriya | 0:7b4c00e3912f | 97 | float Batt_gauge_actual[4]; |
sakthipriya | 0:7b4c00e3912f | 98 | float BAE_temp_actual; |
sakthipriya | 4:39a4ae8c7ecd | 99 | char power_mode; |
sakthipriya | 5:bb592f3185cc | 100 | uint8_t faultPoll_status; |
sakthipriya | 5:bb592f3185cc | 101 | uint8_t faultIr_status; |
lakshya | 20:949d13045431 | 102 | |
lakshya | 20:949d13045431 | 103 | //changed |
lakshya | 20:949d13045431 | 104 | int16_t bit_data_acs_mm[3]; |
lakshya | 20:949d13045431 | 105 | int16_t bit_data_acs_mg[3]; |
lakshya | 20:949d13045431 | 106 | |
lakshya | 20:949d13045431 | 107 | float AngularSpeed_actual[3];//required for algo |
lakshya | 20:949d13045431 | 108 | float Bvalue_actual[3];//required for algo |
lakshya | 19:79e69017c855 | 109 | float Batt_voltage_actual; |
lakshya | 19:79e69017c855 | 110 | /*changed 1.0*/ |
lakshya | 19:79e69017c855 | 111 | //uint16_t Batt_voltage_data; |
sakthipriya | 5:bb592f3185cc | 112 | |
sakthipriya | 0:7b4c00e3912f | 113 | }BAE_HK_actual; |
sakthipriya | 0:7b4c00e3912f | 114 | |
sakthipriya | 0:7b4c00e3912f | 115 | typedef struct BAE_HK_quant{ |
sakthipriya | 5:bb592f3185cc | 116 | uint8_t voltage_quant[16]; //power_mode + faults should be appended to sd card |
sakthipriya | 5:bb592f3185cc | 117 | uint8_t current_quant[12]; |
sakthipriya | 5:bb592f3185cc | 118 | uint8_t Batt_temp_quant[2]; |
sakthipriya | 5:bb592f3185cc | 119 | uint8_t Batt_gauge_quant[3]; // why only 3 here?? |
sakthipriya | 9:194afacf7449 | 120 | float Batt_gauge_alerts; //why is this float?? |
sakthipriya | 5:bb592f3185cc | 121 | uint8_t BAE_temp_quant; |
lakshya | 20:949d13045431 | 122 | |
sakthipriya | 5:bb592f3185cc | 123 | float AngularSpeed_quant[3]; |
sakthipriya | 0:7b4c00e3912f | 124 | float Bvalue_quant[3]; |
lakshya | 20:949d13045431 | 125 | |
sakthipriya | 5:bb592f3185cc | 126 | uint8_t Batt_voltage_quant; |
sakthipriya | 0:7b4c00e3912f | 127 | }BAE_HK_quant; |
sakthipriya | 0:7b4c00e3912f | 128 | |
sakthipriya | 5:bb592f3185cc | 129 | typedef struct BAE_HK_arch{ //power_mode + faults should be appended to sd card |
sakthipriya | 0:7b4c00e3912f | 130 | |
sakthipriya | 5:bb592f3185cc | 131 | uint8_t Batt_1_temp; //verify if uint8_t is right |
sakthipriya | 5:bb592f3185cc | 132 | uint8_t Batt_2_temp; |
sakthipriya | 5:bb592f3185cc | 133 | uint8_t EPS_PCB_temp; |
sakthipriya | 5:bb592f3185cc | 134 | uint8_t Batt_SOC; |
sakthipriya | 0:7b4c00e3912f | 135 | char power_mode; |
sakthipriya | 5:bb592f3185cc | 136 | uint8_t faultPoll_status; |
sakthipriya | 5:bb592f3185cc | 137 | uint8_t faultIr_status; |
sakthipriya | 5:bb592f3185cc | 138 | uint8_t Batt_voltage; |
sakthipriya | 5:bb592f3185cc | 139 | |
sakthipriya | 0:7b4c00e3912f | 140 | //char Batt_voltage2; |
sakthipriya | 0:7b4c00e3912f | 141 | // char Digital power bus voltage; |
sakthipriya | 0:7b4c00e3912f | 142 | |
sakthipriya | 0:7b4c00e3912f | 143 | |
sakthipriya | 0:7b4c00e3912f | 144 | }BAE_HK_arch; |
sakthipriya | 0:7b4c00e3912f | 145 | |
sakthipriya | 0:7b4c00e3912f | 146 | typedef struct BAE_HK_min_max{ |
sakthipriya | 5:bb592f3185cc | 147 | uint8_t voltage_max[16]; |
sakthipriya | 5:bb592f3185cc | 148 | uint8_t current_max[12]; |
lakshya | 20:949d13045431 | 149 | uint8_t Batt_voltage_max; |
lakshya | 20:949d13045431 | 150 | uint8_t BAE_temp_max; |
lakshya | 20:949d13045431 | 151 | |
lakshya | 20:949d13045431 | 152 | //battery soc |
lakshya | 20:949d13045431 | 153 | uint8_t Batt_SOC_max; |
lakshya | 20:949d13045431 | 154 | |
lakshya | 20:949d13045431 | 155 | uint8_t Batt_temp_max[2];//bcn temp also included? |
lakshya | 20:949d13045431 | 156 | //uint8_t Batt_gauge_max[3];//what is the use. |
lakshya | 20:949d13045431 | 157 | |
lakshya | 20:949d13045431 | 158 | uint16_t bit_data_acs_mm_max[3]; |
lakshya | 20:949d13045431 | 159 | uint16_t bit_data_acs_mg_max[3]; |
lakshya | 20:949d13045431 | 160 | uint8_t BCN_TEMP_max; |
lakshya | 20:949d13045431 | 161 | //below no longer valid |
lakshya | 20:949d13045431 | 162 | /*uint16_t Bvalue_max[3]; |
lakshya | 20:949d13045431 | 163 | uint16_t AngularSpeed_max[3]; |
lakshya | 20:949d13045431 | 164 | */ |
sakthipriya | 0:7b4c00e3912f | 165 | |
sakthipriya | 5:bb592f3185cc | 166 | uint8_t voltage_min[16]; |
sakthipriya | 5:bb592f3185cc | 167 | uint8_t current_min[12]; |
lakshya | 20:949d13045431 | 168 | uint8_t Batt_voltage_min; |
sakthipriya | 5:bb592f3185cc | 169 | uint8_t BAE_temp_min; |
lakshya | 20:949d13045431 | 170 | uint8_t Batt_SOC_min; |
lakshya | 20:949d13045431 | 171 | |
lakshya | 20:949d13045431 | 172 | uint8_t Batt_temp_min[3];//includes bcn temp |
lakshya | 20:949d13045431 | 173 | uint8_t BCN_TEMP_min; |
lakshya | 20:949d13045431 | 174 | |
lakshya | 20:949d13045431 | 175 | //uint8_t Batt_gauge_min[3]; |
lakshya | 20:949d13045431 | 176 | |
lakshya | 20:949d13045431 | 177 | uint16_t bit_data_acs_mm_min[3]; |
lakshya | 20:949d13045431 | 178 | uint16_t bit_data_acs_mg_min[3]; |
lakshya | 20:949d13045431 | 179 | |
sakthipriya | 0:7b4c00e3912f | 180 | |
sakthipriya | 0:7b4c00e3912f | 181 | }BAE_HK_min_max; |
sakthipriya | 0:7b4c00e3912f | 182 |