|
@@ -315,6 +315,7 @@ bool mot_contrl_update(mot_contrl_t *ctrl) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#ifndef CONFIG_TORQUE_LUT
|
|
|
static __INLINE float mot_contrl_dc_curr_limiter(mot_contrl_t *ctrl, float maxTrq) {
|
|
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);
|
|
float dc_lim = line_ramp_get_interp(&ctrl->ramp_dc_curr_lim);
|
|
|
/* 计算iq的前馈,(母线功率 - d轴功率)/vq
|
|
/* 计算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;
|
|
float errRef = dc_lim - ctrl->dc_curr_filted;
|
|
|
return PI_Controller_Parallel(&ctrl->pi_power, errRef, ctrl->dc_lim_iq_ff);
|
|
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) {
|
|
static __INLINE float mot_contrl_vel_limiter(mot_contrl_t *ctrl, float maxTrq) {
|
|
|
ctrl->pi_vel_lim.max = maxTrq;
|
|
ctrl->pi_vel_lim.max = maxTrq;
|