Skip to content

Commit

Permalink
move setting target to beginning of move()
Browse files Browse the repository at this point in the history
  • Loading branch information
runger1101001 committed Jun 5, 2024
1 parent 27189ec commit 79af273
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/motors/HybridStepperMotor/HybridStepperMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ void HybridStepperMotor::loopFOC()
void HybridStepperMotor::move(float new_target)
{

// set internal target variable
if (_isset(new_target))
target = new_target;

// downsampling (optional)
if (motion_cnt++ < motion_downsample)
return;
Expand All @@ -315,9 +319,6 @@ void HybridStepperMotor::move(float new_target)
if (!enabled)
return;

// set internal target variable
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))
Expand Down

0 comments on commit 79af273

Please sign in to comment.