Преглед изворни кода

NTC增加-20-0℃插值,温度故障检测变量由unsined改为signed

Ye Jin пре 1 година
родитељ
комит
bd14ddbd5e

+ 1 - 1
User project/1.FrameLayer/Source/tbc.c

@@ -128,7 +128,7 @@ void tbc_voDownIsr(void)
     {
         alm_stIn.uwSpdRefAbsPu = (UWORD)(-scm_swSpdRefPu);
     }
-    alm_stIn.uwIPMTempCe = adc_stUpOut.PCBTemp;
+    alm_stIn.swIPMTempCe = adc_stUpOut.PCBTemp;
     alm_stIn.uwIdcOffset = adc_stCof.uwIdcOffset;
 //    alm_stIn.swDrumSpdAbsNowRpm = uart_swDrumSpdAbsNowRpm;
 //    alm_stIn.swDrumSpdAbsPreRpm = uart_swDrumSpdAbsPreRpm;

+ 1 - 1
User project/2.MotorDrive/Include/alarm.h

@@ -163,7 +163,7 @@ typedef struct
     UWORD uwVdcCompPu;      // Q14
     UWORD uwSpdFbkLpfAbsPu; // Q15
     UWORD uwSpdRefAbsPu;    // Q15
-    UWORD uwIPMTempCe;      // Not Pu, centigrade
+    SWORD swIPMTempCe;      // Not Pu, centigrade
     UWORD uwIaOffset;       // Ia offset value
     UWORD uwIbOffset;       // Ib offset value
     UWORD uwIcOffset;       // Ib offset value

+ 4 - 4
User project/2.MotorDrive/Source/alarm.c

@@ -646,7 +646,7 @@ void alm_voDetecTBS(const ALM_IN *in, const ALM_DETECTBS_COF *coef)
         =======================================================================*/
         if (alm_pvt_blIPMOTReCheckFlg == TRUE)
         {
-            if (in->uwIPMTempCe > coef->uwIPMOvrHeatRecValCe) // 70
+            if (in->swIPMTempCe > coef->uwIPMOvrHeatRecValCe) // 70
             {
                 alm_stDecCt.ulIPMOvrHeat1++;
                 if (alm_stDecCt.ulIPMOvrHeat1 >= coef->ulIPMOvrHeatValCt) // 2s
@@ -664,7 +664,7 @@ void alm_voDetecTBS(const ALM_IN *in, const ALM_DETECTBS_COF *coef)
         }
         else
         {
-            if (in->uwIPMTempCe > coef->uwIPMOvrHeatValCe) // 85
+            if (in->swIPMTempCe > coef->uwIPMOvrHeatValCe) // 85
             {
                 alm_stDecCt.ulIPMOvrHeat++;
                 if (alm_stDecCt.ulIPMOvrHeat >= coef->ulIPMOvrHeatValCt) // 2s
@@ -1009,7 +1009,7 @@ void alm_voReset(const ALM_IN *in, const ALM_RESET_COF *coef) /* parasoft-suppre
     }
 
     /* Recover time of IPM over heat */
-    if (in->uwIPMTempCe < coef->uwIPMOvrHeatRecValCe) // 75
+    if (in->swIPMTempCe < coef->uwIPMOvrHeatRecValCe) // 75
     {
         if (alm_stRecCt.ulIPMOvrHeat < coef->ulIPMOvrHeatRecValCt) // 60s
         {
@@ -1335,7 +1335,7 @@ void alm_voDetec200MS(const ALM_BIKE_IN *in, const ALM_DETEC200MS_COF *coef) /*
 
    
     /* PCB NTC fault */
-    if((in->uwPCBNTCReg < coef->uwNTCMinReg) || (in->uwPCBNTCReg > coef->uwNTCMaxReg))   //  Fault: NTC>100k or <0.032k
+    if((in->uwPCBNTCReg < coef->uwNTCMinReg) || (in->uwPCBNTCReg > coef->uwNTCMaxReg))   //  Fault: NTC>100k or <0.032k, T<-20℃ or T>140℃
     {
         alm_stDecCt.uwPCBNTCFlt ++;
         if(alm_stDecCt.uwPCBNTCFlt >= coef->uwPCBNTCFltCt)

+ 10 - 9
User project/3.BasicFunction/Include/Temp.h

@@ -33,19 +33,20 @@ WLBDM_M0_SR_20170814-new FSM1.1, by cyf, create this file;
 #define MOTOR_TEMP_VCC		51		//0.1V  PCB霍尔板供电电压大约5.1V
 #define MOTOR_TEMP_AD_VCC 	33		//0.1V
 
-#define TEMPNUM          	7
-#define CURCALIBNUM      	7
+#define TEMPNUM          	8
+#define CURCALIBNUM      	8
 #define CURCALIBUNIT     	10 // centidegree
 /************************************************************************
  TypeDefs & Structure defines (N/A)
 *************************************************************************/
-#define temp_0   0
-#define temp_20  1
-#define temp_40  2
-#define temp_60  3
-#define temp_80  4
-#define temp_100 5
-#define temp_120 6
+#define temp__20 0
+#define temp_0   1
+#define temp_20  2
+#define temp_40  3
+#define temp_60  4
+#define temp_80  5
+#define temp_100 6
+#define temp_120 7
 
 #define temp_motor_150 	32
 #define temp_pcb_140 	25

+ 42 - 35
User project/3.BasicFunction/Source/Temp.c

@@ -25,6 +25,7 @@
  *
  ******************************/
 SLONG tmp_CurCalibCoef[CURCALIBNUM] = {
+    8275,   // -20--1		Q10
     30224, // 0-19		Q10
     53743, // 20-39
     77427, // 40-59    
@@ -35,6 +36,7 @@ SLONG tmp_CurCalibCoef[CURCALIBNUM] = {
 };
 
 static SWORD PCB_swRTempTab[TEMPNUM] = {
+    10538,
     3362, // 0.01kOnm IPM voltage at 0 C
     1253, // 0.01kOnm IPM voltage at 20 C
     530,  // 0.01kOnm IPM voltage at 40 C
@@ -45,6 +47,7 @@ static SWORD PCB_swRTempTab[TEMPNUM] = {
 };
 
 static SWORD PCB_swRTempCofTab[TEMPNUM] = {
+    -3,     // Q10  -20--1 Coef of R
     -10,  // Q10  0-19 Coef of R
     -28,  // Q10  20-39 Coef of R
     -72,  // Q10  40-59 Coef of R
@@ -54,35 +57,35 @@ static SWORD PCB_swRTempCofTab[TEMPNUM] = {
     -1301,// Q10  120-139
 };
 /* motor NTC intercept array */
-SLONG q10_motor_tmp_CurCalibCoef[CURCALIBNUM] = {
-    112056, // 70-81		Q10
-    125480, // 81-91
-    139284, // 92-102
-    152248, // 103-113
-    166113, // 114-124
-    178913,  // 125-135
-    198400,  // 136-146
-};
-/* motor NTC resistance */
-static SWORD motor_swRTempTab[TEMPNUM] = {
-    223, // 0.01kOnm IPM voltage at 70 C
-    163, // 0.01kOnm IPM voltage at 81 C
-    120,  // 0.01kOnm IPM voltage at 92 C
-    91,  // 0.01kOnm IPM voltage at 103 C
-    69,  // 0.01kOnm IPM voltage at 114 C
-    54,   // 0.01kOnm IPM voltage at 125 C
-    43,   //0.01kOnm IPM voltage at 136 C
-};
-/* motor NTC fitting slope array */
-static SWORD q10_motor_swRTempCofTab[TEMPNUM] = {
-    -182,  // Q10  70-81 Coef of R
-    -263,  // Q10  81-91 Coef of R
-    -378,  // Q10  92-102 Coef of R
-    -519, // Q10  103-113 Coef of R
-    -715, // Q10  114-124 Coef of R
-    -947,	//Q10 125-135
-    -1393,	//Q10 136-146
-};
+//SLONG q10_motor_tmp_CurCalibCoef[CURCALIBNUM] = {
+//    112056, // 70-81		Q10
+//    125480, // 81-91
+//    139284, // 92-102
+//    152248, // 103-113
+//    166113, // 114-124
+//    178913,  // 125-135
+//    198400,  // 136-146
+//};
+///* motor NTC resistance */
+//static SWORD motor_swRTempTab[TEMPNUM] = {
+//    223, // 0.01kOnm IPM voltage at 70 C
+//    163, // 0.01kOnm IPM voltage at 81 C
+//    120,  // 0.01kOnm IPM voltage at 92 C
+//    91,  // 0.01kOnm IPM voltage at 103 C
+//    69,  // 0.01kOnm IPM voltage at 114 C
+//    54,   // 0.01kOnm IPM voltage at 125 C
+//    43,   //0.01kOnm IPM voltage at 136 C
+//};
+///* motor NTC fitting slope array */
+//static SWORD q10_motor_swRTempCofTab[TEMPNUM] = {
+//    -182,  // Q10  70-81 Coef of R
+//    -263,  // Q10  81-91 Coef of R
+//    -378,  // Q10  92-102 Coef of R
+//    -519, // Q10  103-113 Coef of R
+//    -715, // Q10  114-124 Coef of R
+//    -947,	//Q10 125-135
+//    -1393,	//Q10 136-146
+//};
 
 SWORD tmp_PcbTemp = 0;
 SWORD tmp_MotTemp = 0;
@@ -164,9 +167,13 @@ void PcbTempCal(SWORD PcbR)
 SWORD TempCal(SWORD PcbR, SWORD *ptemp_tab, SWORD *p_temp_coef, SLONG *p_cali_coef, SWORD temp_140)
 {
     SWORD per_temp;
-    if (PcbR >= *(ptemp_tab+temp_0))
+    if (PcbR >= *(ptemp_tab+temp__20))
     {
-        per_temp = 0;
+        per_temp = -20;
+    }
+    else if (PcbR < *(ptemp_tab+temp__20) && PcbR >= *(ptemp_tab+temp_0))
+    {
+	per_temp = (PcbR * (*(p_temp_coef+temp__20)) + (*(p_cali_coef+temp__20))) >> 10;
     }
     else if (PcbR < *(ptemp_tab+temp_0) && PcbR >= *(ptemp_tab+temp_20))
     {
@@ -211,10 +218,10 @@ void PcbTempCal(SWORD PcbR)
     tmp_PcbTemp = TempCal(PcbR, PCB_swRTempTab, PCB_swRTempCofTab, tmp_CurCalibCoef, temp_pcb_140);		
 }
 
-void MotorTempCal(SWORD PcbR)
-{
-    tmp_MotTemp = TempCal(PcbR, motor_swRTempTab, q10_motor_swRTempCofTab, q10_motor_tmp_CurCalibCoef, temp_motor_150);	
-}
+//void MotorTempCal(SWORD PcbR)
+//{
+//    tmp_MotTemp = TempCal(PcbR, motor_swRTempTab, q10_motor_swRTempCofTab, q10_motor_tmp_CurCalibCoef, temp_motor_150);	
+//}
 #endif
 /*************************************************************************
  End of this File (EOF)!