浏览代码

feat:传感器故障测试完成

CN\guohui27 2 年之前
父节点
当前提交
63e93ec210

+ 25 - 25
User project/1.FrameLayer/Source/TimeTask_Event.c

@@ -229,14 +229,14 @@ void Event_10ms(void)
 //        Signal_detect();
       
         /* Use upper computer */
-//        if(cp_stFlg.RotateDirectionSelect == ForwardRotate)
-//        {
-//            uart_slSpdRefRpm = ((SLONG)MC_MotorSPD_rpm_Percent*5000)/100;
-//        }
-//        else if(cp_stFlg.RotateDirectionSelect == BackwardRotate)
-//        {
-//            uart_slSpdRefRpm = -((SLONG)MC_MotorSPD_rpm_Percent*5000)/100;
-//        }
+        if(cp_stFlg.RotateDirectionSelect == ForwardRotate)
+        {
+            uart_slSpdRefRpm = ((SLONG)MC_MotorSPD_rpm_Percent*5000)/100;
+        }
+        else if(cp_stFlg.RotateDirectionSelect == BackwardRotate)
+        {
+            uart_slSpdRefRpm = -((SLONG)MC_MotorSPD_rpm_Percent*5000)/100;
+        }
      
         /* bikespeed closeloop control  */
 //         bikemotorspdref();
@@ -295,23 +295,23 @@ void  Event_200ms(void)
     bikespeed_voGetBikeSpeedPwrError(adc_stUpOut.uwU5VPu);
 
     /* Bike faults 200ms detect */
-//    if((cp_stFlg.RunModelSelect == MountainBIKE) || (cp_stFlg.RunModelSelect == CityBIKE))
-//    {
-//        alm_stBikeIn.uwTroqReg = hw_uwADC0[7];
-//        alm_stBikeIn.uwTroqPu = torsensor_stTorSensorOut.uwTorquePu;
-//        alm_stBikeIn.blBikeSpdOvrFlg = bikespeed_stFreGetOut.blBikeSpeedSensorPwrErrorFlg;
-//        alm_stBikeIn.blCadenceFreqOvrFlg = cadence_stFreGetOut.blCadenceSensorErrorFlg;
-//        alm_stBikeIn.swMotorSpdDir = ass_CalIn.swDirection;
-//        alm_stBikeIn.swMotorSpdPu = scm_stSpdFbkLpf.slY.sw.hi;
-//        alm_stBikeIn.uwBikeSpdPu = bikespeed_stFreGetOut.uwFrequencyPu;
-//        alm_stBikeIn.uwCadenceFreqPu = cadence_stFreGetOut.uwFrequencyPu;
-//        alm_stBikeIn.uwMotorNTCReg = adc_stUpOut.MotorTempReg;
-//        alm_stBikeIn.uwPCBNTCReg = adc_stUpOut.PCBTempReg;
-//        alm_stBikeIn.uwThrottleReg = adc_stUpOut.uwThrottleReg;
-//        alm_stBikeIn.blThrottleExistFlg = FALSE;
-//        alm_stBikeIn.blMotorNTCExistFlg = FALSE;
-//        alm_voDetec200MS(&alm_stBikeIn, &alm_stDetect200MSCoef);   
-//    }
+    if((cp_stFlg.RunModelSelect == MountainBIKE) || (cp_stFlg.RunModelSelect == CityBIKE))
+    {
+        alm_stBikeIn.uwTroqReg = torsensor_stTorSensorOut.uwTorqueReg;
+        alm_stBikeIn.uwTroqPu = torsensor_stTorSensorOut.uwTorqueLPFPu;//torsensor_stTorSensorOut.uwTorquePu;
+        alm_stBikeIn.blBikeSpdOvrFlg = bikespeed_stFreGetOut.blBikeSpeedSensorPwrErrorFlg;
+        alm_stBikeIn.blCadenceFreqOvrFlg = cadence_stFreGetOut.blCadenceSensorErrorFlg;
+        alm_stBikeIn.swMotorSpdDir = ass_CalIn.swDirection;
+        alm_stBikeIn.swMotorSpdPu = scm_stSpdFbkLpf.slY.sw.hi;
+        alm_stBikeIn.uwBikeSpdPu = bikespeed_stFreGetOut.uwFrequencyPu;
+        alm_stBikeIn.uwCadenceFreqPu = cadence_stFreGetOut.uwFrequencyPu;
+        alm_stBikeIn.uwMotorNTCReg = adc_stUpOut.MotorTempReg;
+        alm_stBikeIn.uwPCBNTCReg = adc_stUpOut.PCBTempReg;
+        alm_stBikeIn.uwThrottleReg = adc_stUpOut.uwThrottleReg;
+        alm_stBikeIn.blThrottleExistFlg = FALSE;
+        alm_stBikeIn.blMotorNTCExistFlg = FALSE;
+        alm_voDetec200MS(&alm_stBikeIn, &alm_stDetect200MSCoef);   
+    }
     
     if (switch_flg.SysFault_Flag == TRUE)
     {

+ 1 - 1
User project/2.MotorDrive/Source/adc.c

@@ -272,7 +272,7 @@ void adc_voSampleDown(ADC_COF *cof, ADC_DOWN_OUT *out)
         out->slSampIaPu = -((SLONG)((SLONG)out->uwIaReg - (SLONG)cof->uwIaOffset) * cof->uwCurReg2Pu >> 10); // Q14=Q24-Q10
         out->slSampIbPu = -((SLONG)((SLONG)out->uwIbReg - (SLONG)cof->uwIbOffset) * cof->uwCurReg2Pu >> 10); // Q14=Q24-Q10
         out->slSampIcPu = -((SLONG)((SLONG)out->uwIcReg - (SLONG)cof->uwIcOffset) * cof->uwCurReg2Pu >> 10); // Q14=Q24-Q10
-        cof->uwCalibcoef = 1048;
+        
         out->swIaPu = ((SLONG)out->slSampIaPu * cof->uwCalibcoef) >> 10;
         out->swIbPu = ((SLONG)out->slSampIbPu * cof->uwCalibcoef) >> 10;
         out->swIcPu = ((SLONG)out->slSampIcPu * cof->uwCalibcoef) >> 10;

+ 0 - 59
User project/2.MotorDrive/Source/alarm.c

@@ -1223,65 +1223,6 @@ Reference:
 ****************************************************************/
 void alm_voDetec200MS(ALM_BIKE_IN *in, ALM_DETEC200MS_COF *coef)
 { 
-    /** use motor speed **/
-//    if(((in->swMotorSpdPu > coef->swMotorSpdMinPu) && (in->swMotorSpdDir > 0)) ||  ((in->swMotorSpdPu < -coef->swMotorSpdMinPu) && (in->swMotorSpdDir < 0)))
-//    {
-//      /* Bike speed sensor fault */
-//      if(in->uwBikeSpdPu == 0)
-//      {
-//          alm_stDecCt.uwBikeSpdFlt ++;
-//          if(alm_stDecCt.uwBikeSpdFlt >= coef->uwBikeSpdFltCt)
-//          {
-//              alm_stDecCt.uwBikeSpdFlt = coef->uwBikeSpdFltCt;
-//              alm_unBikeCode.bit.BikeSpdSen = TRUE;
-//              alm_unAction.bit.PWMOff = TRUE;
-//          }        
-//      }
-//      else if(in->blBikeSpdOvrFlg)
-//      {        
-//          alm_unBikeCode.bit.BikeSpdSen = TRUE;
-//          alm_unAction.bit.PWMOff = TRUE;
-//      }
-//      else
-//      {
-//          alm_stDecCt.uwBikeSpdFlt = 0;
-//      }
-//      
-//      /* Bike cadence sensor fault */
-//      if(in->uwTroqPu > ass_CalCoef.uwAssThreshold)
-//      {
-//          if(in->uwCadenceFreqPu == 0)
-//          {
-//              alm_stDecCt.uwCadenceFlt ++;
-//              if(alm_stDecCt.uwCadenceFlt >= coef->uwCadenceFltCt)
-//              {
-//                  alm_stDecCt.uwCadenceFlt = coef->uwCadenceFltCt;
-//                  alm_unBikeCode.bit.CadenceSen = TRUE;
-//                  alm_unAction.bit.PWMOff = TRUE;
-//              }
-//          }
-//          else if(in->blCadenceFreqOvrFlg)
-//          {
-//              alm_unBikeCode.bit.CadenceSen = TRUE;
-//              alm_unAction.bit.PWMOff = TRUE;      
-//          }
-//          else
-//          {
-//              alm_stDecCt.uwCadenceFlt = 0;
-//          }
-//      }
-//      else
-//      {
-//          alm_stDecCt.uwCadenceFlt = 0;
-//      }
-//
-//    }
-//    else
-//    {
-//          alm_stDecCt.uwBikeSpdFlt = 0;
-//          alm_stDecCt.uwCadenceFlt = 0;
-//    }
-//    
     /** Bike sensors judge each other **/
     /* Bike speed sensor fault */
     if(in->uwCadenceFreqPu > 0)

+ 2 - 2
User project/3.BasicFunction/Include/bikespeed.h

@@ -21,9 +21,9 @@
  *
  ****************************************/
 #define BIKESPEED_NUMBERS_PULSES           1     // numbers of pulses per cycles
-#define BIKESPEED_START_INTERVALTIME       10000 // interveal time of detect valid pulses, ms
+#define BIKESPEED_START_INTERVALTIME       10000 //10000 // interveal time of detect valid pulses, ms
 #define BIKESPEED_NUMBERS_VALIDPULSE2START 1     // numbers of valid pulses that needed to start
-#define BIKESPEED_HF_MINTIME               4000  //3000  // Min time of valid pulses, ms
+#define BIKESPEED_HF_MINTIME               30000 //4000  //3000  // Min time of valid pulses, ms
 #define BIKESPEED_ERROR_RESETTIME          5000  // TIMER PERIOD,ms
 #define BIKESPEED_TIM_TIMERUNIT            25    // TIMER PERIOD,ms
 #define BIKESPEED_LPF_GAIN                 80    //%

+ 1 - 1
User project/3.BasicFunction/Source/bikespeed.c

@@ -77,7 +77,7 @@ static void bikespeed_voBikeSpeedIdle(UWORD source)
     if (source == 1)
     {
         bikespeed_stFreGetOut.uwCaputureOverflowCnt++;
-        if (bikespeed_stFreGetOut.uwCaputureOverflowCnt > (30000 / bikespeed_stFreGetCof.uwTimerUnit)) //  3s
+        if (bikespeed_stFreGetOut.uwCaputureOverflowCnt > (30000 / bikespeed_stFreGetCof.uwTimerUnit)) //  30s
         {
             bikespeed_stFreGetOut.uwCaputureOverflowCnt = 0;
         }

+ 1 - 1
User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/CodePara.c

@@ -46,7 +46,7 @@ void CodeParaInit(void)
 }
 #elif (MOTOR_ID_SEL == MOTOR_WELLING_MTB)
 {
-    cp_stFlg.RunModelSelect = ClZLOOP;//ClZLOOP; 
+    cp_stFlg.RunModelSelect = MountainBIKE;//ClZLOOP; MountainBIKE
     cp_stFlg.RotateDirectionSelect = ForwardRotate;
 }
 #endif