@@ -28,7 +28,7 @@ void BLDCMotor::init() {
28
28
29
29
// if no current sensing and the user has set the phase resistance of the motor use current limit to calculate the voltage limit
30
30
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
32
32
// use it if it is less then voltage_limit set by the user
33
33
voltage_limit = new_voltage_limit < voltage_limit ? new_voltage_limit : voltage_limit;
34
34
}
@@ -300,8 +300,9 @@ void BLDCMotor::move(float new_target) {
300
300
301
301
switch (controller) {
302
302
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;
305
306
else
306
307
current_sp = target; // if current/foc_current torque control
307
308
break ;
@@ -316,7 +317,7 @@ void BLDCMotor::move(float new_target) {
316
317
if (torque_controller == TorqueControlType::voltage){
317
318
// use voltage if phase-resistance not provided
318
319
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;
320
321
voltage.d = 0 ;
321
322
}
322
323
break ;
@@ -329,7 +330,7 @@ void BLDCMotor::move(float new_target) {
329
330
if (torque_controller == TorqueControlType::voltage){
330
331
// use voltage if phase-resistance not provided
331
332
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;
333
334
voltage.d = 0 ;
334
335
}
335
336
break ;
0 commit comments