Skip to content

Commit 271a0b6

Browse files
committed
FEAT if added phase resistance the torque control is with current
1 parent d471970 commit 271a0b6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/BLDCMotor.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void BLDCMotor::init() {
2828

2929
// if no current sensing and the user has set the phase resistance of the motor use current limit to calculate the voltage limit
3030
if( !current_sense && _isset(phase_resistance)) {
31-
float new_voltage_limit = current_limit * (phase_resistance*1.5); // v_lim = current_lim / (3/2 phase resistance) - worst case
31+
float new_voltage_limit = current_limit * (phase_resistance); // v_lim = current_lim / (3/2 phase resistance) - worst case
3232
// use it if it is less then voltage_limit set by the user
3333
voltage_limit = new_voltage_limit < voltage_limit ? new_voltage_limit : voltage_limit;
3434
}
@@ -300,8 +300,9 @@ void BLDCMotor::move(float new_target) {
300300

301301
switch (controller) {
302302
case MotionControlType::torque:
303-
if(torque_controller == TorqueControlType::voltage)
304-
voltage.q = target; // if voltage torque control
303+
if(torque_controller == TorqueControlType::voltage) // if voltage torque control
304+
if(!_isset(phase_resistance)) voltage.q = current_sp;
305+
else voltage.q = target*phase_resistance;
305306
else
306307
current_sp = target; // if current/foc_current torque control
307308
break;
@@ -316,7 +317,7 @@ void BLDCMotor::move(float new_target) {
316317
if(torque_controller == TorqueControlType::voltage){
317318
// use voltage if phase-resistance not provided
318319
if(!_isset(phase_resistance)) voltage.q = current_sp;
319-
else voltage.q = current_sp*1.5*phase_resistance;
320+
else voltage.q = current_sp*phase_resistance;
320321
voltage.d = 0;
321322
}
322323
break;
@@ -329,7 +330,7 @@ void BLDCMotor::move(float new_target) {
329330
if(torque_controller == TorqueControlType::voltage){
330331
// use voltage if phase-resistance not provided
331332
if(!_isset(phase_resistance)) voltage.q = current_sp;
332-
else voltage.q = current_sp*1.5*phase_resistance;
333+
else voltage.q = current_sp*phase_resistance;
333334
voltage.d = 0;
334335
}
335336
break;

0 commit comments

Comments
 (0)