Stepper driver reset enable sleep

Discussion in 'Embedded Systems and Microcontrollers' started by SPQR, Nov 13, 2011.

  1. SPQR

    Thread Starter Member

    Nov 4, 2011
    Hello to all, and "Newbie Alert":)

    First I wanted to thank those who established this forum, and those who continue to contribute their expertise to answering questions for those less knowledgeable.

    In the days of the dinosaurs (Imsai, Bill Godbout 64K memory boards, and Mike Quinn Electronics at the Oakland Airport - but you are all too young to be familiar with that history:)) I was an electronic hobbyist, but fell away from it until a few months ago - I've missed it greatly and am having a blast.

    I'm building a lame project using two stepper motors that will make the Travelocity Gnome pop up above a fence, look around and then hide again.
    I've puchased quite a few steppers to play with, and am using three stepper drivers to learn from (Easydriver, Big Easy Driver and the Interinar BSD-02). The hookup and programming (Arduino) of power, motor, ground, step and direction were pretty straight forward.

    After playing for a while, I noted that the stepper motor and the driver chip would get quite hot (up to 120° with an IR laser thermometer), and thought that if I used a relay on the power to the driver, it might help, and it clearly did.

    But then...I noted a little connection called "Enable" on all three drivers, and my world changed!:D
    I don't need the relay anymore! Hooray!

    But now I'm stuck - there are two other connections I'd like to become expert on, but am unclear regarding their relative utility - Reset and Sleep.

    The relevant chips are the Allegro 3967, 4983 and 3979.

    My questions for those kind experts are:

    1. What is the purpose of "Reset" if there is nothing really "stored" on the chip? I suppose it could reset the M1, M2, M3 controllers, but not much else.

    2. What is the difference between "sleep" and "enable"? When should I use one over the other?

    I thank you very kindly in advance.

    Mod note: I searched the forums and couldn't find any other question close to this. And if this is the wrong forum, please let me know. Thanks
    Last edited: Nov 13, 2011
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    I'd say it's a toss up over this forum or general chat

    A schematic or sketch would make your description much easier to follow.

    And just who you sayin' don't know nuthin' 'bout no S-100 bus hardware?

    Welcome to the Forums :D
  3. SPQR

    Thread Starter Member

    Nov 4, 2011
    Thank you for your kind answer.
    There is no real "schematic" but I think if I show the EasyDriver and some info from the A3967 spec sheet, it might help.
    HERE is a link to a picture of the EasyDriver at the bottom of the page.
    The upper left hand corner are the four pins that go to the stepper. (straight-forward)
    Then the upper middle is PDF input (not relevant to me) and RESET (the line in question).
    Upper right of midline is Enable (turn off and on) and MS2 (for microstepping).
    Right corner is Power (straight-forward).
    Lower left is Power Out (straight-forward).
    Bottom middle - SLEEP (line in question) and MS1 (for microstepping).
    Lower right is GND, STEP, DIR (straight foward).

    So I hook all the lines up appropriately and the program does this (pseudocode).
    #define all the pins
    declare constant names and values
    void setup ()
    ---assign all the pins as OUTPUT.
    void loop ()
    ---set RESET pin low and then high (reseting what? only the M1, M2 pins?)
    ---set ENABLE pin LOW (turn everything on so I don't have to use a relay)
    ---set M1, M2 to the microstepping that I want
    ---do a bunch of stuff with the stepper
    ---set ENABLE pin HIGH (turn everything off so it doesn't overheat)
    ---delay for time X (seconds, minutes, hours, days)
    ---go back to the top and do it all over again.

    From THIS datasheet we have:

    Reset Input (RESET).
    The RESET input (active low) sets the translator to a predefined home state (see figures for home state conditions) and turns off all of the outputs. STEP inputs are ignored until the RESET input goes high.

    Enable Input (ENABLE).
    This active-low input enables all of the outputs. When logic high the outputs are disabled. Inputs to the translator (STEP, DIRECTION, MS1, MS2) are all active independent of the ENABLE input state.

    Sleep Mode (SLEEP).
    An active-low control input used to minimize power consumption when not in use. This disables much of the internal circuitry including the outputs. A logic high allows normal operation and startup of the device in the home position.

    So I'll use RESET because it's easy, and would return the chip to a baseline state.
    I use ENABLE so I don't burn my finger when I touch the IC or motor.:)
    But SLEEP seems to be very close to ENABLE/disable - and I'm not exactly sure why I would use one over the other.
    Based on comparison of the text in bold (my additions), perhaps I should be using "SLEEP" instead of "ENABLE" - or perhaps both?

    Again, thanks very much!:)
  4. Feign

    Active Member

    Mar 30, 2009
    #1 Reset, also resets the decay modes to mixed. these are on-board logic also
    I couldn't find the reset table they were referring to either, no worry.

    #2a Power consumption, sleeping is 20 uA and brain dead, enabled is 50 mA and active, idling disabled is 9 mA
    #2b Sleep during long delays, wake up time is 1ms. Disable when the load doesn't need the holding power.

    So the gnome driver would be sleeping when he is hiding. And the drivers disabled when not needed, at say mechanical stop points.

    No need to reset in the loop that is setup's domain. The micro step logic is always active, unless SLEEP. Anytime the drivers are active and not holding or moving something it's just making heat. You can make some of that go away with some code tweaking.
    Heat and substantial amounts will be made from these devices. Need a large heat sink, or overkill sized drivers.

    EasyDriver has an adjustable current limiter, and you have the ENABLE pin to adjust duty cycle on the software side. The datasheet says 30v and 750 ma, but they don't give the duty cycle. The datasheet from allegro has the power curve table on page two. They recommend at most 2watts and 85 Celsius, both phases not per phase.

    2w/12v = 0.166A, the min setting for the EasyDriver is 150mA per phase, So bare chip at 25° about a 50% duty cycle on 12volts.

    Going to a 6 volt gnome will yield smother movement, and holding power. If he is a snow gnome, heat might not be as much an issue in his natural habitat.
  5. Feign

    Active Member

    Mar 30, 2009
    Of course I failed to mention that isn't the actual heat build up in the chip, thats 100% loss straight to heat. Just a scenario where I don't expect it to fail, with a good heat sink.
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    The Easy Driver page also has an interesting Q&A about heat:

    Q) Why does EasyDriver get so hot?
    A) PWM current limiting drivers (so-called 'chopper' drivers) are turning the coil currents on and off very rapidly. This makes sure that the maximum amount of current (as set by R16, the current set pot) is _always_ flowing through the coils of the stepper motor, even if it is not moving at all. That's just how these things work. It means that the driver is constantly passing that much current through, and because its internal resistance is not zero, it dissipates some heat. If you turn R16 all the way up so that 750mA flows through each coil, the entire EasyDriver board will get hot to the touch. I've never burned my finger on it, but it certainly gets hot. (At the minimum - about 150mA/coil - it only gets barely warm.) You can put a small fan blowing across the board if you want to. But fear not, the driver chip has a thermal cut out at 165 degrees C, so it will protect itself. The boards have quite a bit of copper pour on them, to maximize heat dissipation, which helps a lot. Also the voltage regulator gets quite hot - this is because the driver chip needs 70mA at 5V for its logic supply. Depending upon what voltage you use into the M+ pin, the voltage regulator needs to drop that down to 5V (and throw the rest away as heat). So the higher the M+ voltage, the hotter that regulator will get.
  7. SPQR

    Thread Starter Member

    Nov 4, 2011
    Excellent discussion! I thank you both very much.

    Your comments have led me to do a few things that I think will help other newbies if they happen to see this thread.

    1. I've moved the RESET statements (LOW, then HIGH) to the setup () portion of the code since you don't need to reset for every loop.
    Also, I think the use of the RESET statement has gotten me out of a few inexplicable problems I had in terms of microstepping.

    2. I have no formal background in electronics, so I'm left in the wide open spaces of empiricism, and so I "empiricized" a bit.:)

    2a - setup - Arduino Uno, EasyDriver and Mercury stepper. I connected and coded for both SLEEP and ENABLE.
    LOW___HIGH - no motor motion, turns easily during rest period
    HIGH___HIGH - no motor motion, turns easily during rest period
    LOW___HIGH - motion, hard to turn during rest period
    HIGH___LOW - no motor motion, turns easily during rest period
    LOW___X - motion, hard to turn during rest period
    HIGH___X - no motor motion, turns easily during rest period
    X______LOW - No motor motion, turns easily during rest period
    X______HIGH - motion, hard to turn during rest period
    X = wire not connected to the driver

    2b - On average, when SLEEP was used the chip ran about 2-3 degrees hotter than when ENABLE was used.

    2c - the drop in temperature curve during a "rest" period was quicker with ENABLE than with SLEEP

    So I guess my learning points for this particular project were:
    a - use as many of the leads on the driver board as you can/need, you can easily change programming to suit your needs.
    b - use ENABLE over SLEEP
    c - don't worry about temperature too much (but I do, I'm neurotic!:D)
    d - do a RESET in setup () before your loop ()

    Again, I thank you for your help.
    And further comments would certainly be appreciated.
    Last edited: Nov 14, 2011
  8. Feign

    Active Member

    Mar 30, 2009
    External components can also be used to move the heat around, however I don't remember all the specifics.

    An external resistor for the phases, does "something" to the torque/speed curve(?) and makes the motor and resistor heat.

    An external L-C can remove heat from a motor.
  9. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    "Reset" sets the internal state of the IC to the initial microstep (ustep 0). So it effectively 'resets" the internal RAM that remembers what ustep the IC is currently on.

    For your "pop up gnome" application (how often does someone get to say that? ;)) I would suggest using a limit switch etc and a system that detects the limit switch and then turns the stepper motor accordingly. In that case the "Reset" signal is not needed as you will manually detect the motor position with your controlling micro.
  10. SPQR

    Thread Starter Member

    Nov 4, 2011
    Excellent suggestions!

    "Pop up gnome" ! Say that fast five times! :D

    Since I'm in a learning stage, I was thinking about getting a stepper with a built-in encoder so I could learn how to interface it.
    But I've decided on "limit switches" that can feed back the vertical and rotational position of the gnome (I'm also working on a camera slider for a friend, and so I'll need limit switches there too).

    This way I can have him pop up to "eye level", "chin level", "waist level" and "total body level", then randomize those so every "pop up" seems different.:)

    I've got those microswitches with rollers on them, but I'm thinking about using magnets with reed switches.

    Does "reset" always set the controller to factory settings, or just the most recent setting?
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    "Reset" as implemented on all the modern stepper driver chips I have worked with sets the internal ustep controller back to ustep0, the same ustep it has when first switched on.
  12. SPQR

    Thread Starter Member

    Nov 4, 2011
    Excellent! Thanks very much for the info!

    PS - I love your web pages - very nice.
  13. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    You're welcome.
    And thank you! :)