Skip to content

Commit daaa3e1

Browse files
author
askuric
committed
removed K_bemf and added KV_rating
1 parent 249e6a3 commit daaa3e1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/BLDCMotor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ BLDCMotor::BLDCMotor(int pp, float _R, float _KV)
1313
// save phase resistance number
1414
phase_resistance = _R;
1515
// save back emf constant KV = 1/KV
16-
K_bemf = _isset(_KV) ? 1.0f/_KV/_RPM_TO_RADS : NOT_SET;
16+
KV_rating = _KV;
1717

1818
// torque control type is voltage by default
1919
torque_controller = TorqueControlType::voltage;
@@ -344,9 +344,9 @@ void BLDCMotor::move(float new_target) {
344344
if(!enabled) return;
345345
// set internal target variable
346346
if(_isset(new_target)) target = new_target;
347-
348-
// calculate the back-emf voltage if K_bemf available
349-
if (_isset(K_bemf)) voltage_bemf = K_bemf*shaft_velocity;
347+
348+
// calculate the back-emf voltage if KV_rating available U_bemf = vel*(1/KV)
349+
if (_isset(KV_rating)) voltage_bemf = shaft_velocity/KV_rating/_RPM_TO_RADS;
350350
// estimate the motor current if phase reistance available and current_sense not available
351351
if(!current_sense && _isset(phase_resistance)) current.q = (voltage.q - voltage_bemf)/phase_resistance;
352352

src/StepperMotor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ StepperMotor::StepperMotor(int pp, float _R, float _KV)
1313
pole_pairs = pp;
1414
// save phase resistance number
1515
phase_resistance = _R;
16-
// save back emf constant KV = 1/KV
17-
K_bemf = _isset(_KV) ? 1.0f/_KV/_RPM_TO_RADS : NOT_SET;
16+
// save back emf constant KV = 1/K_bemf
17+
KV_rating = _KV;
1818

1919
// torque control type is voltage by default
2020
// current and foc_current not supported yet
@@ -282,8 +282,8 @@ void StepperMotor::move(float new_target) {
282282
// set internal target variable
283283
if(_isset(new_target) ) target = new_target;
284284

285-
// calculate the back-emf voltage if K_bemf available
286-
if (_isset(K_bemf)) voltage_bemf = K_bemf*shaft_velocity;
285+
// calculate the back-emf voltage if KV_rating available U_bemf = vel*(1/KV)
286+
if (_isset(KV_rating)) voltage_bemf = shaft_velocity/KV_rating/_RPM_TO_RADS;
287287
// estimate the motor current if phase reistance available and current_sense not available
288288
if(!current_sense && _isset(phase_resistance)) current.q = (voltage.q - voltage_bemf)/phase_resistance;
289289

src/common/base_classes/FOCMotor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class FOCMotor
161161
// motor physical parameters
162162
float phase_resistance; //!< motor phase resistance
163163
int pole_pairs;//!< motor pole pairs number
164-
float K_bemf; //!< motor back emf constant (1/KV)
164+
float KV_rating; //!< motor KV rating
165165

166166
// limiting variables
167167
float voltage_limit; //!< Voltage limitting variable - global limit

src/communication/Commander.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
224224
case CMD_KV_RATING:
225225
printVerbose(F("Motor KV: "));
226226
if(!GET){
227-
motor->K_bemf = 1.0f/value/_RPM_TO_RADS;
227+
motor->KV_rating = value;
228228
}
229-
if(_isset(motor->K_bemf)) println(1.0f/motor->K_bemf/_RPM_TO_RADS);
229+
if(_isset(motor->KV_rating)) println(motor->KV_rating);
230230
else println(0);
231231
break;
232232
case CMD_SENSOR:

0 commit comments

Comments
 (0)