From 3059e5a493bd0958f82cc068c71a477df9386c6e Mon Sep 17 00:00:00 2001 From: Holger Weber Date: Sun, 22 Feb 2026 21:54:31 +0100 Subject: [PATCH] Fix first motor command by setting speed before move --- src/Helper_Functions.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Helper_Functions.cpp b/src/Helper_Functions.cpp index e8ed46d..e2b316a 100644 --- a/src/Helper_Functions.cpp +++ b/src/Helper_Functions.cpp @@ -124,15 +124,15 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB) } - if ((1 == fROT_STEP_CORRECTION) && (1 == fPEN_STEP_CORRECTION)) - { // if coordinatessystems are identical - // set Coordinates and Speed - g_pStepperRotate->move(rotStepsEBB); - g_pStepperRotate->setSpeedInTicks(abs((float)rotStepsEBB * (float)1000 / (float)duration)); + if ((1 == fROT_STEP_CORRECTION) && (1 == fPEN_STEP_CORRECTION)) + { // if coordinatessystems are identical + // set Coordinates and Speed + g_pStepperRotate->setSpeedInTicks(abs((float)rotStepsEBB * (float)1000 / (float)duration)); + g_pStepperRotate->move(rotStepsEBB); - g_pStepperPen->move(penStepsEBB); - g_pStepperPen->setSpeedInTicks(abs((float)penStepsEBB * (float)1000 / (float)duration)); - } + g_pStepperPen->setSpeedInTicks(abs((float)penStepsEBB * (float)1000 / (float)duration)); + g_pStepperPen->move(penStepsEBB); + } else { // incoming EBB-Steps will be multiplied by 16, then Integer-maths is done, result will be divided by 16 @@ -150,16 +150,16 @@ void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB) long temp_penSpeed = ((long)penStepsToGo * (long)1000 / (long)duration); float rotSpeed = (float)abs(temp_rotSpeed); // type cast - float penSpeed = (float)abs(temp_penSpeed); + float penSpeed = (float)abs(temp_penSpeed); - // set Coordinates and Speed - g_pStepperRotate->move(rotStepsToGo); - g_pStepperRotate->setSpeedInTicks(rotSpeed); + // set Coordinates and Speed + g_pStepperRotate->setSpeedInTicks(rotSpeed); + g_pStepperRotate->move(rotStepsToGo); - g_pStepperPen->move(penStepsToGo); - g_pStepperPen->setSpeedInTicks(penSpeed); + g_pStepperPen->setSpeedInTicks(penSpeed); + g_pStepperPen->move(penStepsToGo); + } } -} void moveOneStep() {