Преглед на файлове

V3.2.6_20211012
1、修改I2C的驱动,解决频繁封波导致电机出线异常;
2、增加清除历史记录的指令。

dail преди 3 години
родител
ревизия
cd1a04bae4

+ 0 - 203
Drivers/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_shift_q31.c

@@ -1,203 +0,0 @@
-/* ----------------------------------------------------------------------    
-* Copyright (C) 2010-2014 ARM Limited. All rights reserved.    
-*    
-* $Date:        19. March 2015
-* $Revision: 	V.1.4.5
-*    
-* Project: 	    CMSIS DSP Library    
-* Title:		arm_shift_q31.c    
-*    
-* Description:	Shifts the elements of a Q31 vector by a specified number of bits.    
-*    
-* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
-*  
-* Redistribution and use in source and binary forms, with or without 
-* modification, are permitted provided that the following conditions
-* are met:
-*   - Redistributions of source code must retain the above copyright
-*     notice, this list of conditions and the following disclaimer.
-*   - Redistributions in binary form must reproduce the above copyright
-*     notice, this list of conditions and the following disclaimer in
-*     the documentation and/or other materials provided with the 
-*     distribution.
-*   - Neither the name of ARM LIMITED nor the names of its contributors
-*     may be used to endorse or promote products derived from this
-*     software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE. 
-* -------------------------------------------------------------------- */
-
-#include "arm_math.h"
-
-/**        
- * @ingroup groupMath        
- */
-/**        
- * @defgroup shift Vector Shift        
- *        
- * Shifts the elements of a fixed-point vector by a specified number of bits.        
- * There are separate functions for Q7, Q15, and Q31 data types.        
- * The underlying algorithm used is:        
- *        
- * <pre>        
- *     pDst[n] = pSrc[n] << shift,   0 <= n < blockSize.        
- * </pre>        
- *        
- * If <code>shift</code> is positive then the elements of the vector are shifted to the left.        
- * If <code>shift</code> is negative then the elements of the vector are shifted to the right.        
- *
- * The functions support in-place computation allowing the source and destination
- * pointers to reference the same memory buffer.
- */
-
-/**        
- * @addtogroup shift        
- * @{        
- */
-
-/**        
- * @brief  Shifts the elements of a Q31 vector a specified number of bits.        
- * @param[in]  *pSrc points to the input vector        
- * @param[in]  shiftBits number of bits to shift.  A positive value shifts left; a negative value shifts right.        
- * @param[out]  *pDst points to the output vector        
- * @param[in]  blockSize number of samples in the vector        
- * @return none.        
- *        
- *        
- * <b>Scaling and Overflow Behavior:</b>        
- * \par        
- * The function uses saturating arithmetic.        
- * Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] will be saturated.        
- */
-
-void arm_shift_q31(
-  q31_t * pSrc,
-  int8_t shiftBits,
-  q31_t * pDst,
-  uint32_t blockSize)
-{
-  uint32_t blkCnt;                               /* loop counter */
-  uint8_t sign = (shiftBits & 0x80);             /* Sign of shiftBits */
-
-#ifndef ARM_MATH_CM0_FAMILY
-
-  q31_t in1, in2, in3, in4;                      /* Temporary input variables */
-  q31_t out1, out2, out3, out4;                  /* Temporary output variables */
-
-  /*loop Unrolling */
-  blkCnt = blockSize >> 2u;
-
-
-  if(sign == 0u)
-  {
-    /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.    
-     ** a second loop below computes the remaining 1 to 3 samples. */
-    while(blkCnt > 0u)
-    {
-      /* C = A  << shiftBits */
-      /* Shift the input and then store the results in the destination buffer. */
-      in1 = *pSrc;
-      in2 = *(pSrc + 1);
-      out1 = in1 << shiftBits;
-      in3 = *(pSrc + 2);
-      out2 = in2 << shiftBits;
-      in4 = *(pSrc + 3);
-      if(in1 != (out1 >> shiftBits))
-        out1 = 0x7FFFFFFF ^ (in1 >> 31);
-
-      if(in2 != (out2 >> shiftBits))
-        out2 = 0x7FFFFFFF ^ (in2 >> 31);
-
-      *pDst = out1;
-      out3 = in3 << shiftBits;
-      *(pDst + 1) = out2;
-      out4 = in4 << shiftBits;
-
-      if(in3 != (out3 >> shiftBits))
-        out3 = 0x7FFFFFFF ^ (in3 >> 31);
-
-      if(in4 != (out4 >> shiftBits))
-        out4 = 0x7FFFFFFF ^ (in4 >> 31);
-
-      *(pDst + 2) = out3;
-      *(pDst + 3) = out4;
-
-      /* Update destination pointer to process next sampels */
-      pSrc += 4u;
-      pDst += 4u;
-
-      /* Decrement the loop counter */
-      blkCnt--;
-    }
-  }
-  else
-  {
-
-    /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.    
-     ** a second loop below computes the remaining 1 to 3 samples. */
-    while(blkCnt > 0u)
-    {
-      /* C = A >>  shiftBits */
-      /* Shift the input and then store the results in the destination buffer. */
-      in1 = *pSrc;
-      in2 = *(pSrc + 1);
-      in3 = *(pSrc + 2);
-      in4 = *(pSrc + 3);
-
-      *pDst = (in1 >> -shiftBits);
-      *(pDst + 1) = (in2 >> -shiftBits);
-      *(pDst + 2) = (in3 >> -shiftBits);
-      *(pDst + 3) = (in4 >> -shiftBits);
-
-
-      pSrc += 4u;
-      pDst += 4u;
-
-      blkCnt--;
-    }
-
-  }
-
-  /* If the blockSize is not a multiple of 4, compute any remaining output samples here.    
-   ** No loop unrolling is used. */
-  blkCnt = blockSize % 0x4u;
-
-#else
-
-  /* Run the below code for Cortex-M0 */
-
-
-  /* Initialize blkCnt with number of samples */
-  blkCnt = blockSize;
-
-#endif /* #ifndef ARM_MATH_CM0_FAMILY */
-
-
-  while(blkCnt > 0u)
-  {
-    /* C = A (>> or <<) shiftBits */
-    /* Shift the input and then store the result in the destination buffer. */
-    *pDst++ = (sign == 0u) ? clip_q63_to_q31((q63_t) * pSrc++ << shiftBits) :
-      (*pSrc++ >> -shiftBits);
-
-    /* Decrement the loop counter */
-    blkCnt--;
-  }
-
-
-}
-
-/**        
- * @} end of shift group        
- */

Файловите разлики са ограничени, защото са твърде много
+ 2493 - 2493
MDK-ARM/QD007A_CTL_APP/QD007A_CTL_APP_CRC.hex


BIN
MDK-ARM/bin/MC_TTKZ010A_V3.2.6_20211012.bin


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 4 - 15
User/Src/I2C_Analog.c

@@ -2,23 +2,12 @@
 
 static void _SDA_IN(I2C_Handle_Struct_t* I2C_Handle)
 {
-  GPIO_InitTypeDef GPIO_InitStruct;
-
-  GPIO_InitStruct.Pin = I2C_Handle->SDA_GPIO_Pin;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-	GPIO_InitStruct.Pull = GPIO_PULLUP;
-  HAL_GPIO_Init(I2C_Handle->SDA_GPIOx, &GPIO_InitStruct);
+	HAL_GPIO_WritePin(I2C_Handle->SDA_GPIOx, I2C_Handle->SDA_GPIO_Pin, GPIO_PIN_SET);
 }
 
 static void _SDA_OUT(I2C_Handle_Struct_t* I2C_Handle)
 {
-  GPIO_InitTypeDef GPIO_InitStruct;
-
-  GPIO_InitStruct.Pin = I2C_Handle->SDA_GPIO_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
-  HAL_GPIO_Init(I2C_Handle->SDA_GPIOx, &GPIO_InitStruct);
+	__NOP();
 }
 
 static void _GPIO_CLK_Init(GPIO_TypeDef* GPIOx)
@@ -59,12 +48,12 @@ void I2C_GPIO_Config(I2C_Handle_Struct_t* I2C_Handle)
 
   GPIO_InitStruct.Pin = I2C_Handle->SCL_GPIO_Pin;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
   HAL_GPIO_Init(I2C_Handle->SCL_GPIOx, &GPIO_InitStruct);
 	
 	GPIO_InitStruct.Pin = I2C_Handle->SDA_GPIO_Pin;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
   HAL_GPIO_Init(I2C_Handle->SDA_GPIOx, &GPIO_InitStruct);
 }
 

+ 10 - 1
User/Src/can_process.c

@@ -720,7 +720,16 @@ void DataProcess(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
 					SendData(ID_MC_TO_CDL, MODE_REPORT, 0xB002, Data);
 					break;
 				}
-				
+				case 0x3909://Çå³ýÀúÊ·ÐÅÏ¢
+				{
+				  if(strncmp("LOG CLEAR", (char*)Data, DataLength) == 0)
+					{
+					  Var_SetToDefaultLog();
+						EEPROM_24C02_LogReset(&I2C_Handle_EEPROM);
+						SendData(ID_MC_TO_CDL, MODE_REPORT, 0xA903, (uint8_t*)"ACK");
+					}
+					break;
+				}
 				default:break;
 			}
 			break;

+ 63 - 59
User/Src/protect_check.c

@@ -304,9 +304,48 @@ void MC_Protect_VoltageChange_Process(uint16_t Voltage, uint16_t Current, MC_Err
 	}
 }
 
+//软件过流保护检测
+void MC_OverCurrent_SoftProtect_Process(uint16_t BusCurrent, uint16_t MaxCurrent, MC_ErrorCode_Struct_t* p_MC_ErrorCode)
+{
+  static uint32_t Protect_TimeCnt = 0;
+	static uint32_t Fault_TimeCnt = 0;
+	uint16_t Current_Th;
+	
+	Current_Th = (MaxCurrent * 3) >> 1;//1.5倍
+	
+	if(p_MC_ErrorCode->ERROR_Bit.Protect_OverCurrent == 0)
+	{
+		if(BusCurrent < Current_Th)
+		{
+			Protect_TimeCnt = HAL_GetTick();
+		}
+		if((HAL_GetTick() - Protect_TimeCnt) > 5000)
+		{
+			p_MC_ErrorCode->ERROR_Bit.Protect_OverCurrent = 1;
+			//记录故障日志
+			MC_ErrorLogSaveInfo.NotesInfo1 = 2;
+			MC_ErrorLogSaveInfo.NotesInfo2 = Current_Th;
+			ErrorLogSave_Update(&MC_ErrorLogSaveInfo);
+		  IsErrorLogSaveInfoUpdateFlag = TRUE;
+			//存储故障次数
+			MC_RunLog1.OC_ProtectCnt++;
+			RunLogSaveIndex = 1;	
+			Fault_TimeCnt = HAL_GetTick();
+		}
+	}
+	else
+	{
+		//过流保护恢复
+		if((HAL_GetTick() - Fault_TimeCnt) > 5000)
+		{
+			MC_ErrorCode.ERROR_Bit.Protect_OverCurrent = 0;
+		}
+	}
+}
+
 /******************************全局函数定义******************************/
 #define OC_CLEARFLAG_DELAYTIME 15 //过流标志间隔清零延时,单位ms
-#define OC_COUNTER_TH 100          //过流保护计数判断阈值
+#define OC_COUNTER_TH 1000          //过流保护计数判断阈值
 //过流保护检测
 /*
 检测原理:
@@ -314,79 +353,42 @@ void MC_Protect_VoltageChange_Process(uint16_t Voltage, uint16_t Current, MC_Err
 2、在过流触发计数达到OC_COUNTER_TH 次之前,如果存在两次过流触发间隔时间超过OC_CLEARFLAG_DELAYTIME ms,清除过流触发计数;
 3、如果每两次过流触发间隔时间都不超过OC_CLEARFLAG_DELAYTIME ms,当过流触发计数达到OC_COUNTER_TH 次,则进入过流保护;
 4、进入过流保护后,超时5s解除。
+
+更改处理方式20210630
+1、关闭过流告警;
+2、出现过流信号时,封闭PWM2个周期
 */
 void MC_Protect_OverCurrent_Process(FlagStatus* OverCurrentTrigFlag, MC_ErrorCode_Struct_t* p_MC_ErrorCode)
 {
   static uint8_t OffPwmCnt = 0;        //过流信号触发后,关闭PWM延时计数
 	static uint8_t StarPwmCnt = 0;       //关闭PWM后启动PWM延时计数
-  static uint16_t ocCnt = 0;           //过流信号触发计数
-  static uint32_t ocTimeCnt = 0;       //过流信号触发计时
-	static uint32_t ocFaultTimeCnt = 0;  //过流保护后计时
 	
-	if(p_MC_ErrorCode->ERROR_Bit.Protect_OverCurrent == 0)
+	if(*OverCurrentTrigFlag == RESET)
 	{
-		if(*OverCurrentTrigFlag == RESET)
+		//关闭PWM计数清零
+		OffPwmCnt = 0;
+		//开启PWM
+		if(StarPwmCnt == 0)
 		{
-			//关闭PWM计数清零
-			OffPwmCnt = 0;
-			//两次过流触发间隔超时OC_CLEARFLAG_DELAYTIME ms,过流次数未达到OC_COUNTER_TH 次,过流计数清零
-			if(ocCnt < OC_COUNTER_TH)
-			{
-				if((HAL_GetTick() - ocTimeCnt) >= OC_CLEARFLAG_DELAYTIME)
-				{
-					ocTimeCnt = HAL_GetTick();
-					ocCnt = 0;
-				}
-			}
-			//开启PWM
-			if(StarPwmCnt == 0)
-			{
-				StarPwmCnt++;
-				Enable_PwmGpio_Out();
-			}
-		}
-		else
-		{
-			//开启PWM计数清零
-			StarPwmCnt = 0;
-			//关闭PWM
-			Disable_PwmGpio_Out();
-			//2个PWM周期后,过流触发标志复位
-			if(OffPwmCnt >= 1)
-			{
-				*OverCurrentTrigFlag = RESET;
-			}
-			//过流次数计数
-			if(ocCnt < OC_COUNTER_TH)
-			{
-				ocCnt++;
-			}
-			//过流标志计数次数达到OC_COUNTER_TH 次,启动过流保护
-			else
-			{
-				ocCnt = 0;
-				p_MC_ErrorCode->ERROR_Bit.Protect_OverCurrent = 1;
-				ocFaultTimeCnt = HAL_GetTick();
-				//记录故障日志
-			  ErrorLogSave_Update(&MC_ErrorLogSaveInfo);
-		  	IsErrorLogSaveInfoUpdateFlag = TRUE;
-				//存储故障次数
-				MC_RunLog1.OC_ProtectCnt++;
-				RunLogSaveIndex = 1;	
-			}
-			OffPwmCnt++;
-			ocTimeCnt = HAL_GetTick();
+			StarPwmCnt++;
+			Enable_PwmGpio_Out();
 		}
 	}
 	else
 	{
-		//过流恢复
-		if((HAL_GetTick() - ocFaultTimeCnt) > 5000)
+		//开启PWM计数清零
+		StarPwmCnt = 0;
+		//2个PWM周期后,过流触发标志复位
+		if(OffPwmCnt >= 1)
 		{
-			MC_ErrorCode.ERROR_Bit.Protect_OverCurrent = 0;
-			ocFaultTimeCnt = HAL_GetTick();
 			*OverCurrentTrigFlag = RESET;
 		}
+		else
+		{
+			//关闭PWM
+			Disable_PwmGpio_Out();
+		}
+		OffPwmCnt++;
 	}
 }
 
@@ -411,4 +413,6 @@ void MC_Protect_Check_Process(void)
 	//电压波动异常保护检测
 	MC_Protect_VoltageChange_Process(MC_RunInfo.BusVoltage, MC_RunInfo.BusCurrent, &MC_ErrorCode);
 	
+  //软件过流保护检测
+	MC_OverCurrent_SoftProtect_Process(MC_RunInfo.BusCurrent, MC_ConfigParam1.CurrentLimit * 1000, &MC_ErrorCode);
 }

+ 0 - 2
User/Src/pwm_driver.c

@@ -44,8 +44,6 @@ void	Enable_Pwm_Output(void)
 	HAL_TIMEx_PWMN_Start(&PWM_TIMER,TIM_CHANNEL_4);
 	
 	Pwm_Timer_Start();
-	HAL_NVIC_SetPriority(TIM1_BRK_IRQn, 0, 0);
-  HAL_NVIC_EnableIRQ(TIM1_BRK_IRQn);
 }
 
 /**

+ 2 - 0
User/Src/remain_distance.c

@@ -543,3 +543,5 @@ uint8_t Battery_SocCal(uint16_t Voltage_mV)
 		return Result;
 	}
 }
+
+

+ 1 - 5
User/Src/tim.c

@@ -184,11 +184,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
     /* Peripheral interrupt init*/
     HAL_NVIC_SetPriority(TIM1_UP_IRQn, 1, 1);
     HAL_NVIC_EnableIRQ(TIM1_UP_IRQn);
-		
-		HAL_NVIC_SetPriority(TIM1_BRK_IRQn, 0, 0);
-    HAL_NVIC_EnableIRQ(TIM1_BRK_IRQn);
-		
-		__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_BREAK);
+
   /* USER CODE BEGIN TIM1_MspInit 1 */
 
   /* USER CODE END TIM1_MspInit 1 */

+ 1 - 1
User/Src/var.c

@@ -491,7 +491,7 @@ void Var_Init(void)
 		
 	//MC版本信息初始化,Mode和SN从EEPROM读取
   strncpy(MC_VerInfo.HW_Version, (char*)"TT_KZ_010C/D.   ", 16);
-	strncpy(MC_VerInfo.FW_Version, (char*)"V3r2r6_20210928.", 16);
+	strncpy(MC_VerInfo.FW_Version, (char*)"V3r2r6_20211012.", 16);
 	strncpy(Firmware_Special, (char*)"TC011000-MS0000-V0r0.           ", 32);
 	
 	//电机型号

+ 3 - 1
修改说明.txt

@@ -386,7 +386,9 @@ V3.2.6_20210928
 2、针对开机后母线电压采集上升缓慢,优化SOC初始值的计算方法;
 3、增加前100km时,清除TRIP时可清除ODO。
 
-
+V3.2.6_20211012
+1、修改I2C的驱动,解决频繁封波导致电机出线异常;
+2、增加清除历史记录的指令。
 
 
 

Някои файлове не бяха показани, защото твърде много файлове са промени