Skip to content

Commit d170176

Browse files
committed
renamed inductacne
1 parent 0f4300e commit d170176

6 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/BLDCMotor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ BLDCMotor::BLDCMotor(int pp, float _R, float _KV, float _Lq, float _Ld)
4747
// 1/sqrt(3) - rms value
4848
KV_rating = _KV;
4949
// save phase inductance
50-
phase_inductance_dq = {_Ld, _Lq};
50+
axis_inductance = {_Ld, _Lq};
5151
phase_inductance = _Lq; // FOR BACKWARDS COMPATIBILITY
5252

5353
// torque control type is voltage by default
@@ -82,9 +82,9 @@ int BLDCMotor::init() {
8282
updateVoltageLimit(voltage_limit);
8383
updateVelocityLimit(velocity_limit);
8484

85-
if(_isset(phase_inductance) && !(_isset(phase_inductance_dq.q))) {
85+
if(_isset(phase_inductance) && !(_isset(axis_inductance.q))) {
8686
// if only single inductance value is set, use it for both d and q axis
87-
phase_inductance_dq = {phase_inductance, phase_inductance};
87+
axis_inductance = {phase_inductance, phase_inductance};
8888
}
8989

9090
// if using open loop control, set a CW as the default direction if not already set

src/HybridStepperMotor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ HybridStepperMotor::HybridStepperMotor(int pp, float _R, float _KV, float _Lq, f
1818
// usually used rms
1919
KV_rating = _KV;
2020
// save phase inductance
21-
phase_inductance_dq = {_Ld, _Lq};
21+
axis_inductance = {_Ld, _Lq};
2222
phase_inductance = _Lq; // FOR BACKWARDS COMPATIBILITY
2323

2424

@@ -66,9 +66,9 @@ int HybridStepperMotor::init()
6666
updateVoltageLimit(voltage_limit);
6767
updateVelocityLimit(velocity_limit);
6868

69-
if(_isset(phase_inductance) && !(_isset(phase_inductance_dq.q))) {
69+
if(_isset(phase_inductance) && !(_isset(axis_inductance.q))) {
7070
// if only single inductance value is set, use it for both d and q axis
71-
phase_inductance_dq = {phase_inductance, phase_inductance};
71+
axis_inductance = {phase_inductance, phase_inductance};
7272
}
7373

7474
// if using open loop control, set a CW as the default direction if not already set

src/StepperMotor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ StepperMotor::StepperMotor(int pp, float _R, float _KV, float _Lq, float _Ld)
1919
// usually used rms
2020
KV_rating = _KV;
2121
// save phase inductance
22-
phase_inductance_dq = {_Ld, _Lq};
22+
axis_inductance = {_Ld, _Lq};
2323
phase_inductance = _Lq; // FOR BACKWARDS COMPATIBILITY
2424

2525
// torque control type is voltage by default
@@ -54,9 +54,9 @@ int StepperMotor::init() {
5454
updateVoltageLimit(voltage_limit);
5555
updateVelocityLimit(velocity_limit);
5656

57-
if(_isset(phase_inductance) && !(_isset(phase_inductance_dq.q))) {
57+
if(_isset(phase_inductance) && !(_isset(axis_inductance.q))) {
5858
// if only single inductance value is set, use it for both d and q axis
59-
phase_inductance_dq = {phase_inductance, phase_inductance};
59+
axis_inductance = {phase_inductance, phase_inductance};
6060
}
6161

6262

src/common/base_classes/FOCMotor.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/common/base_classes/FOCMotor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class FOCMotor
228228
int pole_pairs;//!< motor pole pairs number
229229
float KV_rating; //!< motor KV rating
230230
float phase_inductance; //!< motor phase inductance q axis - FOR BACKWARDS COMPATIBILITY
231-
DQ_s phase_inductance_dq{NOT_SET, NOT_SET}; //!< motor direct axis phase inductance
231+
DQ_s axis_inductance{NOT_SET, NOT_SET}; //!< motor direct axis phase inductance
232232

233233
// limiting variables
234234
float voltage_limit; //!< Voltage limiting variable - global limit

src/communication/Commander.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,25 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
228228
case SCMD_INDUCT_D:
229229
printVerbose(F("d: "));
230230
if(!GET){
231-
motor->phase_inductance_dq.d = value;
231+
motor->axis_inductance.d = value;
232232
motor->phase_inductance = value;
233233
}
234-
if(_isset(motor->phase_inductance_dq.d)) println(motor->phase_inductance_dq.d);
234+
if(_isset(motor->axis_inductance.d)) println(motor->axis_inductance.d);
235235
else println(0);
236236
break;
237237
case SCMD_INDUCT_Q:
238238
printVerbose(F("q: "));
239239
if(!GET){
240-
motor->phase_inductance_dq.q = value;
240+
motor->axis_inductance.q = value;
241241
}
242-
if(_isset(motor->phase_inductance_dq.q)) println(motor->phase_inductance_dq.q);
242+
if(_isset(motor->axis_inductance.q)) println(motor->axis_inductance.q);
243243
else println(0);
244244
break;
245245
default:
246246
if(!GET){
247247
motor->phase_inductance = value;
248-
motor->phase_inductance_dq.d = value;
249-
motor->phase_inductance_dq.q = value;
248+
motor->axis_inductance.d = value;
249+
motor->axis_inductance.q = value;
250250
}
251251
if(_isset(motor->phase_inductance)) println(motor->phase_inductance);
252252
else println(0);

0 commit comments

Comments
 (0)