@@ -310,7 +310,7 @@ int FOCMotor::characteriseMotor(float voltage, float correction_factor=1.0f){
310310
311311 // store the measured values
312312 phase_resistance = 2 .0f * resistance;
313- phase_inductance_dq = {Ld, Lq};
313+ axis_inductance = {Ld, Lq};
314314 phase_inductance = (Ld + Lq) / 2 .0f ; // FOR BACKWARDS COMPATIBILITY
315315 return 0 ;
316316
@@ -546,20 +546,20 @@ int FOCMotor::tuneCurrentController(float bandwidth) {
546546 SIMPLEFOC_MOTOR_ERROR (" Fail. BW too high, current loop freq:" , (1e6f / loopfoc_time_us));
547547 return 2 ;
548548 }
549- if (!_isset (phase_resistance) || (!_isset (phase_inductance) && !_isset (phase_inductance_dq .q ))) {
549+ if (!_isset (phase_resistance) || (!_isset (phase_inductance) && !_isset (axis_inductance .q ))) {
550550 // need motor parameters to tune the controller
551551 SIMPLEFOC_MOTOR_WARN (" Motor params missing!" );
552552 if (characteriseMotor ( voltage_sensor_align )) {
553553 return 3 ;
554554 }
555- }else if (_isset (phase_inductance) && !(_isset (phase_inductance_dq .q ))) {
555+ }else if (_isset (phase_inductance) && !(_isset (axis_inductance .q ))) {
556556 // if only single inductance value is set, use it for both d and q axis
557- phase_inductance_dq = {phase_inductance, phase_inductance};
557+ axis_inductance = {phase_inductance, phase_inductance};
558558 }
559559
560- PID_current_q.P = phase_inductance_dq .q * (_2PI * bandwidth);
560+ PID_current_q.P = axis_inductance .q * (_2PI * bandwidth);
561561 PID_current_q.I = phase_resistance * (_2PI * bandwidth);
562- PID_current_d.P = phase_inductance_dq .d * (_2PI * bandwidth);
562+ PID_current_d.P = axis_inductance .d * (_2PI * bandwidth);
563563 PID_current_d.I = phase_resistance * (_2PI * bandwidth);
564564 LPF_current_d.Tf = 1 .0f / (_2PI * bandwidth * 5 .0f ); // filter cutoff at 5x bandwidth
565565 LPF_current_q.Tf = 1 .0f / (_2PI * bandwidth * 5 .0f ); // filter cutoff at 5x bandwidth
@@ -617,7 +617,7 @@ void FOCMotor::loopFOC() {
617617 // constrain voltage within limits
618618 voltage.q = _constrain (voltage.q , -voltage_limit, voltage_limit) + feed_forward_voltage.q ;
619619 // d voltage - lag compensation
620- if (_isset (phase_inductance_dq .q )) voltage.d = _constrain ( -current_sp*shaft_velocity*pole_pairs*phase_inductance_dq .q , -voltage_limit, voltage_limit) + feed_forward_voltage.d ;
620+ if (_isset (axis_inductance .q )) voltage.d = _constrain ( -current_sp*shaft_velocity*pole_pairs*axis_inductance .q , -voltage_limit, voltage_limit) + feed_forward_voltage.d ;
621621 else voltage.d = feed_forward_voltage.d ;
622622 break ;
623623 case TorqueControlType::dc_current:
@@ -631,7 +631,7 @@ void FOCMotor::loopFOC() {
631631 // calculate the phase voltage
632632 voltage.q = PID_current_q (current_sp - current.q ) + feed_forward_voltage.q ;
633633 // d voltage - lag compensation
634- if (_isset (phase_inductance_dq .q )) voltage.d = _constrain ( -current_sp*shaft_velocity*pole_pairs*phase_inductance_dq .q , -voltage_limit, voltage_limit) + feed_forward_voltage.d ;
634+ if (_isset (axis_inductance .q )) voltage.d = _constrain ( -current_sp*shaft_velocity*pole_pairs*axis_inductance .q , -voltage_limit, voltage_limit) + feed_forward_voltage.d ;
635635 else voltage.d = feed_forward_voltage.d ;
636636 break ;
637637 case TorqueControlType::foc_current:
@@ -647,9 +647,9 @@ void FOCMotor::loopFOC() {
647647 voltage.q = PID_current_q (current_sp - current.q ) + feed_forward_voltage.q ;
648648 voltage.d = PID_current_d (feed_forward_current.d - current.d ) + feed_forward_voltage.d ;
649649 // d voltage - lag compensation
650- if (_isset (phase_inductance_dq .q )) voltage.d = _constrain ( voltage.d - current_sp*shaft_velocity*pole_pairs*phase_inductance_dq .q , -voltage_limit, voltage_limit);
650+ if (_isset (axis_inductance .q )) voltage.d = _constrain ( voltage.d - current_sp*shaft_velocity*pole_pairs*axis_inductance .q , -voltage_limit, voltage_limit);
651651 // q voltage - cross coupling compensation - TODO verify
652- if (_isset (phase_inductance_dq .d )) voltage.q = _constrain ( voltage.q + current.d *shaft_velocity*pole_pairs*phase_inductance_dq .d , -voltage_limit, voltage_limit);
652+ if (_isset (axis_inductance .d )) voltage.q = _constrain ( voltage.q + current.d *shaft_velocity*pole_pairs*axis_inductance .d , -voltage_limit, voltage_limit);
653653 break ;
654654 default :
655655 // no torque control selected
0 commit comments