Просмотр исходного кода

扭矩和相电流区分开,可以给真实扭矩(需要通过台架标定)

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 лет назад
Родитель
Сommit
d740566645

+ 2 - 3
Applications/app/nv_storage.c

@@ -50,8 +50,8 @@ static void nv_default_foc_params(void) {
 	foc_params.s_PhaseCurrLim = CONFIG_DEFAULT_PHASE_CURR_LIM;
 	foc_params.s_maxRPM = CONFIG_DEFAULT_RPM_LIM;
 	foc_params.s_maxEpmRPM = CONFIG_DEFAULT_EPM_RPM;
-	foc_params.s_maxEpmPhaseCurrLim = CONFIG_DEFAULT_EPM_PHASE_CURR;
-	foc_params.s_maxTorque = foc_params.s_PhaseCurrLim;
+	foc_params.s_maxEpmTorqueLim = CONFIG_DEFAULT_EPM_PHASE_CURR;
+	foc_params.s_maxTorque = CONFIG_MAX_MOTOR_TORQUE;
 	foc_params.s_PhaseCurreBrkLim = CONFIG_DEFAULT_EBRK_PHASE_CURR;
 	foc_params.n_currentBand = CONFIG_CURRENT_BANDWITH;
 	foc_params.n_brkShutPower = CONFIG_BRK_SHUT_POWER_ENABLE;
@@ -209,7 +209,6 @@ void nv_read_foc_params(void) {
 			fmc_write_data(focParam_idx_1, (u8 *)&foc_params, sizeof(foc_params));
 		}
 	}
-	foc_params.s_maxTorque = foc_params.s_PhaseCurrLim;//overwrite
 	sys_debug("maxTorque=%f\n", foc_params.s_maxTorque);
 }
 

+ 1 - 1
Applications/app/nv_storage.h

@@ -11,7 +11,7 @@ typedef struct {
 	float s_minDCVol;
 	float s_maxRPM;
 	float s_maxEpmRPM;
-	float s_maxEpmPhaseCurrLim;
+	float s_maxEpmTorqueLim;
 	float s_maxTorque;
 	float s_PhaseCurreBrkLim;
 	float s_iDCeBrkLim;

+ 1 - 1
Applications/bsp/board_mc100_v1.h

@@ -11,7 +11,7 @@
 #define CONFIG_RATED_DC_VOL (96.0f)   /* 母线最大电压 V*/
 #define CONFIG_MIN_DC_VOL   (20.0f)
 
-#define CONFIG_MAX_VBUS_CURRENT 200.0f
+#define CONFIG_MAX_VBUS_CURRENT 120.0f
 #define CONFIG_MAX_MOT_RPM      9000.0f
 #define CONFIG_MAX_PHASE_CURR   400.0F
 #define CONFIG_MAX_PHASE_VOL    (CONFIG_MOS_MAX_VOL - 20.0F)

+ 1 - 1
Applications/foc/commands.c

@@ -440,7 +440,7 @@ static void process_foc_command(foc_cmd_body_t *command) {
 				nv_get_foc_params()->n_startThroVol = (float)decode_s16((u8 *)command->data + 10)/100.0f;
 				nv_get_foc_params()->n_endThroVol = (float)decode_s16((u8 *)command->data + 12)/100.0f;
 				nv_get_foc_params()->s_maxEpmRPM = decode_s16((u8 *)command->data + 14);
-				nv_get_foc_params()->s_maxEpmPhaseCurrLim = decode_s16((u8 *)command->data + 16);
+				nv_get_foc_params()->s_maxEpmTorqueLim = decode_s16((u8 *)command->data + 16);
 				nv_get_foc_params()->n_brkShutPower = decode_u8((u8 *)command->data + 18);
 				nv_get_foc_params()->n_autoHold = decode_u8((u8 *)command->data + 19);
 				nv_get_foc_params()->n_acc_time = decode_u32((u8 *)command->data + 20);

+ 54 - 53
Applications/foc/core/PMSM_FOC_Core.c

@@ -16,9 +16,10 @@
 #include "libs/logger.h"
 #include "math/fir.h"
 
+#define _DEBUG(fmt, args...) no_debug(fmt, ##args)
+
 PMSM_FOC_Ctrl gFoc_Ctrl;
 static Fir_t phase1, phase2;
-
 static bool g_focinit = false;
 
 static u32 PMSM_FOC_Debug_Task(void *p);
@@ -173,14 +174,14 @@ static void PMSM_FOC_UserInit(void) {
 	gFoc_Ctrl.userLim.s_iDCeBrkLim = nv_get_foc_params()->s_iDCeBrkLim;
 	gFoc_Ctrl.userLim.s_PhaseCurreBrkLim = nv_get_foc_params()->s_PhaseCurreBrkLim;
 	gFoc_Ctrl.userLim.s_PhaseVoleBrkLim = gFoc_Ctrl.hwLim.s_PhaseVolMax;
-	
-	gFoc_Ctrl.protLim.s_iDCLim = gFoc_Ctrl.userLim.s_iDCLim;
-	gFoc_Ctrl.protLim.s_PhaseCurrLim = gFoc_Ctrl.userLim.s_PhaseCurrLim;
 }
 
 void PMSM_FOC_RT_LimInit(void) {
+	gFoc_Ctrl.protLim.s_iDCLim = gFoc_Ctrl.userLim.s_iDCLim;
+	gFoc_Ctrl.protLim.s_TorqueLim = gFoc_Ctrl.userLim.s_torqueLim;
+
 	eRamp_init_target(&gFoc_Ctrl.rtLim.rpmLimRamp, gFoc_Ctrl.userLim.s_motRPMLim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
-	eRamp_init_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, gFoc_Ctrl.userLim.s_PhaseCurrLim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
+	eRamp_init_target(&gFoc_Ctrl.rtLim.torqueLimRamp, gFoc_Ctrl.userLim.s_torqueLim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
 	eRamp_init_target(&gFoc_Ctrl.rtLim.DCCurrLimRamp, gFoc_Ctrl.userLim.s_iDCLim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
 }
 
@@ -205,13 +206,18 @@ void PMSM_FOC_CoreInit(void) {
 	gFoc_Ctrl.hwLim.s_PhaseCurrMax = CONFIG_MAX_PHASE_CURR;
 	gFoc_Ctrl.hwLim.s_PhaseVolMax = CONFIG_MAX_PHASE_VOL;
 	gFoc_Ctrl.hwLim.s_vDCMax      = CONFIG_MAX_DC_VOL;
-	gFoc_Ctrl.hwLim.s_torqueMax  = CONFIG_MAX_TORQUE;
+	gFoc_Ctrl.hwLim.s_torqueMax  = CONFIG_MAX_MOTOR_TORQUE;
 	gFoc_Ctrl.hwLim.s_FWDCurrMax = CONFIG_MAX_FW_D_CURR;
 	if (!g_focinit) {
 		PMSM_FOC_UserInit();
 		PMSM_FOC_RT_LimInit();
 		shark_task_create(PMSM_FOC_Debug_Task, NULL);
 		g_focinit = true;
+		_DEBUG("User Limit:\n");
+		_DEBUG("dc %f, rpm %f, torque %f, phase %f, vDCmax %f, vDCmin %f, ebrk %f\n", gFoc_Ctrl.userLim.s_iDCLim, gFoc_Ctrl.userLim.s_motRPMLim, gFoc_Ctrl.userLim.s_torqueLim,
+			gFoc_Ctrl.userLim.s_PhaseCurrLim, gFoc_Ctrl.userLim.s_vDCMaxLim, gFoc_Ctrl.userLim.s_vDCMinLim, gFoc_Ctrl.userLim.s_PhaseCurreBrkLim);
+		_DEBUG("Hw Limit:\n");
+		_DEBUG("dc %f, rpm %f, torque %f, phase %f\n", gFoc_Ctrl.hwLim.s_iDCMax, gFoc_Ctrl.hwLim.s_motRPMMax, gFoc_Ctrl.hwLim.s_torqueMax, gFoc_Ctrl.hwLim.s_PhaseCurrMax);
 	}
 	
 	gFoc_Ctrl.params.n_modulation = CONFIG_SVM_MODULATION;//SVM_Modulation;
@@ -546,8 +552,8 @@ static __INLINE void PMSM_FOC_idq_Assign(void) {
 /*called in media task */
 void PMSM_FOC_idqCalc(void) {
 	if (gFoc_Ctrl.in.b_AutoHold) {
-		gFoc_Ctrl.pi_lock->max = CONFIG_DEFAULT_LOCK_PHASE_CURR_LIM;
-		gFoc_Ctrl.pi_lock->min = -CONFIG_DEFAULT_LOCK_PHASE_CURR_LIM;
+		gFoc_Ctrl.pi_lock->max = CONFIG_DEFAULT_LOCK_TORQUE_LIM;
+		gFoc_Ctrl.pi_lock->min = -CONFIG_DEFAULT_LOCK_TORQUE_LIM;
 		float vel_count = motor_encoder_get_vel_count();
 		float errRef = 0 - vel_count;
 		gFoc_Ctrl.in.s_targetTorque = PI_Controller_run(gFoc_Ctrl.pi_lock ,errRef);
@@ -562,7 +568,7 @@ void PMSM_FOC_idqCalc(void) {
 			}
 		}
 	}else if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_TRQ) {
-		float refTorque = min(eCtrl_get_RefTorque(), eRamp_get_intepolation(&gFoc_Ctrl.rtLim.phaseCurrLimRamp));
+		float refTorque = min(eCtrl_get_RefTorque(), eRamp_get_intepolation(&gFoc_Ctrl.rtLim.torqueLimRamp));
 		float maxTrq = PMSM_FOC_Limit_Speed(refTorque);
 		maxTrq = PMSM_FOC_Limit_iDC(maxTrq);
 		crosszero_step_towards(&gFoc_Ctrl.in.s_targetTorque, maxTrq);
@@ -574,10 +580,10 @@ void PMSM_FOC_idqCalc(void) {
 			refSpeed = eRamp_get_intepolation(&gFoc_Ctrl.in.cruiseRpmRamp);//gFoc_Ctrl.in.s_cruiseRPM;
 		}
 		if (maxSpeed >= 0) {
-			gFoc_Ctrl.pi_speed->max = eRamp_get_intepolation(&gFoc_Ctrl.rtLim.phaseCurrLimRamp);//gFoc_Ctrl.userLim.s_PhaseCurrLim;
+			gFoc_Ctrl.pi_speed->max = eRamp_get_intepolation(&gFoc_Ctrl.rtLim.torqueLimRamp);//gFoc_Ctrl.userLim.s_PhaseCurrLim;
 			gFoc_Ctrl.pi_speed->min = -CONFIG_MAX_NEG_TORQUE;
 		}else if (maxSpeed < 0) {
-			gFoc_Ctrl.pi_speed->min = -eRamp_get_intepolation(&gFoc_Ctrl.rtLim.phaseCurrLimRamp);//gFoc_Ctrl.userLim.s_PhaseCurrLim;
+			gFoc_Ctrl.pi_speed->min = -eRamp_get_intepolation(&gFoc_Ctrl.rtLim.torqueLimRamp);//gFoc_Ctrl.userLim.s_PhaseCurrLim;
 			gFoc_Ctrl.pi_speed->max = CONFIG_MAX_NEG_TORQUE;
 		}
 
@@ -596,28 +602,28 @@ void PMSM_FOC_idqCalc(void) {
 
 bool PMSM_FOC_RunTime_Limit(void) {
 	bool changed = false;
-	float dclim = (float)vbus_current_vol_lower_limit();
-	float phaselim = (float)phase_current_temp_high_limit();
+	float dc_lim = (float)vbus_current_vol_lower_limit();
+	float torque_lim = (float)torque_temp_high_limit();
 
-	dclim = (dclim!=CURRENT_LIMIT_NONE)?dclim:gFoc_Ctrl.hwLim.s_iDCMax;
-	phaselim = (phaselim!=CURRENT_LIMIT_NONE)?phaselim:gFoc_Ctrl.hwLim.s_PhaseCurrMax;
+	dc_lim = (dc_lim != CURRENT_LIMIT_NONE)?dc_lim:gFoc_Ctrl.userLim.s_iDCLim;
+	torque_lim = (torque_lim != CURRENT_LIMIT_NONE)?torque_lim:gFoc_Ctrl.userLim.s_torqueLim;
 
-	if (phaselim < gFoc_Ctrl.rtLim.phaseCurrLimRamp.target) {
-		eRamp_set_step_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, phaselim, CONFIG_eCTRL_STEP_TS);
+	if (torque_lim < gFoc_Ctrl.rtLim.torqueLimRamp.target) {
+		eRamp_set_step_target(&gFoc_Ctrl.rtLim.torqueLimRamp, torque_lim, CONFIG_eCTRL_STEP_TS);
 	}
-	if (dclim < gFoc_Ctrl.rtLim.DCCurrLimRamp.target) {
-		eRamp_set_step_target(&gFoc_Ctrl.rtLim.DCCurrLimRamp, dclim, CONFIG_eCTRL_STEP_TS);
+	if (dc_lim < gFoc_Ctrl.rtLim.DCCurrLimRamp.target) {
+		eRamp_set_step_target(&gFoc_Ctrl.rtLim.DCCurrLimRamp, dc_lim, CONFIG_eCTRL_STEP_TS);
 	}
-	if (gFoc_Ctrl.protLim.s_iDCLim != dclim || gFoc_Ctrl.protLim.s_PhaseCurrLim != phaselim) {
-		gFoc_Ctrl.protLim.s_iDCLim = dclim;
-		gFoc_Ctrl.protLim.s_PhaseCurrLim = phaselim;
+	if (gFoc_Ctrl.protLim.s_iDCLim != dc_lim || gFoc_Ctrl.protLim.s_TorqueLim != torque_lim) {
+		gFoc_Ctrl.protLim.s_iDCLim = dc_lim;
+		gFoc_Ctrl.protLim.s_TorqueLim = torque_lim;
 		changed = true;
 	}
 	return changed;
 }
 
 void PMSM_FOC_Slow_Task(void) {
-	eRamp_running(&gFoc_Ctrl.rtLim.phaseCurrLimRamp);
+	eRamp_running(&gFoc_Ctrl.rtLim.torqueLimRamp);
 	eRamp_running(&gFoc_Ctrl.rtLim.DCCurrLimRamp);
 	eRamp_running(&gFoc_Ctrl.rtLim.rpmLimRamp);
 	eRamp_running(&gFoc_Ctrl.in.cruiseRpmRamp);
@@ -659,12 +665,13 @@ bool PMSM_FOC_Is_Start(void) {
 }
 
 void PMSM_FOC_DCCurrLimit(float ibusLimit) {
-	float minCurr = min(gFoc_Ctrl.hwLim.s_iDCMax, gFoc_Ctrl.protLim.s_iDCLim);
-	if (ibusLimit > minCurr) {
-		ibusLimit = minCurr;
+	if (ibusLimit > gFoc_Ctrl.hwLim.s_iDCMax) {
+		ibusLimit = gFoc_Ctrl.hwLim.s_iDCMax;
 	}
-	gFoc_Ctrl.userLim.s_iDCLim = (ibusLimit);
-	if (ABS(gFoc_Ctrl.in.s_motRPM) < 10){
+	gFoc_Ctrl.userLim.s_iDCLim = ibusLimit;
+	gFoc_Ctrl.protLim.s_iDCLim = gFoc_Ctrl.userLim.s_iDCLim;
+
+	if (ABS(gFoc_Ctrl.in.s_motRPM) <= CONFIG_ZERO_SPEED_RPM){
 		eRamp_reset_target(&gFoc_Ctrl.rtLim.DCCurrLimRamp, ibusLimit);
 	}else {
 		eRamp_set_step_target(&gFoc_Ctrl.rtLim.DCCurrLimRamp, ibusLimit, CONFIG_eCTRL_STEP_TS);
@@ -675,26 +682,26 @@ float PMSM_FOC_GetDCCurrLimit(void) {
 	return gFoc_Ctrl.userLim.s_iDCLim;
 }
 
-void PMSM_FOC_SpeedLimit(float speedLimit) {
-	PMSM_FOC_SpeedRampLimit(speedLimit, false);
-}
-
-void PMSM_FOC_SpeedDirectLimit(float limit) {
-	PMSM_FOC_SpeedRampLimit(limit, true);
-}
-
-void PMSM_FOC_SpeedRampLimit(float speedLimit, bool direct) {
+void PMSM_FOC_SpeedRampLimit(float speedLimit, float speed) {
 	if (speedLimit > gFoc_Ctrl.hwLim.s_motRPMMax) {
 		speedLimit = gFoc_Ctrl.hwLim.s_motRPMMax;
 	}
 	gFoc_Ctrl.userLim.s_motRPMLim = (speedLimit);
-	if (direct) {
+	if (ABS(speed) <= CONFIG_ZERO_SPEED_RPM) {
 		eRamp_reset_target(&gFoc_Ctrl.rtLim.rpmLimRamp, speedLimit);
 	}else {
 		eRamp_set_step_target(&gFoc_Ctrl.rtLim.rpmLimRamp, speedLimit, CONFIG_eCTRL_STEP_TS);
 	}
 }
 
+void PMSM_FOC_SpeedLimit(float speedLimit) {
+	PMSM_FOC_SpeedRampLimit(speedLimit, gFoc_Ctrl.in.s_motRPM);
+}
+
+void PMSM_FOC_SpeedDirectLimit(float limit) {
+	PMSM_FOC_SpeedRampLimit(limit, 0);
+}
+
 
 float PMSM_FOC_GetSpeedLimit(void) {
 	return gFoc_Ctrl.userLim.s_motRPMLim;
@@ -705,11 +712,12 @@ void PMSM_FOC_TorqueLimit(float torqueLimit) {
 		torqueLimit = gFoc_Ctrl.hwLim.s_torqueMax;
 	}
 	gFoc_Ctrl.userLim.s_torqueLim = torqueLimit;
+	gFoc_Ctrl.protLim.s_TorqueLim = gFoc_Ctrl.userLim.s_torqueLim;
 
-	if (ABS(gFoc_Ctrl.in.s_motRPM) < 10){
-		eRamp_reset_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, torqueLimit);
+	if (ABS(gFoc_Ctrl.in.s_motRPM) <= CONFIG_ZERO_SPEED_RPM){
+		eRamp_reset_target(&gFoc_Ctrl.rtLim.torqueLimRamp, torqueLimit);
 	}else {
-		eRamp_set_step_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, torqueLimit, CONFIG_eCTRL_STEP_TS);
+		eRamp_set_step_target(&gFoc_Ctrl.rtLim.torqueLimRamp, torqueLimit, CONFIG_eCTRL_STEP_TS);
 	}
 }
 float PMSM_FOC_GetTorqueLimit(void) {
@@ -751,24 +759,17 @@ u8 PMSM_FOC_GetCtrlMode(void) {
 }
 
 void PMSM_FOC_PhaseCurrLim(float lim) {
-	float minCurr = min(gFoc_Ctrl.hwLim.s_PhaseCurrMax, gFoc_Ctrl.protLim.s_PhaseCurrLim);
-	if (lim > minCurr) {
-		lim = minCurr;
+	if (lim > gFoc_Ctrl.hwLim.s_PhaseCurrMax) {
+		lim = gFoc_Ctrl.hwLim.s_PhaseCurrMax;
 	}
 	gFoc_Ctrl.userLim.s_PhaseCurrLim = lim;
-	if (ABS(gFoc_Ctrl.in.s_motRPM) < 10){
-		eRamp_reset_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, lim);
-	}else {
-		eRamp_set_step_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, lim, CONFIG_eCTRL_STEP_TS);
-	}
 }
 
 void PMSM_FOC_RT_PhaseCurrLim(float lim) {
-	float minCurr = min(gFoc_Ctrl.hwLim.s_PhaseCurrMax, gFoc_Ctrl.protLim.s_PhaseCurrLim);
-	if (lim > minCurr) {
-		lim = minCurr;
+	if (lim > gFoc_Ctrl.hwLim.s_PhaseCurrMax) {
+		lim = gFoc_Ctrl.hwLim.s_PhaseCurrMax;
 	}
-	eRamp_init_target(&gFoc_Ctrl.rtLim.phaseCurrLimRamp, lim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
+	eRamp_init_target(&gFoc_Ctrl.rtLim.torqueLimRamp, lim, CONFIG_LIMIT_RAMP_TIME, CONFIG_LIMIT_RAMP_TIME);
 }
 
 float PMSM_FOC_GetPhaseCurrLim(void) {

+ 2 - 3
Applications/foc/core/PMSM_FOC_Core.h

@@ -119,7 +119,7 @@ typedef struct {
 
 typedef struct {
 	e_Ramp rpmLimRamp;
-	e_Ramp phaseCurrLimRamp;
+	e_Ramp torqueLimRamp;
 	e_Ramp DCCurrLimRamp;
 }FOC_RTLimit;
 
@@ -135,7 +135,7 @@ typedef struct {
 
 typedef struct {
 	float s_iDCLim;
-	float s_PhaseCurrLim;
+	float s_TorqueLim;
 }FOC_ProtLimit;
 
 typedef struct {
@@ -289,7 +289,6 @@ void PMSM_FOC_RT_PhaseCurrLim(float lim);
 void PMSM_FOC_RT_LimInit(void);
 float PMSM_FOC_Get_Real_Torque(void);
 void PMSM_FOC_Reset_Torque(void);
-void PMSM_FOC_SpeedRampLimit(float speedLimit, bool direct);
 void PMSM_FOC_SpeedDirectLimit(float limit);
 
 #endif /* _PMSM_FOC_Core_H__ */

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

@@ -8,7 +8,7 @@
 #include "libs/logger.h"
 #include "prot/can_foc_msg.h"
 
-static rpm_trq_map_t gear_torques[5][5] = {
+static motor_map_t gear_torques[5][5] = {
 	[0] = {{500,  100}, {1200, 100}, {1700, 80}, {2200, 75}, {2800, 50},},
 	[1] = {{800,  130}, {1600, 120}, {2400, 110}, {3200, 80}, {4300, 60},},
 	[2] = {{1200, 150}, {2200, 140}, {3200, 120}, {4200, 80}, {5300, 70},},
@@ -35,7 +35,7 @@ float torque_max_from_gear_rpm(void) {
 	if (gear > 4) {
 		gear = 0;
 	}
-	rpm_trq_map_t *map = &gear_torques[gear][0];
+	motor_map_t *map = &gear_torques[gear][0];
 	s16 rpm = (s16)torque_ctrl.spd_filted;
 	if (rpm <= map[0].rpm) {
 		return (float)map[0].torque;

+ 1 - 1
Applications/foc/foc_config.h

@@ -6,7 +6,7 @@
 #define CONFIG_DEFAULT_IDC_LIM 45
 #define CONFIG_DEFAULT_PHASE_CURR_LIM 200
 #define CONFIG_DEFAULT_RPM_LIM       CONFIG_MAX_MOT_RPM
-#define CONFIG_DEFAULT_LOCK_PHASE_CURR_LIM 100
+#define CONFIG_DEFAULT_LOCK_TORQUE_LIM 20
 
 #define CONFIG_DEFAULT_EPM_PHASE_CURR 50
 #define CONFIG_DEFAULT_EPM_RPM        200

+ 3 - 3
Applications/foc/limit.c

@@ -6,8 +6,8 @@
 
 static limter_t motor_temp_lim[] = {//电机过温限流,限制相电流
 	{.enter_pointer = 120, .exit_pointer = 110, .limit_value = 0},
-	{.enter_pointer = 110, .exit_pointer = 100, .limit_value = 120},
-	{.enter_pointer = 100, .exit_pointer = 90, .limit_value = 130},
+	{.enter_pointer = 110, .exit_pointer = 100, .limit_value = 12},
+	{.enter_pointer = 100, .exit_pointer = 90, .limit_value = 13},
 }; 
 static limter_t mos_temp_lim[] = { //mos过温限流,限制相电流
 	{.enter_pointer = 95, .exit_pointer = 85, .limit_value = 0},
@@ -113,7 +113,7 @@ static u16 _mos_limit(void) {
 	return CURRENT_LIMIT_NONE;
 }
 
-u16 phase_current_temp_high_limit(void) {
+u16 torque_temp_high_limit(void) {
 	u16 motor_lim = _motor_limit();
 	u16 mos_lim   = _mos_limit();
 	return min(motor_lim, mos_lim);

+ 1 - 1
Applications/foc/limit.h

@@ -11,7 +11,7 @@ typedef struct {
 	bool is_limit;
 }limter_t;
 
-u16 phase_current_temp_high_limit(void);
+u16 torque_temp_high_limit(void);
 u16 vbus_current_vol_lower_limit(void);
 void limter_set_under_voltage(s16 und_vol);
 

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

@@ -151,7 +151,7 @@ static void mc_gear_vmode_changed(void) {
 	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_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);
+	PMSM_FOC_TorqueLimit(/*gears[motor.n_gear].u_maxTorque*/CONFIG_MAX_MOTOR_TORQUE);
 }
 
 void mc_init(void) {
@@ -346,14 +346,14 @@ bool mc_start_epm(bool epm) {
 	if (epm) {
 		eCtrl_set_TgtSpeed(0);
 		motor.mode = CTRL_MODE_SPD;
-		PMSM_FOC_RT_PhaseCurrLim(nv_get_foc_params()->s_maxEpmPhaseCurrLim);
+		PMSM_FOC_TorqueLimit(nv_get_foc_params()->s_maxEpmTorqueLim);
 		PMSM_FOC_SetCtrlMode(CTRL_MODE_SPD);
 	}else {
 		motor.epm_dir = EPM_Dir_None;
 		motor.mode = CTRL_MODE_TRQ;
 		motor.b_epm_cmd_move = false;
 		PMSM_FOC_SetCtrlMode(CTRL_MODE_TRQ);
-		PMSM_FOC_RT_PhaseCurrLim(PMSM_FOC_GetPhaseCurrLim());
+		mc_gear_vmode_changed();
 	}
 	cpu_exit_critical(mask);
 	

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

@@ -3,7 +3,7 @@
 #include "math/fast_math.h"
 
 //#if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_ZD_100
-static rpm_trq_map_t mot_map[] = {
+static motor_map_t mot_map[] = {
 	{4500, 200},
 	{4740, 150},
 	{5050, 110},

+ 7 - 5
Applications/foc/motor/motor_param.h

@@ -7,7 +7,7 @@
 typedef struct {
 	s16 rpm;
 	s16 torque;
-}rpm_trq_map_t;
+}motor_map_t;
 
 s16 get_max_torque_for_rpm(s16 rpm);
 
@@ -18,7 +18,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_POLES  4
 #define MOTOR_ENC_OFFSET 0.0F
 
-#define CONFIG_MAX_MOTOR_CURR 400.0F
+#define CONFIG_MAX_MOTOR_TORQUE 40.0F
 
 #define TRQ_PI_KP 0.14F
 #define TRQ_PI_KI 0.15F
@@ -31,7 +31,7 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_POLES  4
 #define MOTOR_ENC_OFFSET 250.0F
 
-#define CONFIG_MAX_MOTOR_CURR 400.0F
+#define CONFIG_MAX_MOTOR_TORQUE 40.0F
 
 #define TRQ_PI_KP 0.14F
 #define TRQ_PI_KI 0.15F
@@ -44,7 +44,8 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_Lq (0.000091f*0.5f)
 #define MOTOR_POLES  5
 #define MOTOR_ENC_OFFSET 145.0F
-#define CONFIG_MAX_MOTOR_CURR 300.0F
+
+#define CONFIG_MAX_MOTOR_TORQUE 200.0F
 
 #define TRQ_PI_KP 0.6F //0.13f
 #define TRQ_PI_KI 0.5F
@@ -56,7 +57,8 @@ s16 get_max_torque_for_rpm(s16 rpm);
 #define MOTOR_Lq (0.000205f*0.5f)
 #define MOTOR_POLES  5
 #define MOTOR_ENC_OFFSET 180.0F
-#define CONFIG_MAX_MOTOR_CURR 200.0F
+
+#define CONFIG_MAX_MOTOR_TORQUE 40.0F
 
 #define TRQ_PI_KP 0.14F
 #define TRQ_PI_KI 0.15F

BIN
Simulink/Test_motor_map.xls