Przeglądaj źródła

挡位切换需要ramp给定

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 lat temu
rodzic
commit
89f1fb73a0

+ 2 - 2
Applications/app/app.c

@@ -126,14 +126,14 @@ static void plot_smo_angle(void) {
 }
 static u32 _app_plot_task(void * args) {
 	if (plot_type == 1) {
-		can_plot2(PMSM_FOC_Get()->rtLim.rpmLimRamp.interpolation, PMSM_FOC_GetSpeed());
+		can_plot2(PMSM_FOC_GetSpeed() + 50, PMSM_FOC_GetSpeed());
 	}else if (plot_type == 2) {
 		can_plot2(eCtrl_get_RefTorque(), PMSM_FOC_Get_Real_Torque());
 	}else if (plot_type == 3) {
 		//can_plot2(PMSM_FOC_GetSpeed(), foc_observer_smo_speed());
 		plot_smo_angle();
 	}else if (plot_type == 4) {
-		can_plot2(eCtrl_get_RefTorque(), PMSM_FOC_Get()->in.s_targetTorque);
+		can_plot2(PMSM_FOC_Get()->in.s_targetTorque + 20, PMSM_FOC_Get()->in.s_targetTorque);
 	}
 	
 	return 20;

+ 7 - 7
Applications/foc/core/PMSM_FOC_Core.c

@@ -432,8 +432,8 @@ u8 PMSM_FOC_CtrlMode(void) {
 		gFoc_Ctrl.out.n_RunMode = CTRL_MODE_SPD;
 	}else if (gFoc_Ctrl.in.n_ctlMode == CTRL_MODE_CURRENT) {
 		gFoc_Ctrl.out.n_RunMode = CTRL_MODE_CURRENT;
-	}else if (gFoc_Ctrl.in.n_ctlMode == CTRL_MODE_CURRENT_BRK) {
-		gFoc_Ctrl.out.n_RunMode = CTRL_MODE_CURRENT_BRK;
+	}else if (gFoc_Ctrl.in.n_ctlMode == CTRL_MODE_EBRAKE) {
+		gFoc_Ctrl.out.n_RunMode = CTRL_MODE_EBRAKE;
 	}else {
 		if (!gFoc_Ctrl.in.b_cruiseEna) {
 			gFoc_Ctrl.out.n_RunMode = CTRL_MODE_TRQ;
@@ -450,7 +450,7 @@ u8 PMSM_FOC_CtrlMode(void) {
 			PI_Controller_Reset(gFoc_Ctrl.pi_speed, target_troque);
 		}else if ((preMode == CTRL_MODE_CURRENT) && (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_TRQ)) {
 			PI_Controller_Reset(gFoc_Ctrl.pi_torque, gFoc_Ctrl.in.s_targetTorque);
-		}else if ((preMode == CTRL_MODE_TRQ) && (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT_BRK)) {
+		}else if ((preMode == CTRL_MODE_TRQ) && (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_EBRAKE)) {
 			float real_trq = PMSM_FOC_Get_Real_Torque() * 0.9f;
 			eCtrl_reset_Current(min(real_trq, gFoc_Ctrl.in.s_targetTorque));
 			eCtrl_set_TgtCurrent(-PMSM_FOC_GeteBrkPhaseCurrent());
@@ -517,7 +517,7 @@ static __INLINE float PMSM_FOC_Limit_Speed(float refTorque) {
 }
 
 static __INLINE void PMSM_FOC_idq_Assign(void) {
-	if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT || gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT_BRK) {
+	if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT || gFoc_Ctrl.out.n_RunMode == CTRL_MODE_EBRAKE) {
 		if (gFoc_Ctrl.in.b_MTPA_calibrate && (gFoc_Ctrl.in.s_manualAngle != INVALID_ANGLE)) {
 			float s, c;
 			normal_sincosf(degree_2_pi(gFoc_Ctrl.in.s_manualAngle + 90.0f), &s, &c);
@@ -554,9 +554,9 @@ void PMSM_FOC_idqCalc(void) {
 		PMSM_FOC_idq_Assign();
 		return;
 	}
-	if ((gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT) || (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT_BRK)) {
+	if ((gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT) || (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_EBRAKE)) {
 		gFoc_Ctrl.in.s_targetCurrent = eCtrl_get_RefCurrent();
-		if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_CURRENT_BRK) {
+		if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_EBRAKE) {
 			if (eCtrl_get_FinalCurrent() < 0.0001f && gFoc_Ctrl.in.s_motRPM < CONFIG_MIN_RPM_EXIT_EBRAKE) {
 				gFoc_Ctrl.in.s_targetCurrent = 0;
 			}
@@ -737,7 +737,7 @@ DQ_t* PMSM_FOC_GetDQCurrent(void) {
 }
 
 bool PMSM_FOC_SetCtrlMode(u8 mode) {
-	if (mode > CTRL_MODE_CURRENT_BRK) {
+	if (mode > CTRL_MODE_EBRAKE) {
 		PMSM_FOC_SetErrCode(FOC_Param_Err);
 		return false;
 	}

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

@@ -200,7 +200,7 @@ typedef struct {
 #define CTRL_MODE_SPD                       ((u8)1U)
 #define CTRL_MODE_TRQ                       ((u8)2U)
 #define CTRL_MODE_CURRENT                   ((u8)3U)
-#define CTRL_MODE_CURRENT_BRK               ((u8)4U)
+#define CTRL_MODE_EBRAKE               ((u8)4U)
 
 #define FOC_CALIMOD_HALL               ((u8) 1U)
 #define FOC_CALIMOD_MTPA               ((u8) 2U)

+ 1 - 1
Applications/foc/core/e_ctrl.c

@@ -89,7 +89,7 @@ static void _eCtrl_clear_ramp(void) {
 
 static void _eCtrl_process_eBrake(void) {
 	if (g_eCtrl.is_ebrake) {
-		PMSM_FOC_SetCtrlMode(CTRL_MODE_CURRENT_BRK);
+		PMSM_FOC_SetCtrlMode(CTRL_MODE_EBRAKE);
 		eRamp_reset_target(&g_eCtrl.current, 0);
 		g_eCtrl.current_shadow = 0.0f;
 	}else {

+ 1 - 1
Applications/foc/core/torque.c

@@ -151,7 +151,7 @@ void throttle_process(u8 run_mode, float f_throttle) {
 		request_torque(torque_ctrl.thro_ration);
 	}else if (run_mode == CTRL_MODE_SPD) {
 		request_speed(torque_ctrl.thro_ration);
-	}else if (run_mode == CTRL_MODE_CURRENT_BRK) {
+	}else if (run_mode == CTRL_MODE_EBRAKE) {
 		eCtrl_reset_Torque(0);
 		if (eCtrl_get_FinalCurrent() < 0.0001f && PMSM_FOC_GetSpeed() < CONFIG_MIN_RPM_EXIT_EBRAKE) {
 			eCtrl_enable_eBrake(false);	

+ 1 - 1
Applications/foc/foc_config.h

@@ -44,7 +44,7 @@
 #define CONFIG_EBRK_RAMP_TIME 500
 #define CONFIG_AUTOHOLD_DETECT_TIME 3000
 
-#define CONFIG_LIMIT_RAMP_TIME (5 * 1000)
+#define CONFIG_LIMIT_RAMP_TIME (2 * 1000)
 
 #define CONFIG_MTPA_CALI_RAMP_TIME (10 * 1000)
 

+ 1 - 1
Applications/foc/motor/motor.c

@@ -149,7 +149,7 @@ static void mc_gear_vmode_changed(void) {
 		gears = &nv_get_gear_configs()->gears_48[0];
 	}
 	sys_debug("limit %d-%d-%d, mode = %s\n", gears[motor.n_gear].u_maxRPM, gears[motor.n_gear].u_maxIdc, gears[motor.n_gear].u_maxTorque, motor.b_is96Mode?"96V":"48V");
-	PMSM_FOC_SpeedDirectLimit(gears[motor.n_gear].u_maxRPM);
+	PMSM_FOC_SpeedLimit(gears[motor.n_gear].u_maxRPM);
 	PMSM_FOC_DCCurrLimit(gears[motor.n_gear].u_maxIdc);
 	//PMSM_FOC_TorqueLimit(gears[motor.n_gear].u_maxTorque);
 }