From d35936cc828b52274a627c8914605027c8d4faee Mon Sep 17 00:00:00 2001 From: Fahad Alduraibi Date: Sat, 6 Sep 2025 23:06:59 +0300 Subject: [PATCH 1/5] A new function to idle the motor after stepping A new function that allow setting the idle option to power down all the motor coils after stepping, in order to reduce power and heat. That also allows manual rotation of the motor. --- src/Stepper.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Stepper.cpp b/src/Stepper.cpp index 148de03..b33e33f 100644 --- a/src/Stepper.cpp +++ b/src/Stepper.cpp @@ -88,6 +88,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2) this->direction = 0; // motor direction this->last_step_time = 0; // timestamp in us of the last step taken this->number_of_steps = number_of_steps; // total number of steps for this motor + this->idle = false; // Power down all coils after done stepping // Arduino pins for the motor control connection: this->motor_pin_1 = motor_pin_1; @@ -118,6 +119,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, this->direction = 0; // motor direction this->last_step_time = 0; // timestamp in us of the last step taken this->number_of_steps = number_of_steps; // total number of steps for this motor + this->idle = false; // Power down all coils after done stepping // Arduino pins for the motor control connection: this->motor_pin_1 = motor_pin_1; @@ -150,6 +152,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, this->direction = 0; // motor direction this->last_step_time = 0; // timestamp in us of the last step taken this->number_of_steps = number_of_steps; // total number of steps for this motor + this->idle = false; // Power down all coils after done stepping // Arduino pins for the motor control connection: this->motor_pin_1 = motor_pin_1; @@ -226,6 +229,21 @@ void Stepper::step(int steps_to_move) yield(); } } + // If ideling is enabled then power down all coils + if (this->idle == true) + { + digitalWrite(motor_pin_1, LOW); + digitalWrite(motor_pin_2, LOW); + if (this->pin_count == 4) + { + digitalWrite(motor_pin_1, LOW); + digitalWrite(motor_pin_2, LOW); + digitalWrite(motor_pin_3, LOW); + digitalWrite(motor_pin_4, LOW); + } + if (this->pin_count == 5) + digitalWrite(motor_pin_5, LOW); + } } /* @@ -358,6 +376,15 @@ void Stepper::stepMotor(int thisStep) } } +/* + * Allow powering down all coils after stepping, + * to reduce heat, power and allow manuall rotation. + */ +void Stepper::idelAfterStep(bool idle) +{ + this->idle = idle; +} + /* version() returns the version of the library: */ From e98e0f5f61e154f653a4fd16abdc1866124fd936 Mon Sep 17 00:00:00 2001 From: Fahad Alduraibi Date: Sat, 6 Sep 2025 23:13:18 +0300 Subject: [PATCH 2/5] A new function to idle the motor after stepping A new function that allow setting the idle option to power down all the motor coils after stepping, in order to reduce power and heat. That also allows manual rotation of the motor. --- src/Stepper.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Stepper.h b/src/Stepper.h index b5578b4..1ade9f2 100644 --- a/src/Stepper.h +++ b/src/Stepper.h @@ -95,6 +95,9 @@ class Stepper { // mover method: void step(int number_of_steps); + + // Power down all coils after stepping, to reduce heat, power and allow manuall rotation. + void idelAfterStep(bool idle); int version(void); @@ -106,6 +109,7 @@ class Stepper { int number_of_steps; // total number of steps this motor can take int pin_count; // how many pins are in use. int step_number; // which step the motor is on + bool idle; // Power down all coils after done stepping // motor pin numbers: int motor_pin_1; From f0d1657223ff1444da1f20b80151b8765da6e5ba Mon Sep 17 00:00:00 2001 From: Fahad Date: Sat, 6 Sep 2025 23:43:37 +0300 Subject: [PATCH 3/5] Spelling correction --- src/Stepper.cpp | 2 +- src/Stepper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stepper.cpp b/src/Stepper.cpp index b33e33f..98fbf00 100644 --- a/src/Stepper.cpp +++ b/src/Stepper.cpp @@ -378,7 +378,7 @@ void Stepper::stepMotor(int thisStep) /* * Allow powering down all coils after stepping, - * to reduce heat, power and allow manuall rotation. + * to reduce heat, power and allow manual rotation. */ void Stepper::idelAfterStep(bool idle) { diff --git a/src/Stepper.h b/src/Stepper.h index 1ade9f2..0ea8aa8 100644 --- a/src/Stepper.h +++ b/src/Stepper.h @@ -96,7 +96,7 @@ class Stepper { // mover method: void step(int number_of_steps); - // Power down all coils after stepping, to reduce heat, power and allow manuall rotation. + // Power down all coils after stepping, to reduce heat, power and allow manual rotation. void idelAfterStep(bool idle); int version(void); From 3fca9caf573088dce3f89869fcc2900190fa4449 Mon Sep 17 00:00:00 2001 From: fduraibi Date: Sun, 7 Sep 2025 00:05:05 +0300 Subject: [PATCH 4/5] Revert "Spelling correction" This reverts commit f0d1657223ff1444da1f20b80151b8765da6e5ba. --- src/Stepper.cpp | 2 +- src/Stepper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stepper.cpp b/src/Stepper.cpp index 98fbf00..b33e33f 100644 --- a/src/Stepper.cpp +++ b/src/Stepper.cpp @@ -378,7 +378,7 @@ void Stepper::stepMotor(int thisStep) /* * Allow powering down all coils after stepping, - * to reduce heat, power and allow manual rotation. + * to reduce heat, power and allow manuall rotation. */ void Stepper::idelAfterStep(bool idle) { diff --git a/src/Stepper.h b/src/Stepper.h index 0ea8aa8..1ade9f2 100644 --- a/src/Stepper.h +++ b/src/Stepper.h @@ -96,7 +96,7 @@ class Stepper { // mover method: void step(int number_of_steps); - // Power down all coils after stepping, to reduce heat, power and allow manual rotation. + // Power down all coils after stepping, to reduce heat, power and allow manuall rotation. void idelAfterStep(bool idle); int version(void); From 5d5c6b3d7da57687269f2c76cfe9095789f75076 Mon Sep 17 00:00:00 2001 From: fduraibi Date: Sun, 7 Sep 2025 00:07:57 +0300 Subject: [PATCH 5/5] Spelling correction --- src/Stepper.cpp | 2 +- src/Stepper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stepper.cpp b/src/Stepper.cpp index b33e33f..98fbf00 100644 --- a/src/Stepper.cpp +++ b/src/Stepper.cpp @@ -378,7 +378,7 @@ void Stepper::stepMotor(int thisStep) /* * Allow powering down all coils after stepping, - * to reduce heat, power and allow manuall rotation. + * to reduce heat, power and allow manual rotation. */ void Stepper::idelAfterStep(bool idle) { diff --git a/src/Stepper.h b/src/Stepper.h index 1ade9f2..0ea8aa8 100644 --- a/src/Stepper.h +++ b/src/Stepper.h @@ -96,7 +96,7 @@ class Stepper { // mover method: void step(int number_of_steps); - // Power down all coils after stepping, to reduce heat, power and allow manuall rotation. + // Power down all coils after stepping, to reduce heat, power and allow manual rotation. void idelAfterStep(bool idle); int version(void);