arduino-libraries / Stepper

Stepper Library for Arduino
http://arduino.cc/
101 stars 113 forks source link

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

Open BiggRanger opened 6 years ago

BiggRanger commented 6 years ago

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
maehw commented 5 years ago

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 commented 4 years ago

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 commented 3 years ago

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.