소스 검색

转把扭矩输出计算调整

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 년 전
부모
커밋
371d362c98
3개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 2
      Applications/foc/core/PMSM_FOC_Core.c
  2. 2 1
      Applications/foc/core/PMSM_FOC_Core.h
  3. 6 2
      Applications/foc/core/thro_torque.c

+ 4 - 2
Applications/foc/core/PMSM_FOC_Core.c

@@ -579,6 +579,7 @@ u8 PMSM_FOC_CtrlMode(void) {
 			//ladrc_reset(&gFoc_Ctrl.vel_lim_adrc, gFoc_Ctrl.in.s_motVelocity, gFoc_Ctrl.in.s_targetTorque);
 			ladrc_copy(&gFoc_Ctrl.vel_lim_adrc, &gFoc_Ctrl.vel_adrc);
 #else
+			gFoc_Ctrl.in.s_trqModeOutLim = gFoc_Ctrl.in.s_targetTorque;
 			PI_Controller_Reset(&gFoc_Ctrl.pi_vel_lim, gFoc_Ctrl.in.s_targetTorque);
 #endif
 		}else if ((preMode == CTRL_MODE_TRQ) && (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_SPD)) {
@@ -591,6 +592,7 @@ u8 PMSM_FOC_CtrlMode(void) {
 #ifdef CONFIG_SPEED_LADRC
 			ladrc_reset(&gFoc_Ctrl.vel_lim_adrc, gFoc_Ctrl.in.s_motVelocity, gFoc_Ctrl.in.s_targetTorque);
 #else
+			gFoc_Ctrl.in.s_trqModeOutLim = gFoc_Ctrl.in.s_targetTorque;
 			PI_Controller_Reset(&gFoc_Ctrl.pi_vel_lim, gFoc_Ctrl.in.s_targetTorque);
 #endif
 		}else if ((preMode != gFoc_Ctrl.out.n_RunMode) && (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_EBRAKE)) {
@@ -728,8 +730,8 @@ 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.torqueLimRamp));
 		float maxTrq = PMSM_FOC_Limit_Speed(refTorque);
-		maxTrq = PMSM_FOC_Limit_iDC(maxTrq);
-		crosszero_step_towards(&gFoc_Ctrl.in.s_targetTorque, maxTrq);
+		gFoc_Ctrl.in.s_trqModeOutLim = PMSM_FOC_Limit_iDC(maxTrq);
+		crosszero_step_towards(&gFoc_Ctrl.in.s_targetTorque, gFoc_Ctrl.in.s_trqModeOutLim);
 	}else if (gFoc_Ctrl.out.n_RunMode == CTRL_MODE_SPD){
 		float maxSpeed = eCtrl_get_FinalSpeed();
 		float refSpeed = eCtrl_get_RefSpeed();

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

@@ -102,7 +102,8 @@ typedef struct {
 	float 	s_targetCurrent;
 	DQ_t    s_targetIdq;
 	DQ_t    s_targetVdq;
-	float   s_targetTorque; //限速后的实际扭矩
+	float   s_targetTorque; //对s_trqModeOutRaw进行扭矩过零处理
+	float   s_trqModeOutLim;//扭矩模式下限速限流后的扭矩请求
 	float 	s_vDC;
 	u8      n_ctlMode;
 	bool    b_motEnable;

+ 6 - 2
Applications/foc/core/thro_torque.c

@@ -211,7 +211,7 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 	if (thro_r > _torque.thro_ration) {
 		if (!_torque.accl) {
 			_torque.thro_ration_last = _torque.thro_ration;
-			_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
+			_torque.torque_real = _torque.torque_req;
 			if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_torque.torque_real = 0;
 			}
@@ -221,7 +221,11 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
 	}else if (thro_r < _torque.thro_ration) {
 		if (_torque.accl) {
 			_torque.thro_ration_last = _torque.thro_ration;
-			_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
+			_torque.torque_real = PMSM_FOC_Get()->in.s_trqModeOutLim;
+			/* 如果扭矩给定的ramp没有结束,使用原始扭矩请求作为减扭矩的起始点 */
+			if (_torque.torque_req - eCtrl_get_RefTorque() >= 10.0f ) {
+				_torque.torque_real = _torque.torque_req;
+			}
 			if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
 				_torque.torque_real = 0;
 			}