tyhenry / CheapStepper

Arduino library for the cheap but decent 28BYJ-48 5v stepper motor with ULN2003 board
GNU General Public License v3.0
122 stars 46 forks source link

After any move the stepper remains in a high current state #19

Open drp0 opened 4 years ago

drp0 commented 4 years ago

My stepper draws 200mA when moving and 370mA when the move has completed. It would be useful to have an idle call which sets the stepper control lines to zero:

This works: void idle(); // drp CheapStepper.h

void CheapStepper::idle(){
      seq(8);      // drp CheapStepper.cpp
}

This utilises the default case in switch(seqNum) of void CheapStepper::seq (int seqNum)

If the function is called on the completion of a move, the current drops to 30mA ! The next move appears un-affected.

stepper.run();
  if (stepper.getStepsLeft() == 0){
  // if the current move is done...
  stepper.idle(); // low current

David

mrv96 commented 4 years ago

Hi, your method idle is already present in the code:

`void CheapStepper::off() {
    for (int p=0; p<4; p++)
        digitalWrite(pins[p], 0);
}`

Consider also the fact that if you power off all coils, your motor will loose retention torque.

drp0 commented 4 years ago

Hi, off() looks like the same idea- does it affect any other parts of the library?

I had considered the loss of torque. However in some applications battery demand in static positioning outways the need to apply torque to a stationary motor.

mrv96 commented 4 years ago

off() is already part of the master official library, it's sufficient to call it.

Since it has been already included, i suppose that it doesn't affect any other parts of the library