|
|
@@ -72,10 +72,14 @@ float throttle_to_torque(float f_throttle) {
|
|
|
return PMSM_FOC_GetTorqueLimit() * throttle_ration(f_throttle);
|
|
|
}
|
|
|
|
|
|
+/* 软件设置油门开度,调试使用 */
|
|
|
+void throttle_set_ration(float r) {
|
|
|
+ g_trq_mn.thro_value = r;
|
|
|
+}
|
|
|
+
|
|
|
#define REAL_DQ_CEOF 0.9f
|
|
|
#define FINAL_DQ_CEFO 1.1F
|
|
|
-#define START_RPM_FOR_AUDOHOLD 10.0F
|
|
|
-#if 1
|
|
|
+
|
|
|
void torque_mode_process(void) {
|
|
|
float ref_trq = PMSM_FOC_GetTorqueLimit() * g_trq_mn.thro_value;
|
|
|
if ((mc_throttle_released()) && eCtrl_enable_eBrake(true)) {
|
|
|
@@ -86,7 +90,7 @@ void torque_mode_process(void) {
|
|
|
}
|
|
|
|
|
|
if (!mc_throttle_released()) {
|
|
|
- if (PMSM_FOC_GetSpeed() <= START_RPM_FOR_AUDOHOLD) {
|
|
|
+ if (PMSM_FOC_GetSpeed() <= CONFIG_ZERO_SPEED_RPM) {
|
|
|
ref_trq = MAX(eCtrl_get_FinalTorque() * FINAL_DQ_CEFO, ref_trq );
|
|
|
g_trq_mn.torque_base = ref_trq;
|
|
|
}
|
|
|
@@ -102,60 +106,7 @@ void torque_mode_process(void) {
|
|
|
g_trq_mn.torque_base = 0;
|
|
|
}
|
|
|
}
|
|
|
-#else
|
|
|
-void torque_mode_process(void) {
|
|
|
- float thro_curr = g_trq_mn.thro_value;
|
|
|
- float thro_prev = g_trq_mn.thro_prev;
|
|
|
- float trq_ref = PMSM_FOC_GetTorqueLimit() * thro_curr;
|
|
|
|
|
|
- if ((thro_curr == 0.0f) && eCtrl_enable_eBrake(true)) {
|
|
|
- g_trq_mn.thro_value = 0;
|
|
|
- g_trq_mn.accl = false;
|
|
|
- g_trq_mn.thro_prev = 0.0f;
|
|
|
- return;
|
|
|
- }
|
|
|
- float real_trq = eCtrl_get_FinalTorque() * REAL_DQ_CEOF;
|
|
|
- if (trq_ref > 0) {
|
|
|
- if (PMSM_FOC_GetSpeed() <= 10.0f) {
|
|
|
- g_trq_mn.accl_ref = MAX(real_trq, trq_ref); //不能小于autohold产生的扭矩
|
|
|
- trq_ref = g_trq_mn.accl_ref;
|
|
|
- }else {
|
|
|
- if (thro_curr > thro_prev) {
|
|
|
- if (!g_trq_mn.accl){
|
|
|
- g_trq_mn.accl_ref = eCtrl_get_RefTorque();
|
|
|
- }
|
|
|
- if (g_trq_mn.accl_ref > PMSM_FOC_GetTorqueLimit()) {
|
|
|
- g_trq_mn.accl_ref = PMSM_FOC_GetTorqueLimit();
|
|
|
- }
|
|
|
- trq_ref = g_trq_mn.accl_ref + thro_curr * (PMSM_FOC_GetTorqueLimit() - g_trq_mn.accl_ref);
|
|
|
- g_trq_mn.accl = true;
|
|
|
- }else if (thro_curr < thro_prev){
|
|
|
- if (g_trq_mn.accl) {
|
|
|
- g_trq_mn.accl_ref = min(real_trq, eCtrl_get_RefTorque());
|
|
|
- eCtrl_reset_Torque(g_trq_mn.accl_ref);
|
|
|
- }
|
|
|
- trq_ref = thro_curr * g_trq_mn.accl_ref;
|
|
|
- g_trq_mn.accl = false;
|
|
|
- }else {
|
|
|
- if (g_trq_mn.accl) {
|
|
|
- trq_ref = g_trq_mn.accl_ref + thro_curr * (PMSM_FOC_GetTorqueLimit() - g_trq_mn.accl_ref);
|
|
|
- }else {
|
|
|
- trq_ref = thro_curr * g_trq_mn.accl_ref;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- PMSM_FOC_Set_Torque(trq_ref);
|
|
|
- }
|
|
|
- else if (eCtrl_get_FinalTorque() != 0){
|
|
|
- float ref_now = min(real_trq, eCtrl_get_RefTorque());
|
|
|
- eCtrl_reset_Torque(ref_now);
|
|
|
- PMSM_FOC_Set_Torque(0);
|
|
|
- g_trq_mn.thro_value = 0;
|
|
|
- }
|
|
|
- g_trq_mn.thro_prev = thro_curr;
|
|
|
-}
|
|
|
-
|
|
|
-#endif
|
|
|
void speed_mode_process(void) {
|
|
|
float speed_Ref = g_trq_mn.spd_ref;
|
|
|
PMSM_FOC_Set_Speed(speed_Ref);
|
|
|
@@ -188,29 +139,3 @@ void throttle_process(u8 run_mode, float f_throttle) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
-void torque_manager(u8 run_mode, float f_throttle) {
|
|
|
- if ((g_trq_mn.count++ % 20) != 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (run_mode == CTRL_MODE_SPD) {
|
|
|
- float speed_Ref = throttle_to_speed(f_throttle);
|
|
|
- PMSM_FOC_Set_Speed(speed_Ref);
|
|
|
- }else if (run_mode == CTRL_MODE_TRQ) {
|
|
|
- if (mc_throttle_released()) {
|
|
|
- eCtrl_enable_eBrake(true);
|
|
|
- PMSM_FOC_Set_Torque(0);
|
|
|
- g_trq_mn.torque_prev = 0;
|
|
|
- }else {
|
|
|
- float torque = throttle_to_torque(f_throttle);
|
|
|
- eCtrl_enable_eBrake(false);
|
|
|
- PMSM_FOC_Set_Torque(torque);
|
|
|
- g_trq_mn.torque_prev = torque;
|
|
|
- }
|
|
|
- }else if (run_mode == CTRL_MODE_CURRENT_BRK) {
|
|
|
- if (!mc_throttle_released() || (mc_throttle_released() && (PMSM_FOC_GetSpeed() == 0.0f))) {
|
|
|
- eCtrl_enable_eBrake(false);
|
|
|
- }
|
|
|
- }
|
|
|
-} */
|
|
|
-
|