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

使用扭矩查找表,功率环使用扭矩前馈

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin 2 лет назад
Родитель
Сommit
e396fa1025
1 измененных файлов с 25 добавлено и 0 удалено
  1. 25 0
      Applications/foc/core/controller.c

+ 25 - 0
Applications/foc/core/controller.c

@@ -315,6 +315,7 @@ bool mot_contrl_update(mot_contrl_t *ctrl) {
 	return true;
 }
 
+#ifndef CONFIG_TORQUE_LUT
 static __INLINE float mot_contrl_dc_curr_limiter(mot_contrl_t *ctrl, float maxTrq) {
 	float dc_lim = line_ramp_get_interp(&ctrl->ramp_dc_curr_lim);
 	/* 计算iq的前馈,(母线功率 - d轴功率)/vq
@@ -340,6 +341,30 @@ static __INLINE float mot_contrl_dc_curr_limiter(mot_contrl_t *ctrl, float maxTr
 	float errRef = dc_lim - ctrl->dc_curr_filted;
 	return PI_Controller_Parallel(&ctrl->pi_power, errRef, ctrl->dc_lim_iq_ff);
 }
+#else
+static __INLINE float mot_contrl_dc_curr_limiter(mot_contrl_t *ctrl, float maxTrq) {
+	float dc_lim = line_ramp_get_interp(&ctrl->ramp_dc_curr_lim);
+	/* 计算扭矩的前馈,(母线功率 * 9.55 * 电机效率)/(电机速度)
+	 * 加上0.0001f 避免除0
+	*/
+	float torque_ff = dc_lim * get_vbus_float() * 9.55f * 0.8f/(ctrl->foc.in.mot_velocity + 0.0001f);
+	torque_ff = ABS(torque_ff);
+	if (torque_ff > maxTrq) {
+		ctrl->dc_lim_iq_ff = maxTrq;
+	}else if (torque_ff < 0) {
+		ctrl->dc_lim_iq_ff = 0;
+	}else {
+		ctrl->dc_lim_iq_ff = torque_ff;
+	}
+	/** 使用min(maxTrq, ctrl->dc_lim_iq_ff * 1.1f)带入max的原因是为了防止积分器饱和后有过冲现象
+	 *  1.1f的系数是为了保证ctrl->dc_lim_iq_ff计算偏小的情况下功率能达到上限,这个系数太大不能
+	 *  防止过冲
+	*/
+	ctrl->pi_power.max = min(maxTrq, ctrl->dc_lim_iq_ff * 1.1f);
+	float errRef = dc_lim - ctrl->dc_curr_filted;
+	return PI_Controller_Parallel(&ctrl->pi_power, errRef, ctrl->dc_lim_iq_ff);
+}
+#endif
 
 static __INLINE float mot_contrl_vel_limiter(mot_contrl_t *ctrl, float maxTrq) {
 	ctrl->pi_vel_lim.max = maxTrq;