Преглед изворни кода

EPM 模式单独速度控制参数,支持转把控制前进车速

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui пре 2 година
родитељ
комит
84934ccaa3

+ 4 - 0
Applications/foc/core/thro_torque.c

@@ -74,6 +74,10 @@ float thro_ration_to_voltage(float r) {
 	return fclamp(vol, 0, nv_get_foc_params()->n_endThroVol);
 	return fclamp(vol, 0, nv_get_foc_params()->n_endThroVol);
 }
 }
 
 
+float thro_get_ration(float f_thro) {
+	return thro_ration(f_thro);
+}
+
 static float _thro_torque_for_accelerate(float ration) {
 static float _thro_torque_for_accelerate(float ration) {
 	float max_torque = thro_torque_gear_map((s16)_torque.spd_filted, _torque.gear);
 	float max_torque = thro_torque_gear_map((s16)_torque.spd_filted, _torque.gear);
 	float acc_r = 1.0f;
 	float acc_r = 1.0f;

+ 1 - 1
Applications/foc/core/thro_torque.h

@@ -19,6 +19,6 @@ float thro_ration_to_voltage(float r);
 void thro_torque_process(u8 run_mode, float f_throttle);
 void thro_torque_process(u8 run_mode, float f_throttle);
 float get_user_request_torque(void);
 float get_user_request_torque(void);
 float thro_torque_gear_map(s16 rpm, u8 gear);
 float thro_torque_gear_map(s16 rpm, u8 gear);
-
+float thro_get_ration(float f_thro);
 #endif /* _THRO_TORQUE_H__ */
 #endif /* _THRO_TORQUE_H__ */
 
 

+ 2 - 2
Applications/foc/foc_config.h

@@ -45,9 +45,9 @@
 #define CONFIG_EBRK_RAMP_TIME 50
 #define CONFIG_EBRK_RAMP_TIME 50
 #define CONFIG_AUTOHOLD_DETECT_TIME 3000
 #define CONFIG_AUTOHOLD_DETECT_TIME 3000
 
 
-#define CONFIG_CRUISE_RAMP_TIME 2000
+#define CONFIG_CRUISE_RAMP_TIME 4000
 
 
-#define CONFIG_LIMIT_RAMP_TIME (2 * 1000)
+#define CONFIG_LIMIT_RAMP_TIME (6 * 1000)
 
 
 #define CONFIG_MTPA_CALI_RAMP_TIME (10 * 1000)
 #define CONFIG_MTPA_CALI_RAMP_TIME (10 * 1000)
 
 

+ 12 - 4
Applications/foc/motor/motor.c

@@ -523,10 +523,14 @@ bool mc_start_epm_move(EPM_Dir_t dir, bool is_command) {
 		if (dir == EPM_Dir_Back) {
 		if (dir == EPM_Dir_Back) {
 #ifdef CONFIG_SPEED_LADRC
 #ifdef CONFIG_SPEED_LADRC
 			PMSM_FOC_Change_VelLoop_Params(CONFIG_LADRC_EPM_Wcv, CONFIG_LADRC_EPMBK_B0);
 			PMSM_FOC_Change_VelLoop_Params(CONFIG_LADRC_EPM_Wcv, CONFIG_LADRC_EPMBK_B0);
+#else
+			PMSM_FOC_Change_VelLoop_Params(0.2f, 7.5f);
 #endif
 #endif
 		}else {
 		}else {
 #ifdef CONFIG_SPEED_LADRC
 #ifdef CONFIG_SPEED_LADRC
-			PMSM_FOC_Change_VelLoop_Params(CONFIG_LADRC_EPM_Wcv, CONFIG_LADRC_EPM_B0);S
+			PMSM_FOC_Change_VelLoop_Params(CONFIG_LADRC_EPM_Wcv, CONFIG_LADRC_EPM_B0);
+#else
+			PMSM_FOC_Change_VelLoop_Params(0.2f, 7.5f);
 #endif
 #endif
 		}
 		}
 		PMSM_FOC_TorqueLimit(motor.f_epm_trq);
 		PMSM_FOC_TorqueLimit(motor.f_epm_trq);
@@ -535,6 +539,8 @@ bool mc_start_epm_move(EPM_Dir_t dir, bool is_command) {
 		motor.b_epm_cmd_move = false;
 		motor.b_epm_cmd_move = false;
 #ifdef CONFIG_SPEED_LADRC
 #ifdef CONFIG_SPEED_LADRC
 		PMSM_FOC_Change_VelLoop_Params(nv_get_foc_params()->f_adrc_vel_Wcv, nv_get_foc_params()->f_adrc_vel_B0);
 		PMSM_FOC_Change_VelLoop_Params(nv_get_foc_params()->f_adrc_vel_Wcv, nv_get_foc_params()->f_adrc_vel_B0);
+#else
+		PMSM_FOC_Change_VelLoop_Params(nv_get_foc_params()->pid_conf[PID_Spd_id].kp, nv_get_foc_params()->pid_conf[PID_Spd_id].ki);
 #endif
 #endif
 		PMSM_FOC_Set_Speed(0);
 		PMSM_FOC_Set_Speed(0);
 	}
 	}
@@ -1162,14 +1168,16 @@ static void mc_process_epm_move(void) {
 	}
 	}
 	float target_vel = nv_get_foc_params()->s_maxEpmRPM;
 	float target_vel = nv_get_foc_params()->s_maxEpmRPM;
 	float target_trq = nv_get_foc_params()->s_maxEpmTorqueLim;
 	float target_trq = nv_get_foc_params()->s_maxEpmTorqueLim;
-	float step = 0.2f;
+	float step = 0.05f;
 	if (motor.epm_dir == EPM_Dir_Back) {
 	if (motor.epm_dir == EPM_Dir_Back) {
 		target_vel = -nv_get_foc_params()->s_maxEpmRPMBck;
 		target_vel = -nv_get_foc_params()->s_maxEpmRPMBck;
 		target_trq = nv_get_foc_params()->s_maxEpmTorqueLimBck;
 		target_trq = nv_get_foc_params()->s_maxEpmTorqueLimBck;
-		step = 0.1f;
+	}else if (!motor.b_epm_cmd_move) {
+		target_vel = thro_get_ration(get_throttle_float()) * 2.0f * (float)target_vel;
+		step = 0.07f;
 	}
 	}
 	step_towards(&motor.f_epm_vel, target_vel, step);
 	step_towards(&motor.f_epm_vel, target_vel, step);
-	step_towards(&motor.f_epm_trq, target_trq, 0.1f);
+	motor.f_epm_trq = target_trq;
 	PMSM_FOC_TorqueLimit(motor.f_epm_trq);
 	PMSM_FOC_TorqueLimit(motor.f_epm_trq);
 	PMSM_FOC_Set_Speed(motor.f_epm_vel);
 	PMSM_FOC_Set_Speed(motor.f_epm_vel);
 }
 }