FU6812做高压无感FOC吊扇控制,怎么在上电后快速检测是否有插电机?缺相是启动后检测,但不插电机需要报故障怎么检测?
void Fault_Detection(void)
{
mcFaultDect.segment++;
if(mcFaultDect.segment>=5)
{
mcFaultDect.segment=0;
}
if(mcFaultDect.segment==0)
{
if(CurrentRecoverEnable)
{
Fault_OverCurrentRecover(&mcFaultDect);
}
}
else if(mcFaultDect.segment==1)
{
if(VoltageProtectEnable==1)
{
Fault_OverUnderVoltage(&mcFaultDect);
}
}
else if(mcFaultDect.segment==2)
{
if(StartProtectEnable==1)
{
Fault_Start(&mcFaultDect);
}
}
else if(mcFaultDect.segment==3)
{
if(StallProtectEnable==1)
{
Fault_Stall(&mcFaultDect);
}
}
else if(mcFaultDect.segment==4)
{
if(PhaseLossProtectEnable==1)
{
Fault_phaseloss(&mcFaultDect);
}
}
else
{
}
}
void Fault_phaseloss(FaultVarible *h_Fault)
{
if(mcState == mcRun)
{
h_Fault->Lphasecnt++;
if(h_Fault->Lphasecnt>100)
{
h_Fault->Lphasecnt=0;
if((mcCurVarible.Max_ia<PhaseLossLowCurrent)&&(mcCurVarible.Max_ib>PhaseLossHighCurrent)&&(mcCurVarible.Max_ic>PhaseLossHighCurrent))
{
h_Fault->AOpencnt++;
}
else
{
h_Fault->AOpencnt =0;
}
if((mcCurVarible.Max_ib<PhaseLossLowCurrent)&&(mcCurVarible.Max_ia>PhaseLossHighCurrent)&&(mcCurVarible.Max_ic>PhaseLossHighCurrent))
{
h_Fault->BOpencnt++;
}
else
{
if(h_Fault->BOpencnt>0)
h_Fault->BOpencnt --;
}
if((mcCurVarible.Max_ic<PhaseLossLowCurrent)&&(mcCurVarible.Max_ib>PhaseLossHighCurrent)&&(mcCurVarible.Max_ia>PhaseLossHighCurrent))
{
h_Fault->COpencnt++;
}
else
{
if(h_Fault->COpencnt>0)
h_Fault->COpencnt --;
}
mcCurVarible.Max_ia = 0;
mcCurVarible.Max_ib = 0;
mcCurVarible.Max_ic = 0;
if(h_Fault->AOpencnt > 1|| h_Fault->BOpencnt > 1 || h_Fault->COpencnt > 1)
{
mcProtectTime.LossPHTimes++;
mcFaultSource=FaultLossPhase;
FaultProcess();
SetBuzzer(1, 1, 2);
}
}
}
{
if((mcFaultSource==FaultLossPhase)&&(mcState == mcFault)&&
(mcProtectTime.LossPHTimes<5))
{
h_Fault->mcLossPHRecCount++;
if(h_Fault->mcLossPHRecCount>=PhaseLossRecoverTime)
{
h_Fault->AOpencnt=0;
h_Fault->BOpencnt=0;
h_Fault->COpencnt=0;
mcState = mcReady;
mcFaultSource=FaultNoSource;
}
}
else
{
h_Fault->mcLossPHRecCount=0;
}
}
}
void MC_Control(void)
{
switch(mcState)
{
case mcReady:
Motor_Ready();
if((mcCurOffset.OffsetFlag == 1) && (mcSpeedRamp.FlagONOFF == 1)) mcState = mcInit;
break;
case mcInit:
Motor_Init();
FOC_Init();
mcState = mcCharge;
mcFocCtrl.State_Count = 0;
break;
case mcCharge:
Motor_Charge();
#if (IPMState == NormalRun)
if( mcFocCtrl.State_Count == 0)
{
if(mcFocCtrl.mcChargeStep == 0)
{
MOE = 0;
mcState = mcTailWind;
mcFocCtrl.State_Count = 40;
}
else if(mcFocCtrl.mcChargeStep == 1)
{
MOE = 0;
mcState = mcPosiCheck;
}
}
#endif
break;
case mcTailWind:
#if (TailWind_Mode == NoTailWind)
mcState = mcPosiCheck;
McStaSet.SetFlag.PosiCheckSetFlag = 0;
mcFocCtrl.mcPosCheckAngle = 0xffff;
#elif (TailWind_Mode == TailWind)
Motor_TailWind();
#endif
break;
case mcPosiCheck:
#if (PosCheckEnable==0)
mcFocCtrl.mcPosCheckAngle = Align_Angle;
mcState = mcAlign;
mcFocCtrl.State_Count = Align_Time;
#else
RPD();
#endif
break;
case mcAlign:
Motor_Align();
#if (AlignTestMode==1)
while(1);
#else
if(mcFocCtrl.State_Count == 0) mcState = mcStart;
#endif
break;
case mcStart:
Motor_Open();
break;
case mcPllTect:
#if (EstimateAlgorithm == PLL)
Motor_PllStart();
#endif
break;
case mcRun:
if(mcSpeedRamp.TargetValue == 0)
{
mcState = mcStop;
mcFocCtrl.State_Count = 6000;
}
break;
case mcStop:
if((mcFocCtrl.SpeedFlt<Motor_Min_Speed)||(mcFocCtrl.State_Count==0))
{
#if (StopBrakeFlag == 0)
if(mcFocCtrl.mcIqref > POWER_OFF_CURRENT)
{
mcFocCtrl.mcIqref-= 5;
FOC_IQREF = mcFocCtrl.mcIqref;
PI_UK = mcFocCtrl.mcIqref;
}
else
{
mcState = mcReady;
MOE=0;
FOC_CR1 = 0x00;
ClrBit(DRV_CR, FOCEN);
}
#else
if(mcFocCtrl.SpeedFlt < Motor_Stop_Speed)
{
MOE = 0;
FOC_CR1 = 0x00;
ClrBit(DRV_CR, FOCEN);
DRV_DR = DRV_ARR+1;
DRV_CMR &= 0xFFC0;
DRV_CMR |= 0x015;
ClrBit(DRV_CR, OCS);
MOE = 1;
mcState = mcBrake;
mcFocCtrl.State_Count = StopWaitTime;
}
#endif
}
else if(mcSpeedRamp.TargetValue > 0)
{
mcState = mcRun;
mcFocCtrl.State_Count = 0;
}
break;
case mcBrake:
if(mcFocCtrl.State_Count == 0)
{
mcState = mcReady;
MOE=0;
ClrBit(DRV_CR, FOCEN);
}
break;
case mcFault:
break;
}
}