@@ -1296,7 +1296,7 @@ void conf_general_calc_apply_foc_cc_kp_ki_gain(mc_configuration *mcconf, float t
1296
1296
}
1297
1297
1298
1298
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 ) {
1300
1300
float current_start = current_max / 50 ;
1301
1301
if (current_start < (current_min * 1.1 )) {
1302
1302
current_start = current_min * 1.1 ;
@@ -1327,7 +1327,8 @@ static bool measure_r_l_imax(float current_min, float current_max,
1327
1327
mcconf -> foc_motor_r = * r ;
1328
1328
mc_interface_set_configuration (mcconf );
1329
1329
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 ;
1331
1332
* i_max = sqrtf (max_power_loss / * r / 1.5 );
1332
1333
utils_truncate_number (i_max , HW_LIM_CURRENT );
1333
1334
@@ -1396,6 +1397,7 @@ typedef struct {
1396
1397
float max_power_loss ;
1397
1398
float r ;
1398
1399
float l ;
1400
+ float ld_lq_diff ;
1399
1401
float i_max ;
1400
1402
bool res ;
1401
1403
int motor ;
@@ -1408,7 +1410,7 @@ static void measure_r_l_imax_task(void *arg) {
1408
1410
args -> current_min ,
1409
1411
args -> current_max ,
1410
1412
args -> max_power_loss ,
1411
- & args -> r , & args -> l , & args -> i_max );
1413
+ & args -> r , & args -> l , & args -> ld_lq_diff , & args -> i_max );
1412
1414
}
1413
1415
1414
1416
typedef struct {
@@ -1567,9 +1569,10 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
1567
1569
1568
1570
float r = 0.0 ;
1569
1571
float l = 0.0 ;
1572
+ float ld_lq_diff ;
1570
1573
float i_max = 0.0 ;
1571
1574
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 );
1573
1576
1574
1577
#ifdef HW_HAS_DUAL_MOTORS
1575
1578
worker_wait ();
@@ -1642,6 +1645,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
1642
1645
mcconf_old -> motor_type = MOTOR_TYPE_FOC ;
1643
1646
mcconf_old -> foc_motor_r = r ;
1644
1647
mcconf_old -> foc_motor_l = l ;
1648
+ mcconf_old -> foc_motor_ld_lq_diff = ld_lq_diff ;
1645
1649
mcconf_old -> foc_motor_flux_linkage = lambda ;
1646
1650
1647
1651
if (mc_interface_temp_motor_filtered () > -10 ) {
@@ -1660,6 +1664,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
1660
1664
mcconf_old_second -> motor_type = MOTOR_TYPE_FOC ;
1661
1665
mcconf_old_second -> foc_motor_r = r_l_imax_args .r ;
1662
1666
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 ;
1663
1668
mcconf_old_second -> foc_motor_flux_linkage = linkage_args .linkage ;
1664
1669
conf_general_calc_apply_foc_cc_kp_ki_gain (mcconf_old_second , 1000 );
1665
1670
mc_interface_select_motor_thread (2 );
0 commit comments