Stepper motor control

Discussion in 'General Electronics Chat' started by JosiahDD, Dec 15, 2011.

  1. JosiahDD

    Thread Starter New Member

    Dec 14, 2011
    3
    0
    Hello everyone,

    I have a project I've been working on using an Arduino Uno, 400 step Stepper motor, Easy Driver v4, joystick and various switches.

    I am trying to be able to position the stepper where I want it using a joystick, then set the steppers position using two different buttons. After the position is set with one button I would like to be able to move the steppers position again so I can use the other button to set another position.

    My end goal is to be able to toggle the steppers position back and forth using the two button that I have preset with the joystick.

    I have some code down but I am not sure how to read the steppers current steps, then set it as a position.

    Thank you for any reply.
     
  2. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,770
    970
    Steppers don't have any feedback (unless you add it via an encoder or other methods) so you don't really know its current position other than where you just told it to go to. Typically you just tell it to turn X amount of steps in 1 direction then back x amount of steps in the other direction or whatever.
    Steppers can also miss steps or get stuck due to mechanical issues/too fast of movements,etc..

    Do you just want 2 fixed positions or something like holding down the one button just causes it to go in one direction until you let go of the button?
     
  3. JosiahDD

    Thread Starter New Member

    Dec 14, 2011
    3
    0
    I looked into different rotary encoders but I wasn't sure if I could drive the stepper while simultaneously using the motor itself as a rotary encoder or not.

    Yes, I would like to have 2 fixed positions instead of just using directional control.
     
  4. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,770
    970
    So you just tell it to go X amount of steps when one button is pressed and go X amount of steps in the opposite direction when the other button is pressed.. Seems pretty simple..
    You could also incorporate limit switches on each end and only stop the stepper movement when the limit switch is triggered. This would ensure you are completing the full movements as designed.

    There really is no need for feedback or over complicating the setup based on the descriptions you have given.
     
  5. JosiahDD

    Thread Starter New Member

    Dec 14, 2011
    3
    0
    I was thinking about attaching an Absolute Binary Rotary Encoder to the motors drive shaft to be able to get feedback from the motors position. Do you think this might be able to work? the motor will be running at relatively low speeds.
     
  6. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,770
    970
    Sure that would work..
    Sparkfun (probably where you bought the easydriver from) has rotary encoders that will work perfectly with the Arduino and plenty of sample code floating around
    http://www.sparkfun.com/products/9117
     
    Last edited: Dec 15, 2011
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You should be able to forego the need for an encoder by establishing a HOME position using a momentary microswitch. Then you should be able to go to the home position and then use the step commands issued to the stepper motor to get to a repeatable position of the motor.

    hgmjr
     
  8. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    Steppers are very accurate if used properly (not stepped out of sequence or at too high a step frequency or stalled.)

    You can count on them to be where they have been commanded even thousands of steps and dozens of direction changes later.

    I am working with a small CNC mill as part of my portfolio project and even open loop it is working perfectly for purposes like engraving.

    Making it closed loop is part of the plan, but the benefit is mostly because it will be used by classes of future students and needs to be fault tolerant so that it can survive mistakes and abuse.
     
Loading...