Skip to content

Commit

Permalink
apply fix to stepper motor logic as well
Browse files Browse the repository at this point in the history
  • Loading branch information
nmscode committed Nov 27, 2023
1 parent d4e1c2c commit afdbd9d
Showing 1 changed file with 2 additions and 2 deletions.
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

2 comments on commit afdbd9d

@dzid26
Copy link

@dzid26 dzid26 commented on afdbd9d Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be _SQRT2 for the stepper, no ?
If I measure phase voltage as 10Vrms with a voltmeter, then peak is 1.41V.

@askuric
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, my bad. I did this too quickly.

Please sign in to comment.