|
@@ -244,47 +244,40 @@ MC_CalParam_Struct_t MC_AssistRunMode_Walk_Process(MC_WorkMode_Struct_t p_MC_Wor
|
|
|
MC_WalkProcess_Param.MotorSpeedSetBegin = (MC_MotorParam.Rate_Speed << 5 ) * MC_WalkMode_Persent / 100;
|
|
|
}
|
|
|
SpdMotorByIdc = PID_Regulator((MC_ConfigParam1.CurrentLimit * 1000) >> 7, MC_RunInfo.BusCurrent >> 7, &PID_ConstantPower); // 母线电流闭环
|
|
|
+
|
|
|
+ //电机启动
|
|
|
+ MC_MotorStar(&MC_StarFlag);
|
|
|
}
|
|
|
|
|
|
//运行模式,设定转速 = 设置值
|
|
|
else
|
|
|
{
|
|
|
uint8_t WalkMode_MotorSpeedSet = 0;
|
|
|
+ uint8_t WalkMode_SpeedLimit = 0;
|
|
|
|
|
|
//新增配置项,兼容旧电机
|
|
|
WalkMode_MotorSpeedSet = (MC_ConfigParam1.WalkMode_MotorSpeedSet == 0) ? 135 : MC_ConfigParam1.WalkMode_MotorSpeedSet;
|
|
|
+ WalkMode_SpeedLimit = (MC_ConfigParam1.WalkMode_SpeedLimit == 0) ? 60 : MC_ConfigParam1.WalkMode_SpeedLimit;
|
|
|
|
|
|
+ //加减速计算
|
|
|
if(MC_WalkProcess_Param.MotorSpeedSetBegin < (WalkMode_MotorSpeedSet << 5) - 10)
|
|
|
{
|
|
|
- MC_WalkProcess_Param.MotorSpeedSetBegin += 1;
|
|
|
+ MC_WalkProcess_Param.MotorSpeedSetBegin += 1;
|
|
|
}
|
|
|
else if(MC_WalkProcess_Param.MotorSpeedSetBegin > (WalkMode_MotorSpeedSet << 5) + 10)
|
|
|
{
|
|
|
- MC_WalkProcess_Param.MotorSpeedSetBegin -= 1;
|
|
|
+ MC_WalkProcess_Param.MotorSpeedSetBegin -= 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MC_WalkProcess_Param.MotorSpeedSetBegin = WalkMode_MotorSpeedSet << 5;
|
|
|
+ MC_WalkProcess_Param.MotorSpeedSetBegin = WalkMode_MotorSpeedSet << 5;
|
|
|
}
|
|
|
SpdMotorByIdc = PID_Regulator((MC_ConfigParam1.CurrentLimit * 500) >> 7, MC_RunInfo.BusCurrent >> 7, &PID_ConstantPower); // 母线电流闭环
|
|
|
- }
|
|
|
-
|
|
|
- //速度环
|
|
|
- TorQueBySpd = PID_Regulator((MC_WalkProcess_Param.MotorSpeedSetBegin >> 5), MC_RunInfo.MotorSpeed, &PID_MotorSpd); // 电机速度闭环输出
|
|
|
- TorQueBySpd += SpdMotorByIdc;
|
|
|
-
|
|
|
- //限制车速低于设置值
|
|
|
- if(p_MC_WorkMode != MC_WorkMode_Config) //运行模式,推行限速
|
|
|
- {
|
|
|
- uint8_t WalkMode_SpeedLimit = 0;
|
|
|
-
|
|
|
- //新增配置项,兼容旧电机
|
|
|
- WalkMode_SpeedLimit = (MC_ConfigParam1.WalkMode_SpeedLimit == 0) ? 60 : MC_ConfigParam1.WalkMode_SpeedLimit;
|
|
|
-
|
|
|
- TorQueBySpd = (uint16_t)((uint32_t)(TorQueBySpd * Function_Linear_3Stage((WalkMode_SpeedLimit - 5), 0, (WalkMode_SpeedLimit - 5), 128, MC_RunInfo.BikeSpeed)) >> 10);
|
|
|
- if(MC_RunInfo.BikeSpeed > WalkMode_SpeedLimit)
|
|
|
+
|
|
|
+ //限速处理
|
|
|
+ if(MC_RunInfo.BikeSpeed > (WalkMode_SpeedLimit))
|
|
|
{
|
|
|
- MC_WalkProcess_Param.MotorSpeedSetBegin = 0;
|
|
|
+ MC_WalkProcess_Param.MotorSpeedSetBegin = 0;
|
|
|
MC_MotorStop(&MC_StarFlag);
|
|
|
}
|
|
|
else
|
|
@@ -293,11 +286,10 @@ MC_CalParam_Struct_t MC_AssistRunMode_Walk_Process(MC_WorkMode_Struct_t p_MC_Wor
|
|
|
MC_MotorStar(&MC_StarFlag);
|
|
|
}
|
|
|
}
|
|
|
- else //配置模式不限速
|
|
|
- {
|
|
|
- //电机启动
|
|
|
- MC_MotorStar(&MC_StarFlag);
|
|
|
- }
|
|
|
+
|
|
|
+ //速度环
|
|
|
+ TorQueBySpd = PID_Regulator((MC_WalkProcess_Param.MotorSpeedSetBegin >> 5), MC_RunInfo.MotorSpeed, &PID_MotorSpd); // 电机速度闭环输出
|
|
|
+ TorQueBySpd += SpdMotorByIdc;
|
|
|
|
|
|
#if 1
|
|
|
static uint16_t K_ByVoltage_Set_Old = 1024;
|