|
|
@@ -149,11 +149,11 @@ bool mc_throttle_released(void) {
|
|
|
return get_throttle_float() < THROTTLE_LOW_VALUE;
|
|
|
}
|
|
|
|
|
|
-static float _get_speed_from_throttle(void) {
|
|
|
+static float _get_speed_from_throttle(float f_throttle) {
|
|
|
if (motor.b_ignor_throttle) {
|
|
|
return motor.s_targetFix;
|
|
|
}
|
|
|
- float f_throttle = motor.throttle;
|
|
|
+
|
|
|
if (f_throttle <= (THROTTLE_LOW_VALUE)) {
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -161,15 +161,14 @@ static float _get_speed_from_throttle(void) {
|
|
|
|
|
|
float ration = delta / (THROTTLE_MAX_VALUE - THROTTLE_LOW_VALUE);
|
|
|
|
|
|
- return (THROTTLE_MIN_RPM + PMSM_FOC_GetSpeedLimit() * ration);
|
|
|
+ return (PMSM_FOC_GetSpeedLimit() * ration);
|
|
|
}
|
|
|
|
|
|
-static float _get_idq_from_throttle(void) {
|
|
|
+static float _get_torque_from_throttle(float f_throttle) {
|
|
|
if (motor.b_ignor_throttle) {
|
|
|
return motor.s_targetFix;
|
|
|
}
|
|
|
|
|
|
- float f_throttle = motor.throttle;
|
|
|
if (f_throttle <= (THROTTLE_LOW_VALUE)) {
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -177,7 +176,7 @@ static float _get_idq_from_throttle(void) {
|
|
|
|
|
|
float ration = delta / (THROTTLE_MAX_VALUE - THROTTLE_LOW_VALUE);
|
|
|
|
|
|
- return (THROTTLE_MIN_IDQ + MAX_iDQ * ration);
|
|
|
+ return (MAX_TORQUE * ration);
|
|
|
}
|
|
|
|
|
|
/*do 50 times filter*/
|
|
|
@@ -244,14 +243,15 @@ void Sched_MC_mTask(void) {
|
|
|
#endif
|
|
|
if (runMode != CTRL_MODE_OPEN) {
|
|
|
eCtrl_Running();
|
|
|
- if (get_throttle_float() != motor.throttle) {
|
|
|
- motor.throttle = get_throttle_float();
|
|
|
+ float f_throttle = get_throttle_float();
|
|
|
+ if (f_throttle != motor.throttle) {
|
|
|
+ motor.throttle = f_throttle;
|
|
|
if (runMode == CTRL_MODE_SPD) {
|
|
|
- float speed_Ref = _get_speed_from_throttle();
|
|
|
+ float speed_Ref = _get_speed_from_throttle(f_throttle);
|
|
|
PMSM_FOC_Set_Speed(speed_Ref);
|
|
|
}else if (runMode == CTRL_MODE_TRQ) {
|
|
|
- float torque_idq = _get_idq_from_throttle();
|
|
|
- PMSM_FOC_Set_Torque(torque_idq);
|
|
|
+ float torque = _get_torque_from_throttle(f_throttle);
|
|
|
+ PMSM_FOC_Set_Torque(torque);
|
|
|
}
|
|
|
}
|
|
|
PMSM_FOC_idqCalc();
|