|
|
@@ -252,6 +252,8 @@ bool mot_contrl_update(mot_contrl_t *ctrl) {
|
|
|
|
|
|
foc_update(foc);
|
|
|
|
|
|
+ ctrl->duty_raw = NORM2_f(foc->out.vol_dq.d, foc->out.vol_dq.q)/(foc->in.dc_vol * CONFIG_SVM_MODULATION * SQRT3_BY_2);
|
|
|
+ LowPass_Filter(ctrl->duty_filterd, ctrl->duty_raw, 0.01f);
|
|
|
float lowpass = foc->mot_vel_radusPers * FOC_CTRL_US * 2;
|
|
|
lowpass = fclamp(lowpass, 0.001f, 1.0f);
|
|
|
LowPass_Filter(ctrl->out_idq_filterd.d, foc->out.curr_dq.d ,lowpass);
|
|
|
@@ -467,8 +469,15 @@ void mot_contrl_slow_task(mot_contrl_t *ctrl) {
|
|
|
u8 mot_contrl_protect(mot_contrl_t *ctrl) {
|
|
|
u8 changed = FOC_LIM_NO_CHANGE;
|
|
|
float dc_lim = (float)vbus_under_vol_limit();
|
|
|
- float torque_lim = (float)min(mos_temp_high_limit(), motor_temp_high_limit());
|
|
|
-
|
|
|
+ u16 mot_trq_lim = motor_temp_high_limit(type_phase);
|
|
|
+ s16 mos_trq_lim = mos_temp_high_limit();
|
|
|
+ float torque_lim = (float)min(mos_trq_lim, mot_trq_lim);
|
|
|
+
|
|
|
+ /*如果电机高温扭矩限制后,还是比当前的扭矩大,需要通过限制母线电流来实现降温*/
|
|
|
+ if ((torque_lim != HW_LIMIT_NONE) && (torque_lim >= mc_get_max_torque_now())) {
|
|
|
+ float mot_idc_lim = motor_temp_high_limit(type_idc);
|
|
|
+ dc_lim = min(dc_lim, mot_idc_lim);
|
|
|
+ }
|
|
|
if (ctrl->protlim.dc_curr != dc_lim || ctrl->protlim.torque != torque_lim) {
|
|
|
if ((dc_lim > ctrl->protlim.dc_curr) || (torque_lim > ctrl->protlim.torque)) {
|
|
|
changed = FOC_LIM_CHANGE_H;
|
|
|
@@ -815,7 +824,7 @@ void mot_contrl_calc_current(mot_contrl_t *ctrl) {
|
|
|
}else {
|
|
|
ctrl->dc_curr_filted = ctrl->dc_curr_calc;
|
|
|
}
|
|
|
- ctrl->out_current_vec = sqrtf(SQ(id) + SQ(iq));
|
|
|
+ ctrl->out_current_vec = NORM2_f(id, iq);
|
|
|
}
|
|
|
|
|
|
|