Skip to content

Commit 36c333c

Browse files
committed
Apply ld_lq_diff in detection
1 parent f6e78a0 commit 36c333c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

conf_general.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ void conf_general_calc_apply_foc_cc_kp_ki_gain(mc_configuration *mcconf, float t
12961296
}
12971297

12981298
static bool measure_r_l_imax(float current_min, float current_max,
1299-
float max_power_loss, float *r, float *l, float *i_max) {
1299+
float max_power_loss, float *r, float *l, float *ld_lq_diff, float *i_max) {
13001300
float current_start = current_max / 50;
13011301
if (current_start < (current_min * 1.1)) {
13021302
current_start = current_min * 1.1;
@@ -1327,7 +1327,8 @@ static bool measure_r_l_imax(float current_min, float current_max,
13271327
mcconf->foc_motor_r = *r;
13281328
mc_interface_set_configuration(mcconf);
13291329

1330-
*l = mcpwm_foc_measure_inductance_current(i_last, 100, 0, 0) * 1e-6;
1330+
*l = mcpwm_foc_measure_inductance_current(i_last, 100, 0, ld_lq_diff) * 1e-6;
1331+
*ld_lq_diff *= 1e-6;
13311332
*i_max = sqrtf(max_power_loss / *r / 1.5);
13321333
utils_truncate_number(i_max, HW_LIM_CURRENT);
13331334

@@ -1396,6 +1397,7 @@ typedef struct {
13961397
float max_power_loss;
13971398
float r;
13981399
float l;
1400+
float ld_lq_diff;
13991401
float i_max;
14001402
bool res;
14011403
int motor;
@@ -1408,7 +1410,7 @@ static void measure_r_l_imax_task(void *arg) {
14081410
args->current_min,
14091411
args->current_max,
14101412
args->max_power_loss,
1411-
&args->r, &args->l, &args->i_max);
1413+
&args->r, &args->l, &args->ld_lq_diff, &args->i_max);
14121414
}
14131415

14141416
typedef struct {
@@ -1567,9 +1569,10 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
15671569

15681570
float r = 0.0;
15691571
float l = 0.0;
1572+
float ld_lq_diff;
15701573
float i_max = 0.0;
15711574
bool res_r_l_imax_m1 = measure_r_l_imax(mcconf->cc_min_current,
1572-
mcconf->l_current_max, max_power_loss, &r, &l, &i_max);
1575+
mcconf->l_current_max, max_power_loss, &r, &l, &ld_lq_diff, &i_max);
15731576

15741577
#ifdef HW_HAS_DUAL_MOTORS
15751578
worker_wait();
@@ -1642,6 +1645,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
16421645
mcconf_old->motor_type = MOTOR_TYPE_FOC;
16431646
mcconf_old->foc_motor_r = r;
16441647
mcconf_old->foc_motor_l = l;
1648+
mcconf_old->foc_motor_ld_lq_diff = ld_lq_diff;
16451649
mcconf_old->foc_motor_flux_linkage = lambda;
16461650

16471651
if (mc_interface_temp_motor_filtered() > -10) {
@@ -1660,6 +1664,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
16601664
mcconf_old_second->motor_type = MOTOR_TYPE_FOC;
16611665
mcconf_old_second->foc_motor_r = r_l_imax_args.r;
16621666
mcconf_old_second->foc_motor_l = r_l_imax_args.l;
1667+
mcconf_old_second->foc_motor_ld_lq_diff = r_l_imax_args.ld_lq_diff;
16631668
mcconf_old_second->foc_motor_flux_linkage = linkage_args.linkage;
16641669
conf_general_calc_apply_foc_cc_kp_ki_gain(mcconf_old_second, 1000);
16651670
mc_interface_select_motor_thread(2);

0 commit comments

Comments
 (0)