Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added idle() method to power down a motor to save energy or allow manual rotation of motor #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BiggRanger
Copy link

I've added an idle() method to power down the stepper motor pins in order to save energy or in my case allow a motor with a hand wheel to be manually operated. The only risk is if someone is keeping track of position by counting steps, while the motor is idle the motor may change position.

Stepper myStepper(2048, 5, 3, 4, 2);
myStepper.setSpeed(15);
myStepper.step(50);

myStepper.idle();   //Power down stepper
delay(5000);

myStepper.step(50); //step another 50 steps

BiggRanger added 3 commits April 29, 2018 12:52
The idle method will power down the stepper motor pins to either save power or allow the motor to be manually rotated.
Added an idle() method to power down the stepper motor. This is useful for power savings, or if the motor needs to be manually rotated.
@@ -14,6 +14,7 @@ Stepper KEYWORD1 Stepper

step KEYWORD2
setSpeed KEYWORD2
idle KEYWORD2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use a true tab separator between the keyword and identifier, not spaces.

@@ -1,5 +1,5 @@
/*
* Stepper.cpp - Stepper library for Wiring/Arduino - Version 1.1.0
* Stepper.cpp - Stepper library for Wiring/Arduino - Version 1.1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version is actually already at 1.1.3. A non-breaking API change should bump the minor version so the next release would be 1.2.0. But I think it's best to let Arduino handle the versioning since you don't necessarily want a version bump for every commit, only every release.

@@ -8,6 +8,7 @@
* High-speed stepping mod by Eugene Kozlenko
* Timer rollover fix by Eugene Kozlenko
* Five phase five wire (1.1.0) by Ryan Orendorff
* add idle method (1.1.1) by Darren Clark
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

@@ -8,6 +8,7 @@
* High-speed stepping mod by Eugene Kozlenko
* Timer rollover fix by Eugene Kozlenko
* Five phase five wire (1.1.0) by Ryan Orendorff
* add idle method (1.1.1) by Darren Clark
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

/*
version() returns the version of the library:
*/
int Stepper::version(void)
{
return 5;
return 6;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding version.

@maehw
Copy link

maehw commented Nov 4, 2018

Hi, I had the same issue, as can bee seen here in the forum.

However, I'd use a more compact code in the method itself:

{
    digitalWrite(motor_pin_1, LOW);
    digitalWrite(motor_pin_2, LOW);
    if (this->pin_count >= 4) {
        digitalWrite(motor_pin_3, LOW);
        digitalWrite(motor_pin_4, LOW);
        if (this->pin_count == 5) {
            digitalWrite(motor_pin_5, LOW);
        }
    }
}

@goldcove
Copy link

I second this commit.
I would only suggest that idel() is called automatically after each run. Why should the user remember to idle the motor? Common sense dictate that the programmering should not leave the engine in a possible overheating situation.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


BiggRanger seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants