Moving a stepper motor by analog voltage signals + smooth acceleratio and decele

I have an arduino mega connected to a v2 shield and a voltage calibrator which i adjust the volts between 0-5. It's connected to an analog pin on the arduino. I can get it to rotate 720 degrees with 1 volt and 1440 with 2 volts etc. I want a smooth change in direction so how can I code it to decelerate before changing dircetions?

Hi, Welcome to the Forum

Can you post the code you have and we can advise from there.

http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

This may help, it is a library for stepper motor that has acceleration control.

http://www.airspayce.com/mikem/arduino/AccelStepper/

Tom... :)

perez244: I can get it to rotate 720 degrees with 1 volt and 1440 with 2 volts etc. I want a smooth change in direction so how can I code it to decelerate before changing dircetions?

Your description lacks detail.

Is this a system in which the stepper responds immediately to a change in control input? OR Is it a system in which a change in the input is followed some time later (how many seconds later?) by the motor moving to a new position?

If it is the latter then the solution probably lies in recording the existing position and comparing it with the new position before deciding what to tell the motor to do.

...R Stepper Motor Basics Simple Stepper Code

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Please answer the questions in Reply #2

Please tell us what the code in Reply #3 actually does and what you want it to do.

…R

perez244: Here's the code properly posted and the motor will respond to the new voltage input read once it has completed it's current assignment( voltage read)

That sounds like you need to determine when the motor has reached its destination and only then check for a new voltage value.

I am not familiar with the stepper library you are using so I can't say whether your existing code is or is not doing that.

When you call myMotor->step(steps, FORWARD, SINGLE); does it complete all the steps before it returns to allow the code to move on the next line? Or does it just move forward one step towards the total?

...R

Hi, Can you post a link to the spec of your stepper please?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :)

The AccelStepper library already handles acceleration and deceleration - at least when no new position is requested before the previous movement has finished.