Motor Shield: Set current of stepper in hold mode

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
finalcu
 
Posts: 4
Joined: Tue Apr 03, 2012 8:30 am

Motor Shield: Set current of stepper in hold mode

Post by finalcu »

Hi,

Is there a way to reduce the current of a stepper in hold mode? I don't want to use motor.release() and i don't need maximum holding torque either. Currently my motor needs 300mA when it runs (SINGLE) but when it holds it consumes 500mA which is too much (the L293D driver gets really hot such that i'm afraid it will break...)

best,
finalcu

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield: Set current of stepper in hold mode

Post by adafruit_support_bill »

There is no support for that in the AF_Motor library. But it should be possible to implement. You would probably need to define another mode ("HOLD"?) and then use the PWM to set the holding current.

In any case, 500mA is a safe level for the L293. Although you could add heat-sinks to dissipate some of that heat: http://forums.adafruit.com/viewtopic.php?f=31&t=26873.

finalcu
 
Posts: 4
Joined: Tue Apr 03, 2012 8:30 am

Re: Motor Shield: Set current of stepper in hold mode

Post by finalcu »

Thanks for the reply. Is 500mA safe even when continuously running for 10 hours without heat sink? It get's so incredibly hot that i can barely touch it. Is that normal?

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield: Set current of stepper in hold mode

Post by adafruit_support_bill »

They are rated for 600mA continuous, and at that level they do get very hot to the touch. As long as there is sufficient air circulation around the chip and the board (the ground-plane is acting as a heat-sink) it should be OK. But you don't have a lot of margin for safety there. Personally, I like to err on the safe side and use a heat-sink.

finalcu
 
Posts: 4
Joined: Tue Apr 03, 2012 8:30 am

Re: Motor Shield: Set current of stepper in hold mode

Post by finalcu »

Ok. I've tried to implement a hold function but since it did not understand the code entirely, i mainly copied the content of the onestep function:

Code: Select all

void AF_Stepper::hold(uint8_t pwm, uint8_t style) {
  uint8_t a, b, c, d;
  uint8_t ocrb, ocra;

  ocra = ocrb = pwm;

  if (steppernum == 1) {
    a = _BV(MOTOR1_A);
    b = _BV(MOTOR2_A);
    c = _BV(MOTOR1_B);
    d = _BV(MOTOR2_B);
  } else if (steppernum == 2) {
    a = _BV(MOTOR3_A);
    b = _BV(MOTOR4_A);
    c = _BV(MOTOR3_B);
    d = _BV(MOTOR4_B);
  } else {
    return;
  }


  if (steppernum == 1) {
    setPWM1(ocra);
    setPWM2(ocrb);
  } else if (steppernum == 2) {
    setPWM3(ocra);
    setPWM4(ocrb);
  }


  // release all
  latch_state &= ~a & ~b & ~c & ~d; // all motor pins to 0

  //Serial.println(step, DEC);
  if (style == MICROSTEP) {
    if ((currentstep >= 0) && (currentstep < MICROSTEPS))
      latch_state |= a | b;
    if ((currentstep >= MICROSTEPS) && (currentstep < MICROSTEPS*2))
      latch_state |= b | c;
    if ((currentstep >= MICROSTEPS*2) && (currentstep < MICROSTEPS*3))
      latch_state |= c | d;
    if ((currentstep >= MICROSTEPS*3) && (currentstep < MICROSTEPS*4))
      latch_state |= d | a;
  } else {
    switch (currentstep/(MICROSTEPS/2)) {
    case 0:
      latch_state |= a; // energize coil 1 only
      break;
    case 1:
      latch_state |= a | b; // energize coil 1+2
      break;
    case 2:
      latch_state |= b; // energize coil 2 only
      break;
    case 3:
      latch_state |= b | c; // energize coil 2+3
      break;
    case 4:
      latch_state |= c; // energize coil 3 only
      break; 
    case 5:
      latch_state |= c | d; // energize coil 3+4
      break;
    case 6:
      latch_state |= d; // energize coil 4 only
      break;
    case 7:
      latch_state |= d | a; // energize coil 1+4
      break;
    }
  }

 
  MC.latch_tx();
  return;
}
it seems to work but the driver still gets very hot and for lower pwm duty cycles the motor starts to sing. I this the proper way to do it?

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield: Set current of stepper in hold mode

Post by adafruit_support_bill »

That looks about right. Do you notice the lower holding torque at lower PWM levels?

finalcu
 
Posts: 4
Joined: Tue Apr 03, 2012 8:30 am

Re: Motor Shield: Set current of stepper in hold mode

Post by finalcu »

Yes, definitely. Although the consumed current (and so the torque) drops way more than proportional to the decrease in duty cycle.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield: Set current of stepper in hold mode

Post by adafruit_support_bill »

You might want to post an issue on the Github repository. Your mod might make a good addition to the library.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”