Skip to content

Commit

Permalink
Merge pull request #347 from nmscode/kv_rating_fix
Browse files Browse the repository at this point in the history
Kv rating fix
  • Loading branch information
runger1101001 authored Dec 2, 2023
2 parents 030508f + afdbd9d commit 186e5cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/BLDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BLDCMotor::BLDCMotor(int pp, float _R, float _KV, float _inductance)
// 1/sqrt(2) - rms value
KV_rating = NOT_SET;
if (_isset(_KV))
KV_rating = _KV*_SQRT2;
KV_rating = _KV;
// save phase inductance
phase_inductance = _inductance;

Expand Down Expand Up @@ -396,7 +396,7 @@ void BLDCMotor::move(float new_target) {
if(_isset(new_target)) target = new_target;

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

Expand Down
4 changes: 2 additions & 2 deletions src/StepperMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ StepperMotor::StepperMotor(int pp, float _R, float _KV, float _inductance)
phase_resistance = _R;
// save back emf constant KV = 1/K_bemf
// usually used rms
KV_rating = _KV*_SQRT2;
KV_rating = _KV;
// save phase inductance
phase_inductance = _inductance;

Expand Down Expand Up @@ -292,7 +292,7 @@ void StepperMotor::move(float new_target) {
if(_isset(new_target) ) target = new_target;

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

Expand Down

0 comments on commit 186e5cf

Please sign in to comment.