Go Down

Topic: Stepper library - suggestion for improvement (Read 123 times) previous topic - next topic

maehw

Hey there,

I don't know if this is the right way to suggest an improvement for an Arduino library. Let's try it any way.

We've used the Stepper library today - but we've also had a problem with it.

We're using it in a battery-powered application with a "4 control wires" stepper motor. We've seen that the stepper motor consumes a lot of power. Interestingly more power, when in idle mode (not moving) compared to when set in motion with the step() method.

We've added a new method in the Stepper class, so that no current is drawn in idle mode:

Add the following code to Stepper.cpp:
Code: [Select]
/*
 * Set the motor to idle state (no power consumption).
 */
void Stepper::setIdle(void)
{
    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);
        }
    }
}



Do not forget to add the prototype of the public method in the header file:
Code: [Select]
void setIdle(void);

Cheers

pert

A pull request for something similar was submitted some time ago:
https://github.com/arduino-libraries/Stepper/pull/11
but it has not been merged.

maehw

A pull request for something similar was submitted some time ago:
https://github.com/arduino-libraries/Stepper/pull/11
but it has not been merged.
Thank you, pert.
I didn't find the repository itself, nor was I sure there was one.
Is there a guideline how merge requests are generally handled?

Cheers

pert

I'm not sure what you're asking. Do you mean a guideline on how Arduino specifically handles merge requests, or just general GitHub guidelines?

maehw

I'm not sure what you're asking. Do you mean a guideline on how Arduino specifically handles merge requests, or just general GitHub guidelines?
Yes, a guideline on how Arduino typically handles merge requests.

pert

This probably has the best information:
https://github.com/per1234/Arduino/blob/improve-contribution-guidelines/CONTRIBUTING.md
Let me know if you have any specific questions or suggestions for improvement after reading that.

Go Up