Turning off the stepper

  • Suggestion for the next version of the Stepper library ---

I was testing the Stepper library with the 28BYJ-48 stepper motor and I noticed that the stepper motor still continued with the last coils triggered after the call function, warming them up and consuming power. So I added a function to disconnect the last used coils.

On Windows, the codes are in "C: \ Program Files \ arduino-nightly \ libraries \ Stepper \ src" and you need to change the security of the files.

In stepper.cpp:

  1. Added function below:

void Stepper::turnOff()
{
if (this->pin_count == 2) {
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_1, LOW);
digitalWrite(motor_pin_2, LOW);
digitalWrite(motor_pin_3, LOW);
digitalWrite(motor_pin_4, LOW);
}

  1. I called the function turnOff () as the last command in "void function Stepper :: step (int steps_to_move)" - before the last "close parentheses"

void function Stepper :: step (int steps_to_move)
{
....
turnOff();
}

At Stepper.h:

  1. Added "void Stepper::turnOff();" in private clause;

Genesio:
I was testing the Stepper library with the 28BYJ-48 stepper motor and I noticed that the stepper motor still continued with the last coils triggered after the call function, warming them up and consuming power.

That is the normal behaviour of stepper motors. Keeping the coils powered is essential if the motor is to hold its position and. of course, that make stepper motors very inefficient energy users.

If you de-energize the coils there is a distinct possibility that the motor will jump forward or backwards by one step when power is next applied to the coils. For many applications that position error would be serious.

...R

The normal approach to saving power with steppers is to drop the current by a factor of 2 or so whenever its
stationary. Power dissipation is prop. to the square of current, so this represents a 75% saving in power for
intermittent use.

Due to the much higher torque at low speeds and stationary this current reduction isn't a problem for miss-stepping, which will happen at high speed first.

Unfortunately a lot of the cheap stepper driver modules don't support this power saving mode.