|
@@ -53,8 +53,8 @@ bool mot_contrl_enable(mot_contrl_t *ctrl, bool start) {
|
|
|
mot_contrl_pid(ctrl);
|
|
mot_contrl_pid(ctrl);
|
|
|
mot_contrl_ulimit(ctrl);
|
|
mot_contrl_ulimit(ctrl);
|
|
|
mot_contrl_rtlimit(ctrl);
|
|
mot_contrl_rtlimit(ctrl);
|
|
|
- mot_contrl_enable_hfi(ctrl, true);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ mot_contrl_enable_hfi(ctrl, start);
|
|
|
ctrl->b_ebrk_running = false;
|
|
ctrl->b_ebrk_running = false;
|
|
|
ctrl->b_AutoHold = false;
|
|
ctrl->b_AutoHold = false;
|
|
|
ctrl->b_cruiseEna = false;
|
|
ctrl->b_cruiseEna = false;
|
|
@@ -101,17 +101,17 @@ void mot_contrl_enable_hfi(mot_contrl_t *ctrl, bool enable) {
|
|
|
ctrl->b_hfi = enable;
|
|
ctrl->b_hfi = enable;
|
|
|
}
|
|
}
|
|
|
#else
|
|
#else
|
|
|
-#define HFI_PLL_BAND 100.0F
|
|
|
|
|
-#define HFI_IPD_V 30.0F
|
|
|
|
|
-#define HFI_RUNNING_V 30.0F
|
|
|
|
|
-#define HFI_SAMPLE_NUM 5000
|
|
|
|
|
|
|
+#define HFI_PLL_BAND 50.0F
|
|
|
|
|
+#define HFI_IPD_V 20.0F
|
|
|
|
|
+#define HFI_RUNNING_V 10.0F
|
|
|
|
|
+#define HFI_SAMPLE_NUM 8000
|
|
|
void mot_contrl_enable_hfi(mot_contrl_t *ctrl, bool enable) {
|
|
void mot_contrl_enable_hfi(mot_contrl_t *ctrl, bool enable) {
|
|
|
hfi_t *hfi = &ctrl->hfi;
|
|
hfi_t *hfi = &ctrl->hfi;
|
|
|
if (enable) {
|
|
if (enable) {
|
|
|
PI_Controller_Reset(&hfi->pi, 0);
|
|
PI_Controller_Reset(&hfi->pi, 0);
|
|
|
hfi->angle_deg = encoder_get_abi_angle();
|
|
hfi->angle_deg = encoder_get_abi_angle();
|
|
|
hfi->rad_integrator = degree_2_pi(hfi->angle_deg);
|
|
hfi->rad_integrator = degree_2_pi(hfi->angle_deg);
|
|
|
- hfi->v_inj = HFI_IPD_V;
|
|
|
|
|
|
|
+ hfi->v_inj = 0;
|
|
|
hfi->pi.ts = (1.0f/(float)CONFIG_IDQ_CTRL_TS);
|
|
hfi->pi.ts = (1.0f/(float)CONFIG_IDQ_CTRL_TS);
|
|
|
hfi->pi.kp = 2.0f * HFI_PLL_BAND;
|
|
hfi->pi.kp = 2.0f * HFI_PLL_BAND;
|
|
|
hfi->pi.ki = SQ(HFI_PLL_BAND);
|
|
hfi->pi.ki = SQ(HFI_PLL_BAND);
|
|
@@ -295,7 +295,8 @@ static __INLINE void hfi_pll_run(hfi_t *hfi, float alpha, float beta) {
|
|
|
float sin, cos;
|
|
float sin, cos;
|
|
|
arm_sin_cos(hfi->angle_deg, &sin, &cos);
|
|
arm_sin_cos(hfi->angle_deg, &sin, &cos);
|
|
|
float err = alpha * sin - beta * cos;
|
|
float err = alpha * sin - beta * cos;
|
|
|
- hfi->elec_vel = PI_Controller_Run(&hfi->pi, err);
|
|
|
|
|
|
|
+ float vel_elec = PI_Controller_Run(&hfi->pi, err);
|
|
|
|
|
+ LowPass_Filter(hfi->elec_vel, vel_elec, 0.05f);
|
|
|
hfi->rad_integrator += hfi->elec_vel * hfi->pi.ts;
|
|
hfi->rad_integrator += hfi->elec_vel * hfi->pi.ts;
|
|
|
norm_angle_rad(hfi->rad_integrator);
|
|
norm_angle_rad(hfi->rad_integrator);
|
|
|
hfi->angle_deg = pi_2_degree(hfi->rad_integrator);
|
|
hfi->angle_deg = pi_2_degree(hfi->rad_integrator);
|
|
@@ -318,18 +319,23 @@ static void mot_contrl_hfi_alpha_beta(mot_contrl_t *ctrl) {
|
|
|
float alpha = (ctrl->foc.in.curr_ab.a + hfi->sample_prev.a) * 0.5f;
|
|
float alpha = (ctrl->foc.in.curr_ab.a + hfi->sample_prev.a) * 0.5f;
|
|
|
float beta = (ctrl->foc.in.curr_ab.b + hfi->sample_prev.b) * 0.5f;
|
|
float beta = (ctrl->foc.in.curr_ab.b + hfi->sample_prev.b) * 0.5f;
|
|
|
|
|
|
|
|
|
|
+ hfi->hi_alpha_beta.a = hi_alpha;
|
|
|
|
|
+ hfi->hi_alpha_beta.b = hi_beta;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
hfi_pll_run(hfi, hi_alpha, hi_beta);
|
|
hfi_pll_run(hfi, hi_alpha, hi_beta);
|
|
|
|
|
+ hfi->rpm_vel = LowPass_Filter(hfi->rpm_vel, (hfi->elec_vel/M_PI*30/mc_conf()->m.poles) ,0.003f);
|
|
|
|
|
|
|
|
foc->in.mot_angle = hfi->angle_deg;
|
|
foc->in.mot_angle = hfi->angle_deg;
|
|
|
foc->in.mot_velocity = hfi->rpm_vel;
|
|
foc->in.mot_velocity = hfi->rpm_vel;
|
|
|
- arm_sin_cos(foc->in.mot_angle, &foc->sin, &foc->cos);
|
|
|
|
|
|
|
+
|
|
|
if (!hfi->ipd) {
|
|
if (!hfi->ipd) {
|
|
|
float v_inj = hfi->v_inj;
|
|
float v_inj = hfi->v_inj;
|
|
|
- step_towards(&v_inj, HFI_RUNNING_V, 1.0f);
|
|
|
|
|
|
|
+ step_towards(&v_inj, HFI_RUNNING_V, 0.1f);
|
|
|
hfi->v_inj = v_inj;
|
|
hfi->v_inj = v_inj;
|
|
|
}else {
|
|
}else {
|
|
|
float v_inj = hfi->v_inj;
|
|
float v_inj = hfi->v_inj;
|
|
|
- step_towards(&v_inj, HFI_IPD_V, 5.0f);
|
|
|
|
|
|
|
+ step_towards(&v_inj, HFI_IPD_V, 0.5f);
|
|
|
hfi->v_inj = v_inj;
|
|
hfi->v_inj = v_inj;
|
|
|
if (hfi->n_samples < HFI_SAMPLE_NUM) {
|
|
if (hfi->n_samples < HFI_SAMPLE_NUM) {
|
|
|
hfi->n_samples++;
|
|
hfi->n_samples++;
|
|
@@ -346,8 +352,6 @@ static void mot_contrl_hfi_alpha_beta(mot_contrl_t *ctrl) {
|
|
|
|
|
|
|
|
ctrl->foc.in.curr_ab.a = alpha;
|
|
ctrl->foc.in.curr_ab.a = alpha;
|
|
|
ctrl->foc.in.curr_ab.b = beta;
|
|
ctrl->foc.in.curr_ab.b = beta;
|
|
|
-
|
|
|
|
|
- hfi->rpm_vel = LowPass_Filter(hfi->rpm_vel, (hfi->elec_vel/M_PI*30/mc_conf()->m.poles) ,0.004f);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
#endif
|
|
@@ -385,14 +389,12 @@ bool mot_contrl_update(mot_contrl_t *ctrl) {
|
|
|
foc->in.target_vol_dq.d = line_ramp_get_interp(&ctrl->ramp_target_vd);
|
|
foc->in.target_vol_dq.d = line_ramp_get_interp(&ctrl->ramp_target_vd);
|
|
|
foc->in.target_vol_dq.q = line_ramp_get_interp(&ctrl->ramp_target_vq);
|
|
foc->in.target_vol_dq.q = line_ramp_get_interp(&ctrl->ramp_target_vq);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ arm_sin_cos(foc->in.mot_angle, &foc->sin, &foc->cos);
|
|
|
if (ctrl->b_hfi) {
|
|
if (ctrl->b_hfi) {
|
|
|
mot_contrl_hfi_alpha_beta(ctrl);
|
|
mot_contrl_hfi_alpha_beta(ctrl);
|
|
|
foc->in.v_ab_inj.a = ctrl->hfi.v_alpha_inj;
|
|
foc->in.v_ab_inj.a = ctrl->hfi.v_alpha_inj;
|
|
|
foc->in.v_ab_inj.b = ctrl->hfi.v_beta_inj;
|
|
foc->in.v_ab_inj.b = ctrl->hfi.v_beta_inj;
|
|
|
}else {
|
|
}else {
|
|
|
- arm_sin_cos(foc->in.mot_angle, &foc->sin, &foc->cos);
|
|
|
|
|
foc->in.v_ab_inj.a = 0;
|
|
foc->in.v_ab_inj.a = 0;
|
|
|
foc->in.v_ab_inj.b = 0;
|
|
foc->in.v_ab_inj.b = 0;
|
|
|
}
|
|
}
|