Stepper motor control

Thread Starter

JosiahDD

Joined Dec 14, 2011
3
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.
 

mcgyvr

Joined Oct 15, 2009
5,394
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?
 

Thread Starter

JosiahDD

Joined Dec 14, 2011
3
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.
 

mcgyvr

Joined Oct 15, 2009
5,394
Yes, I would like to have 2 fixed positions instead of just using directional control.
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.
 

Thread Starter

JosiahDD

Joined Dec 14, 2011
3
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.
 

mcgyvr

Joined Oct 15, 2009
5,394
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.
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:

hgmjr

Joined Jan 28, 2005
9,027
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
 

Potato Pudding

Joined Jun 11, 2010
688
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.
 
Top