Browse Source

优化电压和温度故障诊断由原来的两个STEP改为持续1min

qingfeng 2 years ago
parent
commit
5de8c1d395

+ 9 - 5
LIB/MIDDLE/CellStateEstimation/Common/V1_0_1/BatParam.py

@@ -4,11 +4,7 @@ class BatParam:
     def __init__(self,celltype):
 
         #公用参数................................................................................................................................................
-        self.CellTempUpLmt=119
-        self.CellTempLwLmt=-39
-        self.CellTempRate=5
-
-       #热失控参数
+        #热失控参数
         self.TrwTempHigh=60
         self.TrwTempRate=20
         self.TrwTempDiff=15
@@ -16,6 +12,14 @@ class BatParam:
         self.TrwCellVoltFall=1
         self.TrwCellVoltLow=1.5
         self.TrwPackVoltFall=1.5
+        
+        #故障诊断参数
+        self.CellTempUpLmt=119
+        self.CellTempLwLmt=-39
+        self.CellTempRate=5
+
+        self.temp_time=60
+        self.volt_time=60
 
         self.SocJump=10
         self.SocClamp=0.1

+ 150 - 97
LIB/MIDDLE/SaftyCenter/DataDiag_Static/CBMSBatDiag.py

@@ -55,9 +55,17 @@ class BatDiag:
         ah_accum=0  #SOC卡滞初始参数
         as_chg=0    #过流诊断初始参数
         as_dis=0    #过流诊断初始参数
-        time1=self.bmstime[0]   #温升速率初始参数
-        temp1=np.array(self._celltemp_get(0))   #温升速率初始参数
-        temprate_cnt=0
+        # time1=self.bmstime[0]   #温升速率初始参数
+        # temp1=np.array(self._celltemp_get(0))   #温升速率初始参数
+        # temprate_cnt=0
+        ot_time=0
+        ut_time=0
+        dt_time=0
+        cov_time=0
+        cuv_time=0
+        cdv_time=0
+        pov_time=0
+        puv_time=0
         
         end_time='0000-00-00 00:00:00'
             
@@ -76,19 +84,22 @@ class BatDiag:
             else:  
                 celltempvalid=1
            
-
             if celltempvalid==1:
                 #过温判断.............................................................................................................
                 if not 4 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if celltempmax0>self.param.CellTempHighLv2 and celltempmax1>self.param.CellTempHighLv2:    #二级高温进入
-                        time=self.bmstime[i]
-                        code=4
-                        faultlv=3
-                        faultinfo='温度{}高温二级'.format(celltemp1.index(celltempmax1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        ot_time=ot_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if ot_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=4
+                            faultlv=3
+                            faultinfo='温度{}高温二级'.format(celltemp1.index(celltempmax1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        ot_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if celltempmax0<self.param.CellTempHighLv1-5 and celltempmax1<self.param.CellTempHighLv1-5:    #二级高温恢复
                         time=self.bmstime[i]
@@ -99,14 +110,18 @@ class BatDiag:
                 #欠温判断.................................................................................................................
                 if not 6 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if celltempmin0<self.param.CellTempLowLv2 and celltempmin1<self.param.CellTempLowLv2:  #二级低温进入
-                        time=self.bmstime[i]
-                        code=6
-                        faultlv=3
-                        faultinfo='温度{}低温二级'.format(celltemp1.index(celltempmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        ut_time=ut_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if ut_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=6
+                            faultlv=3
+                            faultinfo='温度{}低温二级'.format(celltemp1.index(celltempmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        ut_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if celltempmax0>self.param.CellTempLowLv1+2 and celltempmax1>self.param.CellTempLowLv1+2:    #二级高温恢复
                         time=self.bmstime[i]
@@ -117,14 +132,18 @@ class BatDiag:
                 #温差判断.............................................................................................................................
                 if not 8 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if (celltempmax0-celltempmin0)>self.param.CellTempDiffLv2 and (celltempmax1-celltempmin1)>self.param.CellTempDiffLv2:  #二级温差进入
-                        time=self.bmstime[i]
-                        code=8
-                        faultlv=3
-                        faultinfo='温度{}和{}温差大二级'.format(celltemp1.index(celltempmax1)+1,celltemp1.index(celltempmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        dt_time=dt_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if dt_time>self.param.temp_time:
+                            time=self.bmstime[i]
+                            code=8
+                            faultlv=3
+                            faultinfo='温度{}和{}温差大二级'.format(celltemp1.index(celltempmax1)+1,celltemp1.index(celltempmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        dt_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if (celltempmax0-celltempmin0)<self.param.CellTempDiffLv1-2 and (celltempmax1-celltempmax0)>self.param.CellTempDiffLv1-2:  #二级温差恢复
                         time=self.bmstime[i]
@@ -161,9 +180,11 @@ class BatDiag:
             #     else:
             #         pass
             
-            # else:
-            #     pass
-            
+            else:
+                ot_time=0
+                ut_time=0
+                dt_time=0
+                    
             #电压诊断功能.................................................................................................
             cellvolt0=self._cellvolt_get(i-1)
             cellvolt1=self._cellvolt_get(i)
@@ -181,14 +202,18 @@ class BatDiag:
                 #过压诊断.............................................................................................................
                 if not 12 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if cellvoltmax0>self.param.CellOvLv2 and cellvoltmax1>self.param.CellOvLv2:  #二级过压进入
-                        time=self.bmstime[i]
-                        code=12
-                        faultlv=4
-                        faultinfo='电芯{}过压二级'.format(cellvolt1.index(cellvoltmax1)+1)
-                        faultadvice='联系用户询问用车场景,技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cov_time=cov_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cov_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=12
+                            faultlv=4
+                            faultinfo='电芯{}过压二级'.format(cellvolt1.index(cellvoltmax1)+1)
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cov_time=0
                 else:   #ram当前故障中有该故障,则判断是否退出该故障
                     if cellvoltmax0<self.param.CellOvLv1-0.05 and cellvoltmax1<self.param.CellOvLv1-0.05:   #二级过压故障恢复
                         time=self.bmstime[i]
@@ -200,14 +225,18 @@ class BatDiag:
                 #欠压诊断.................................................................................................................
                 if not 14 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if cellvoltmin0<self.param.CellUvLv2 and cellvoltmin1<self.param.CellUvLv2:  #二级欠压
-                        time=self.bmstime[i]
-                        code=14
-                        faultlv=3
-                        faultinfo='电芯{}欠压二级'.format(cellvolt1.index(cellvoltmin1)+1)
-                        faultadvice='联系用户询问用车场景,技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cuv_time=cuv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cuv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=14
+                            faultlv=3
+                            faultinfo='电芯{}欠压二级'.format(cellvolt1.index(cellvoltmin1)+1)
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cuv_time=0
                 else:
                     if cellvoltmin0>self.param.CellUvLv1+0.1 and cellvoltmin1>self.param.CellUvLv1+0.1:
                         time=self.bmstime[i]
@@ -218,14 +247,18 @@ class BatDiag:
                 #电芯压差大.....................................................................................................................................................
                 if not 16 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
                     if (cellvoltmax0-cellvoltmin0)>self.param.CellVoltDiffLv2 and (cellvoltmax1-cellvoltmin1)>self.param.CellVoltDiffLv2:  #二级电芯压差
-                        time=self.bmstime[i]
-                        code=16
-                        faultlv=3
-                        faultinfo='电芯{}和{}压差大二级'.format(cellvolt1.index(cellvoltmax1)+1,cellvolt1.index(cellvoltmin1)+1)
-                        faultadvice='技术介入诊断'
-                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        cdv_time=cdv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if cdv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=16
+                            faultlv=3
+                            faultinfo='电芯{}和{}压差大二级'.format(cellvolt1.index(cellvoltmax1)+1,cellvolt1.index(cellvoltmin1)+1)
+                            faultadvice='技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
                     else:
-                        pass
+                        cdv_time=0
                 else:
                     if (cellvoltmax0-cellvoltmin0)<self.param.CellVoltDiffLv1-0.05 and (cellvoltmax1-cellvoltmin1)<self.param.CellVoltDiffLv1-0.05: #二级欠压恢复
                         time=self.bmstime[i]
@@ -233,43 +266,61 @@ class BatDiag:
                     else:
                         pass
             else:
-                pass
+                cov_time=0
+                cuv_time=0
+                cdv_time=0
                 
             #电池包诊断.....................................................................................................................................
-            if not 18 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if self.packvolt[i-1]>self.param.PackVoltOvLv2 and self.packvolt[i]>self.param.PackVoltOvLv2:   #电池包过压二级进入
-                    time=self.bmstime[i]
-                    code=18
-                    faultlv=4
-                    faultinfo='电池包过压二级'
-                    faultadvice='联系用户询问用车场景,技术介入诊断'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
-                else:
-                    pass
+            if self.packvolt[i-1]<2*self.param.CellVoltNums and self.packvolt[i]>4.5*self.param.CellVoltNums:   #电池包电压有效性
+                packvoltvalid=0
             else:
-                if self.packvolt[i-1]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums and self.packvolt[i]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums: #电池包过压二级恢复
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==18].index, 'end_time'] = time
+                packvoltvalid=1
+
+            if packvoltvalid==1:
+                if not 18 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if self.packvolt[i-1]>self.param.PackVoltOvLv2 and self.packvolt[i]>self.param.PackVoltOvLv2:   #电池包过压二级进入
+                        pov_time=pov_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if pov_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=18
+                            faultlv=4
+                            faultinfo='电池包过压二级'
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
+                    else:
+                        pov_time=0
                 else:
-                    pass
+                    if self.packvolt[i-1]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums and self.packvolt[i]<self.param.PackVoltOvLv1-0.05*self.param.CellVoltNums: #电池包过压二级恢复
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==18].index, 'end_time'] = time
+                    else:
+                        pass
           
-            #电池包诊断.....................................................................................................................................
-            if not 20 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if self.packvolt[i-1]<self.param.PackVoltUvLv2 and self.packvolt[i]<self.param.PackVoltUvLv2:   #电池包二级欠压进入
-                    time=self.bmstime[i]
-                    code=20
-                    faultlv=3
-                    faultinfo='电池包欠压二级'
-                    faultadvice='联系用户询问用车场景,技术介入诊断'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                if not 20 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if self.packvolt[i-1]<self.param.PackVoltUvLv2 and self.packvolt[i]<self.param.PackVoltUvLv2:   #电池包二级欠压进入
+                        puv_time=puv_time+(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
+                        if puv_time>self.param.volt_time:
+                            time=self.bmstime[i]
+                            code=20
+                            faultlv=3
+                            faultinfo='电池包欠压二级'
+                            faultadvice='联系用户询问用车场景,技术介入诊断'
+                            self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                        else:
+                            pass
+                    else:
+                        puv_time=0
                 else:
-                    pass
+                    if self.packvolt[i-1]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums and self.packvolt[i]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums:   #电池包二级欠压恢复
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==20].index, 'end_time'] = time
+                    else:
+                        pass
             else:
-                if self.packvolt[i-1]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums and self.packvolt[i]>self.param.PackVoltUvLv1+0.1*self.param.CellVoltNums:   #电池包二级欠压恢复
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==20].index, 'end_time'] = time
-                else:
-                    pass
+                pov_time=0
+                puv_time=0
             
             #电流过流诊断.......................................................................................................................
             step=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
@@ -322,26 +373,28 @@ class BatDiag:
             else:
                 pass
             #SOC卡滞............................................................................................................
-            bmssoc_now=float(self.bms_soc[i])
-            if not 27 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
-                if abs(ah_accum)>self.param.Capacity*0.05 and abs(bmssoc_now-bmssoc_st)<self.param.SocClamp:   #SOC卡滞故障进入
-                    bmssoc_st=bmssoc_now
-                    ah_accum=0
-                    time=self.bmstime[i]
-                    code=27
-                    faultlv=1
-                    faultinfo='电池SOC卡滞'
-                    faultadvice='技术介入诊断,检修电池BMS软件'
-                    self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+            if abs(ah_accum)>self.param.Capacity*0.1:   
+                bmssoc_now=float(self.bms_soc[i])
+                if not 27 in list(self.df_diag_ram['code']):  #当前故障中没有该故障,则判断是否发生该故障
+                    if abs(bmssoc_now-bmssoc_st)<self.param.SocClamp:   #SOC卡滞故障进入
+                        time=self.bmstime[i]
+                        code=27
+                        faultlv=1
+                        faultinfo='电池SOC卡滞'
+                        faultadvice='技术介入诊断,检修电池BMS软件'
+                        self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+                    else:
+                        pass
                 else:
-                    pass
+                    if abs(bmssoc_now-bmssoc_st)>self.param.SocClamp:   #SOC卡滞故障退出
+                        time=self.bmstime[i]
+                        self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==27].index, 'end_time'] = time
+                    else:
+                        pass
+                bmssoc_st=bmssoc_now
+                ah_accum=0
             else:
-                if abs(bmssoc_now-bmssoc_st)>self.param.SocClamp:   #SOC卡滞故障退出
-                    time=self.bmstime[i]
-                    self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==27].index, 'end_time'] = time
-                else:
-                    pass
-            
+                pass
 
             #SOC跳变....................................................................................................................
             bmssoc_last=float(self.bms_soc[i-1])