|
|
@@ -3,6 +3,7 @@
|
|
|
#include "math/fast_math.h"
|
|
|
#include "foc/motor/mot_params_ind.h"
|
|
|
#include "libs/logger.h"
|
|
|
+#include "foc/samples.h"
|
|
|
#include "prot/can_foc_msg.h"
|
|
|
|
|
|
/*
|
|
|
@@ -87,6 +88,7 @@ static void _rs_ind_timer_handler(shark_timer_t *t) {
|
|
|
}
|
|
|
}else {
|
|
|
wait_iq_0_cnt = 0;
|
|
|
+ delay_ms(100);
|
|
|
rs_ind_step = 3;
|
|
|
sys_debug("start rs calc, %d\n", rs_meas_time);
|
|
|
}
|
|
|
@@ -94,8 +96,12 @@ static void _rs_ind_timer_handler(shark_timer_t *t) {
|
|
|
case 3: {
|
|
|
float *iabc = motor.controller.foc.in.curr_abc;
|
|
|
float d, q;
|
|
|
+ float v_a_final = 0;
|
|
|
+ float v_abc[3] = {0, 0, 0};
|
|
|
foc_abc_2_dq(SIGN(iabc[0]), SIGN(iabc[1]), SIGN(iabc[2]), &d, &q);
|
|
|
- float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_Half_Period) * motor.controller.foc.in.dc_vol * 1.5f;
|
|
|
+ get_uvw_phases_raw(v_abc);
|
|
|
+ v_a_final = LowPass_Filter(v_a_final, v_abc[0], 0.2f);
|
|
|
+ float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_period) * motor.controller.foc.in.dc_vol * TWO_BY_THREE;
|
|
|
float vd = (rs_vd_now - dtc) * TWO_BY_THREE;
|
|
|
float id = motor.controller.foc.out.curr_dq.d;
|
|
|
float rs = vd / (id + 0.0001f);
|
|
|
@@ -106,8 +112,9 @@ static void _rs_ind_timer_handler(shark_timer_t *t) {
|
|
|
mc_ind_motor_start(false);
|
|
|
finish = true;
|
|
|
b_rs_ested = true;
|
|
|
- sys_debug("est rs = %f\n", rs_est_value);
|
|
|
- sys_debug("vd-id is %f-%f-%f, wait %d\n", rs_vd_now, id, dtc/1.5f, wait_iq_0_cnt);
|
|
|
+ sys_debug("est rs = %f-%f\n", rs_est_value, rs);
|
|
|
+ sys_debug("vd-id is %f-%f-%f-%f, wait %d\n", rs_vd_now, id, dtc/1.5f, vd, wait_iq_0_cnt);
|
|
|
+ sys_debug("Va = %f\n", v_a_final);
|
|
|
}
|
|
|
}
|
|
|
default:
|
|
|
@@ -145,7 +152,7 @@ void mot_params_ind_inductance(float v, float freq, u16 l_type) {
|
|
|
hj_n = (float)FOC_PWM_FS / hj_freq;
|
|
|
hj_samples = hj_n * 50;
|
|
|
K_terms = (s32) (0.5f + hj_samples*hj_freq/(float)FOC_PWM_FS);
|
|
|
- Vdead = motor.controller.foc.in.dc_vol * 0.5f * (float)CONFIG_HW_DeadTime / (float)FOC_PWM_period;
|
|
|
+ Vdead = motor.controller.foc.in.dc_vol * (float)CONFIG_HW_DeadTime / (float)FOC_PWM_period * TWO_BY_THREE;
|
|
|
hj_w = 360.0f / hj_n;
|
|
|
sys_debug("hj %f, %f, %f, %f, %f, %f, %f\n", hj_v, hj_freq, hj_n, hj_samples, K_terms, Vdead, hj_w);
|
|
|
float fft_angle = 360.0f / hj_samples * K_terms;
|
|
|
@@ -265,7 +272,7 @@ void mot_params_calc_inductance(void) {
|
|
|
float z_image = z_mag * s;
|
|
|
float Rs = rs_est_value;
|
|
|
float Ri = (SQ(z_real - Rs) + SQ(z_image))/(z_real - Rs + 0.0000001f);
|
|
|
- float l = Ri * (z_real - Rs)/(hj_freq * 2 * PI * z_image + 0.0000001f) * 0.83f; //0.83f just for v3 board
|
|
|
+ float l = Ri * (z_real - Rs)/(hj_freq * 2 * PI * z_image + 0.0000001f) * 0.9f;
|
|
|
if (n_ind_ld == L_TYPE_D) {
|
|
|
ld_est_value = l;
|
|
|
b_ld_ested = true;
|