Updated PWM working; Entering nominal mode

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of TFR_BAE_vr1_1working_finally_USE_FOR_TESTING by Team Fox

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Thu Dec 24 20:01:31 2015 +0000
Parent:
0:7b4c00e3912f
Child:
2:c823d84b4cb0
Commit message:
updated

Changed in this revision

EPS.cpp Show annotated file Show diff for this revision Revisions of this file
EPS.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EPS.cpp	Thu Dec 24 19:15:43 2015 +0000
+++ b/EPS.cpp	Thu Dec 24 20:01:31 2015 +0000
@@ -103,7 +103,7 @@
 
 void FCTN_BATTERYGAUGE_MAIN(float Battery_parameters[4])
 {
-    
+        printf("\n\r battery gauge \n");
 
         float temp=25;    //=Battery_temp  (from temp sensor on battery board)       //value of battery temperature in C currently given a dummy value. Should be updated everytime.
         tempCompensation(temp);
@@ -143,6 +143,21 @@
         return (buff[0] << 8) | buff[1];
     }
  
+ unsigned short read_soc(char reg , bool ack = true)
+    {
+         
+         //Create a temporary buffer
+        char buff[2];
+ 
+        //Select the register
+        m_I2C.write(m_ADDR, &reg, 1, true);
+ 
+        //Read the 16-bit register
+        ack = m_I2C.read(m_ADDR, buff, 2);
+ 
+        //Return the combined 16-bit value
+        return (buff[0] << 8) | buff[1];
+    }
     
     void write(char reg, unsigned short data)
     {
@@ -344,6 +359,7 @@
     // Get the current cell voltage measurement of the MAX17049
     float vcell()
     {
+        
         //Read the 16-bit raw Vcell value
         unsigned short value = read(REG_VCELL);
  
@@ -354,27 +370,17 @@
     // Get the current state of charge measurement of the MAX17049 as a float
     float soc()
     {
-        unsigned short value;
+        //unsigned short value;
         char buff[2];
- 
-        //Select the register
-        m_I2C.write(m_ADDR, &REG_SOC, 1, true);
- 
-        //Read the 16-bit register
-        bool ack = true; 
-        ack = m_I2C.read(m_ADDR, buff, 2);
- 
-        //Return the combined 16-bit value
-        value =  (buff[0] << 8) | buff[1];
-       /* 
+        bool ack;
         //Read the 16-bit raw SOC value
-        unsigned short value = read(REG_SOC);*/
+        unsigned short value = read_soc(REG_SOC, ack);
  
         //Return SOC in percent
-        if(ack == 0)
+       // if(ack == 0)
         return value * 0.00390625;
-        else 
-        return 200;
+        //else 
+        //return 200;
     }
     
    
--- a/EPS.h	Thu Dec 24 19:15:43 2015 +0000
+++ b/EPS.h	Thu Dec 24 20:01:31 2015 +0000
@@ -34,6 +34,7 @@
 #define VBATT PIN20
 #define BATT_HEAT PIN96
 //#define BATT_HEAT_OUTPUT 
+void FCTN_EPS_INIT();
 
 void FCTN_EPS_POWERMODE(float soc) ;
 
@@ -43,6 +44,8 @@
 void FCTN_BATTERYGAUGE_INIT();
 void FCTN_BATTERYGAUGE_MAIN(float*Battery_parameters);
 
+// unsigned short read_soc(char , bool );
+unsigned short read_soc(char,bool ack);
 unsigned short read(char reg);
 void write(char reg, unsigned short data);
 void reset();       //not used
--- a/main.cpp	Thu Dec 24 19:15:43 2015 +0000
+++ b/main.cpp	Thu Dec 24 20:01:31 2015 +0000
@@ -50,8 +50,11 @@
 float data[6];
 
 extern float moment[3];
-extern SensorData Sensor; 
 extern uint8_t BCN_FEN;
+extern BAE_HK_actual actual_data;
+extern BAE_HK_quant quant_data;
+extern BAE_HK_min_max bae_HK_minmax;
+extern BAE_HK_arch arch_data;
 
 bool write_ack = 1;
 bool read_ack = 1;
@@ -140,7 +143,7 @@
     }
     else
     {
-            if(Sensor.power_mode>1)
+            if(actual_data.power_mode>1)
             
             {
                 if(ACS_STATE == '2')   // check ACS_STATE = ACS_ZAXIS_MOMENT_ONLY 
@@ -244,7 +247,7 @@
         //FCTN_READ_HK();
         //FCTN_APPEND_HKDATA();
         FCTN_BATTERYGAUGE_MAIN(actual_data.Batt_gauge_actual);
-        if (actual_data.Battery_gauge_actual[1] == 200)   //data not received
+        if (actual_data.Batt_gauge_actual[1] == 200)   //data not received
         {
           actual_data.power_mode = 1;
           EPS_BATTERY_GAUGE_STATUS = 'c';           //clear EPS_BATTERY_GAUGE_STATUS
@@ -252,7 +255,7 @@
         }
         else
         {
-          FCTN_EPS_POWERMODE(actual_data.Battery_gauge_actual[1]);            //updating power level 
+          FCTN_EPS_POWERMODE(actual_data.Batt_gauge_actual[1]);            //updating power level 
           EPS_BATTERY_GAUGE_STATUS = 's';           //set EPS_BATTERY_GAUGE_STATUS
         }
        /* if( Temperature data received)
@@ -360,12 +363,12 @@
     }
     if(schedcount%1==0)
     {
-        ptr_t_acs -> signal_set(0x1);
+        //ptr_t_acs -> signal_set(0x1);
     }
     
     if(schedcount%2==0)
     {
-       // ptr_t_eps -> signal_set(0x2);
+        ptr_t_eps -> signal_set(0x2);
         
     }
     if(schedcount%3==0)
@@ -451,7 +454,7 @@
 void FCTN_BAE_INIT()
 {
     printf("\n\r Initialising BAE ");
-    FCTN_ACS_INIT();
+   // FCTN_ACS_INIT();
     FCTN_EPS_INIT();
     //P_BCN_INIT();
     FLAG();