ACS completed fully. All cases to be tested

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of ACS_Flowchart_BAE by Team Fox

Committer:
sakthipriya
Date:
Thu Dec 24 20:01:31 2015 +0000
Revision:
1:446a959e36ce
Parent:
0:7b4c00e3912f
Child:
2:c823d84b4cb0
updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sakthipriya 0:7b4c00e3912f 1 #include <mbed.h>
sakthipriya 0:7b4c00e3912f 2
sakthipriya 0:7b4c00e3912f 3
sakthipriya 0:7b4c00e3912f 4 #define tstart -40
sakthipriya 0:7b4c00e3912f 5 #define tstep 8
sakthipriya 0:7b4c00e3912f 6 #define tstep_thermistor 8 //verify everything!!
sakthipriya 0:7b4c00e3912f 7 #define tstart_thermistor -40
sakthipriya 0:7b4c00e3912f 8 #define vstart 3.3
sakthipriya 0:7b4c00e3912f 9 #define vstep 0.84667
sakthipriya 0:7b4c00e3912f 10 #define cstart 0.0691
sakthipriya 0:7b4c00e3912f 11 #define cstep 0.09133
sakthipriya 0:7b4c00e3912f 12 #define rsens 0.095
sakthipriya 0:7b4c00e3912f 13
sakthipriya 0:7b4c00e3912f 14 #define m_ADDR (0x6C) //slave address
sakthipriya 0:7b4c00e3912f 15
sakthipriya 0:7b4c00e3912f 16 //I2C register addresses
sakthipriya 0:7b4c00e3912f 17 #define REG_VCELL 0x02
sakthipriya 0:7b4c00e3912f 18 #define REG_SOC 0x04
sakthipriya 0:7b4c00e3912f 19 #define REG_MODE 0x06
sakthipriya 0:7b4c00e3912f 20 #define REG_VERSION 0x08
sakthipriya 0:7b4c00e3912f 21 #define REG_HIBRT 0x0A
sakthipriya 0:7b4c00e3912f 22 #define REG_CONFIG 0x0C
sakthipriya 0:7b4c00e3912f 23 #define REG_VALRT 0x14
sakthipriya 0:7b4c00e3912f 24 #define REG_CRATE 0x16
sakthipriya 0:7b4c00e3912f 25 #define REG_VRESET_ID 0x18
sakthipriya 0:7b4c00e3912f 26 #define REG_STATUS 0x1A
sakthipriya 0:7b4c00e3912f 27 #define REG_TABLE 0x40
sakthipriya 0:7b4c00e3912f 28 #define REG_CMD 0xFE
sakthipriya 0:7b4c00e3912f 29
sakthipriya 0:7b4c00e3912f 30 //.............Power switching..........
sakthipriya 0:7b4c00e3912f 31 #define TRXY_DR_EN PIN82 //torque rod driver enable
sakthipriya 0:7b4c00e3912f 32 #define TRZ_DR_EN PIN88
sakthipriya 0:7b4c00e3912f 33 #define ENBL3V3A PIN33
sakthipriya 0:7b4c00e3912f 34 #define VBATT PIN20
sakthipriya 0:7b4c00e3912f 35 #define BATT_HEAT PIN96
sakthipriya 0:7b4c00e3912f 36 //#define BATT_HEAT_OUTPUT
sakthipriya 1:446a959e36ce 37 void FCTN_EPS_INIT();
sakthipriya 0:7b4c00e3912f 38
sakthipriya 0:7b4c00e3912f 39 void FCTN_EPS_POWERMODE(float soc) ;
sakthipriya 0:7b4c00e3912f 40
sakthipriya 0:7b4c00e3912f 41 void HK_main();
sakthipriya 0:7b4c00e3912f 42 int quantiz(float start,float step,float x);
sakthipriya 0:7b4c00e3912f 43
sakthipriya 0:7b4c00e3912f 44 void FCTN_BATTERYGAUGE_INIT();
sakthipriya 0:7b4c00e3912f 45 void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters);
sakthipriya 0:7b4c00e3912f 46
sakthipriya 1:446a959e36ce 47 // unsigned short read_soc(char , bool );
sakthipriya 1:446a959e36ce 48 unsigned short read_soc(char,bool ack);
sakthipriya 0:7b4c00e3912f 49 unsigned short read(char reg);
sakthipriya 0:7b4c00e3912f 50 void write(char reg, unsigned short data);
sakthipriya 0:7b4c00e3912f 51 void reset(); //not used
sakthipriya 0:7b4c00e3912f 52 void quickStart(); //not used
sakthipriya 0:7b4c00e3912f 53 void disable_sleep();
sakthipriya 0:7b4c00e3912f 54 void disable_hibernate();
sakthipriya 0:7b4c00e3912f 55 void socChangeAlertEnabled(bool);
sakthipriya 0:7b4c00e3912f 56 void compensation(char rcomp);
sakthipriya 0:7b4c00e3912f 57 void tempCompensation(float temp);
sakthipriya 0:7b4c00e3912f 58 void clearAlert();
sakthipriya 0:7b4c00e3912f 59 void emptyAlertThreshold(char threshold);
sakthipriya 0:7b4c00e3912f 60 void vAlertMinMaxThreshold();
sakthipriya 0:7b4c00e3912f 61 void vResetThresholSet();
sakthipriya 0:7b4c00e3912f 62 void vResetAlertEnabled(bool enabled);
sakthipriya 0:7b4c00e3912f 63 char alertFlags();
sakthipriya 0:7b4c00e3912f 64 void clearAlertFlags();
sakthipriya 0:7b4c00e3912f 65 float vcell();
sakthipriya 0:7b4c00e3912f 66 float soc();
sakthipriya 0:7b4c00e3912f 67 float crate();
sakthipriya 0:7b4c00e3912f 68 bool alerting();
sakthipriya 0:7b4c00e3912f 69 void vResetThresholdSet();
sakthipriya 0:7b4c00e3912f 70
sakthipriya 0:7b4c00e3912f 71 typedef struct BAE_HK_actual{
sakthipriya 0:7b4c00e3912f 72 float voltage_actual[16];
sakthipriya 0:7b4c00e3912f 73 float current_actual[12];
sakthipriya 0:7b4c00e3912f 74 float Batt_temp_actual[2];
sakthipriya 0:7b4c00e3912f 75 float Batt_gauge_actual[4];
sakthipriya 0:7b4c00e3912f 76 float BAE_temp_actual;
sakthipriya 0:7b4c00e3912f 77 char power_mode;
sakthipriya 0:7b4c00e3912f 78 float AngularSpeed_actual[3];
sakthipriya 0:7b4c00e3912f 79 float Bvalue_actual[3];
sakthipriya 0:7b4c00e3912f 80 float Batt_voltage_actual;
sakthipriya 0:7b4c00e3912f 81 }BAE_HK_actual;
sakthipriya 0:7b4c00e3912f 82
sakthipriya 0:7b4c00e3912f 83 typedef struct BAE_HK_quant{
sakthipriya 0:7b4c00e3912f 84 char voltage_quant[16]; //power_mode should be appended to sd card
sakthipriya 0:7b4c00e3912f 85 char current_quant[12];
sakthipriya 0:7b4c00e3912f 86 char Batt_temp_quant[2];
sakthipriya 0:7b4c00e3912f 87 char Batt_gauge_quant[3];
sakthipriya 0:7b4c00e3912f 88 float Batt_gauge_alerts;
sakthipriya 0:7b4c00e3912f 89 char BAE_temp_quant;
sakthipriya 0:7b4c00e3912f 90 char AngularSpeed_quant[3];
sakthipriya 0:7b4c00e3912f 91 float Bvalue_quant[3];
sakthipriya 0:7b4c00e3912f 92 char Batt_voltage_quant;
sakthipriya 0:7b4c00e3912f 93 }BAE_HK_quant;
sakthipriya 0:7b4c00e3912f 94
sakthipriya 0:7b4c00e3912f 95 typedef struct BAE_HK_arch{
sakthipriya 0:7b4c00e3912f 96
sakthipriya 0:7b4c00e3912f 97 char Batt_1_temp;
sakthipriya 0:7b4c00e3912f 98 char Batt_2_temp;
sakthipriya 0:7b4c00e3912f 99 char EPS_PCB_temp;
sakthipriya 0:7b4c00e3912f 100 char Batt_SOC;
sakthipriya 0:7b4c00e3912f 101 char power_mode;
sakthipriya 0:7b4c00e3912f 102 char Batt_voltage;
sakthipriya 0:7b4c00e3912f 103 //char Batt_voltage2;
sakthipriya 0:7b4c00e3912f 104 // char Digital power bus voltage;
sakthipriya 0:7b4c00e3912f 105
sakthipriya 0:7b4c00e3912f 106
sakthipriya 0:7b4c00e3912f 107 }BAE_HK_arch;
sakthipriya 0:7b4c00e3912f 108
sakthipriya 0:7b4c00e3912f 109 typedef struct BAE_HK_min_max{
sakthipriya 0:7b4c00e3912f 110 char voltage_max[16];
sakthipriya 0:7b4c00e3912f 111 char current_max[12];
sakthipriya 0:7b4c00e3912f 112 char Batt_temp_max[2];
sakthipriya 0:7b4c00e3912f 113 char Batt_gauge_max[3];
sakthipriya 0:7b4c00e3912f 114 char BAE_temp_max;
sakthipriya 0:7b4c00e3912f 115 char AngularSpeed_max[3];
sakthipriya 0:7b4c00e3912f 116 float Bvalue_max[3];
sakthipriya 0:7b4c00e3912f 117 char Batt_voltage_max;
sakthipriya 0:7b4c00e3912f 118
sakthipriya 0:7b4c00e3912f 119 char voltage_min[16];
sakthipriya 0:7b4c00e3912f 120 char current_min[12];
sakthipriya 0:7b4c00e3912f 121 char Batt_temp_min[2];
sakthipriya 0:7b4c00e3912f 122 char Batt_gauge_min[3];
sakthipriya 0:7b4c00e3912f 123 char BAE_temp_min;
sakthipriya 0:7b4c00e3912f 124 char AngularSpeed_min[3];
sakthipriya 0:7b4c00e3912f 125 float Bvalue_min[3];
sakthipriya 0:7b4c00e3912f 126 char Batt_voltage_min;
sakthipriya 0:7b4c00e3912f 127
sakthipriya 0:7b4c00e3912f 128 }BAE_HK_min_max;
sakthipriya 0:7b4c00e3912f 129