|
|
@@ -18,7 +18,7 @@ static shark_timer_t _ldq_ind_timer = TIMER_INIT(_ldq_ind_timer, _ldq_ind_timer_
|
|
|
static void _flux_ind_timer_handler(shark_timer_t *);
|
|
|
static shark_timer_t _flux_ind_timer = TIMER_INIT(_flux_ind_timer, _flux_ind_timer_handler);
|
|
|
|
|
|
-static float rs_id_max, rs_vd_max, rs_vd_now, rs_est_value;
|
|
|
+static float rs_id_max, rs_vd_max, rs_vd_now, rs_est_value = 0.011f;
|
|
|
static s32 rs_meas_time;
|
|
|
static bool b_rs_ind = false, b_rs_ested = false, b_ldq_ind = false, b_ld_ested = false, b_lq_ested = false, b_flux_ind = false, b_flux_ested = false;
|
|
|
static u8 rs_ind_step = 0;
|
|
|
@@ -47,6 +47,7 @@ void mot_params_ind_stop(void) {
|
|
|
b_rs_ind = false;
|
|
|
b_ldq_ind = false;
|
|
|
b_flux_ind = false;
|
|
|
+ mot_ctrl_set_ind_freq(mot_contrl(), 0);
|
|
|
cpu_exit_critical(mask);
|
|
|
mot_contrl_set_vdq(&motor.controller, 0, 0);
|
|
|
mot_contrl_set_current(&motor.controller, 0);
|
|
|
@@ -94,12 +95,8 @@ static void _rs_ind_timer_handler(shark_timer_t *t) {
|
|
|
}
|
|
|
break;
|
|
|
case 3: {
|
|
|
- float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_period) * motor.controller.foc.in.dc_vol * 0.2f;
|
|
|
-#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==0
|
|
|
+ float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_period) * motor.controller.foc.in.dc_vol * 0.667f;
|
|
|
float vd = rs_vd_now * TWO_BY_THREE - dtc;
|
|
|
-#else
|
|
|
- float vd = motor.controller.phase_v_dq.d;
|
|
|
-#endif
|
|
|
float id = motor.controller.foc.out.curr_dq.d;
|
|
|
float rs = vd / (id + 0.0001f);
|
|
|
rs_est_value = LowPass_Filter(rs_est_value, rs, 0.2f);
|
|
|
@@ -166,6 +163,7 @@ void mot_params_ind_inductance(float v, float freq, u16 l_type) {
|
|
|
v_samples = os_alloc(sizeof(float) * hj_samples);
|
|
|
i_samples = os_alloc(sizeof(float) * hj_samples);
|
|
|
if (v_samples != NULL && i_samples != NULL) {
|
|
|
+ mot_ctrl_set_ind_freq(mot_contrl(), freq);
|
|
|
b_ldq_ind = true;
|
|
|
shark_timer_post(&_ldq_ind_timer, 10);
|
|
|
}else {
|
|
|
@@ -258,8 +256,9 @@ void mot_params_calc_inductance(void) {
|
|
|
sys_debug("v %f, %f, %f\n", v_mag/(hj_samples*0.5f), v_real, v_image);
|
|
|
sys_debug("i %f, %f, %f\n", i_mag/(hj_samples*0.5f), i_real, i_image);
|
|
|
sys_debug("vmag %f, %f\n", v_mag, Vdead * hj_samples*0.5f);
|
|
|
+#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==0
|
|
|
v_mag -= Vdead * hj_samples*0.5f;
|
|
|
-
|
|
|
+#endif
|
|
|
float z_angle = fast_atan2(i_image, i_real) - fast_atan2(v_image, v_real);
|
|
|
float s,c;
|
|
|
arm_sin_cos(pi_2_degree(z_angle), &s, &c);
|