|
@@ -45,6 +45,8 @@ void Speed_response(void)
|
|
|
|
|
|
|
|
if ((mcState == mcRun) || (mcState == mcStop))
|
|
if ((mcState == mcRun) || (mcState == mcStop))
|
|
|
{
|
|
{
|
|
|
|
|
+ #if 0
|
|
|
|
|
+
|
|
|
if (mcFocCtrl.RunStateCnt < MotorStartHoldTime) // MotorStartHoldTime目标转速为启动转速
|
|
if (mcFocCtrl.RunStateCnt < MotorStartHoldTime) // MotorStartHoldTime目标转速为启动转速
|
|
|
{
|
|
{
|
|
|
mcSpeedRamp.IncValue = SpeedRampStartInc;
|
|
mcSpeedRamp.IncValue = SpeedRampStartInc;
|
|
@@ -75,17 +77,17 @@ void Speed_response(void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ #endif
|
|
|
|
|
+
|
|
|
switch (mcFocCtrl.CtrlMode)
|
|
switch (mcFocCtrl.CtrlMode)
|
|
|
{
|
|
{
|
|
|
case 0:
|
|
case 0:
|
|
|
{
|
|
{
|
|
|
if (motorControl.ActualSpeed > MOTOR_LOOP_RPM)
|
|
if (motorControl.ActualSpeed > MOTOR_LOOP_RPM)
|
|
|
{
|
|
{
|
|
|
- if (Start_CNT < 15)
|
|
|
|
|
- {
|
|
|
|
|
- Start_CNT ++;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ Start_CNT ++;
|
|
|
|
|
+
|
|
|
|
|
+ if (Start_CNT > 15)
|
|
|
{
|
|
{
|
|
|
mcFocCtrl.CtrlMode = 1;
|
|
mcFocCtrl.CtrlMode = 1;
|
|
|
Start_CNT = 0;
|
|
Start_CNT = 0;
|
|
@@ -95,7 +97,7 @@ void Speed_response(void)
|
|
|
mcFocCtrl.LoopTime = SPEED_LOOP_TIME;
|
|
mcFocCtrl.LoopTime = SPEED_LOOP_TIME;
|
|
|
mcFocCtrl.IND_DEC_LoopTime = SPEED_INC_DEC_TIME;
|
|
mcFocCtrl.IND_DEC_LoopTime = SPEED_INC_DEC_TIME;
|
|
|
PI0_UKH = mcFocCtrl.mcIqref;
|
|
PI0_UKH = mcFocCtrl.mcIqref;
|
|
|
- mcFocCtrl.IsRef = mcFocCtrl.mcIqref;
|
|
|
|
|
|
|
+ mcFocCtrl.IsRef = mcFocCtrl.mcIqref;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -125,26 +127,14 @@ void Speed_response(void)
|
|
|
}
|
|
}
|
|
|
#else
|
|
#else
|
|
|
{
|
|
{
|
|
|
- mcFocCtrl.mcIqref = FOC_IQREF;
|
|
|
|
|
-
|
|
|
|
|
- if (FOC_IQREF < motorControl.QOutRef)
|
|
|
|
|
- {
|
|
|
|
|
- mcFocCtrl.mcIqref += QOUTINC;
|
|
|
|
|
|
|
+ motorControl.ActualQOutValue = FOC_IQREF;
|
|
|
|
|
|
|
|
- if (mcFocCtrl.mcIqref > motorControl.QOutRef)
|
|
|
|
|
- { mcFocCtrl.mcIqref = motorControl.QOutRef; }
|
|
|
|
|
-
|
|
|
|
|
- FOC_IQREF = mcFocCtrl.mcIqref;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (motorControl.ActualQOutValue < motorControl.QOutRef)
|
|
|
|
|
+ { motorControl.ActualQOutValue += QOUTINC; }
|
|
|
else if (FOC_IQREF > motorControl.QOutRef)
|
|
else if (FOC_IQREF > motorControl.QOutRef)
|
|
|
- {
|
|
|
|
|
- mcFocCtrl.mcIqref -= QOUTINC;
|
|
|
|
|
-
|
|
|
|
|
- if (mcFocCtrl.mcIqref < motorControl.QOutRef)
|
|
|
|
|
- { mcFocCtrl.mcIqref = motorControl.QOutRef; }
|
|
|
|
|
|
|
+ { motorControl.ActualQOutValue -= QOUTINC; }
|
|
|
|
|
|
|
|
- FOC_IQREF = mcFocCtrl.mcIqref;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ FOC_IQREF = motorControl.ActualQOutValue;
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
mcFocCtrl.LoopTime = 0;
|
|
mcFocCtrl.LoopTime = 0;
|
|
@@ -225,14 +215,6 @@ void StarRampDealwith(void)
|
|
|
{
|
|
{
|
|
|
if ((mcState == mcRun) || (mcState == mcStart))
|
|
if ((mcState == mcRun) || (mcState == mcStart))
|
|
|
{
|
|
{
|
|
|
- if ((mcFocCtrl.CtrlMode == 0) || (mcFocCtrl.State_Count > 10))
|
|
|
|
|
- {
|
|
|
|
|
- if (mcFocCtrl.iiqq <= IQ_Start_CURRENT2)
|
|
|
|
|
- {mcFocCtrl.iiqq = mcFocCtrl.iiqq + 2;}
|
|
|
|
|
-
|
|
|
|
|
- FOC_IQREF = mcFocCtrl.iiqq;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if (mcFocCtrl.State_Count == 1200) //2300
|
|
if (mcFocCtrl.State_Count == 1200) //2300
|
|
|
{
|
|
{
|
|
|
FOC_EKP = OBSW_KP_GAIN_RUN; // 估算器里的PI的KP
|
|
FOC_EKP = OBSW_KP_GAIN_RUN; // 估算器里的PI的KP
|