Skip to content

Commit 79af273

Browse files
committed
move setting target to beginning of move()
1 parent 27189ec commit 79af273

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/motors/HybridStepperMotor/HybridStepperMotor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ void HybridStepperMotor::loopFOC()
295295
void HybridStepperMotor::move(float new_target)
296296
{
297297

298+
// set internal target variable
299+
if (_isset(new_target))
300+
target = new_target;
301+
298302
// downsampling (optional)
299303
if (motion_cnt++ < motion_downsample)
300304
return;
@@ -315,9 +319,6 @@ void HybridStepperMotor::move(float new_target)
315319
if (!enabled)
316320
return;
317321

318-
// set internal target variable
319-
if (_isset(new_target))
320-
target = new_target;
321322

322323
// calculate the back-emf voltage if KV_rating available U_bemf = vel*(1/KV)
323324
if (_isset(KV_rating))

0 commit comments

Comments
 (0)