Stepper acceleration with a potentiometer

finalizing some finishing touches on my power mill project and Im having some issues.

First is rapid moves, for reference im using the accelstepper library.

A potentiometer controls the speed along with buttons for direction, stop, and disable the driver. Also a rapid button that can be pressed to increase to the max speed. My pot speed is 8 to 3000, the rapid is 4000 ( all steps per second)

The issue is around 2500 and higher. Pushing a direction button can stall the motor… mostly when moving right because it takes more torque that direction. These are big steppers Nm34 1699oz so they have the power but not instantaneously.

The same stalling happens with the rapid button… if im below 2500 and rapid is pushed it stalls. If im above, it will work… but going right it stalls sometimes.

Anyone have any ideas on how to implement an acceleration into my potentiometer control and rapid button? Ive trial and errored ideas for this with no luck.

Another issue is my limit switches… sometimes they trip by them selves. Im not using shield wires, should i be?

I attached my code and also here is a link to a video of its action.

Any help is much appreciated and i plan to have this code free to use for anyone when its finished.

MarchXaxis.ino (11.4 KB)

You are using runSpeed() to move your motor and it does not implement acceleration. The run() function applies acceleration but it expects to know the total number of steps to be moved so that it can calculate the acceleration and deceleration.

When you are not applying acceleration the AccelStepper library does not offer much benefit. It is not that difficult to control a stepper motor with your own code and your own acceleration code. See this Simple Stepper Code and this simple acceleration code.

Either way I suggest you write a short program just for testing and learning.

...R

The acceleration should be fixed to what your motor can do. If you have a different load in either direction, you can switch the acceleration before a move. For testing purposes you can use 2 pots, one for left and one for right acceleration. Once you figured out safe values, hard code them into your program.

Eventually the max. speed also depends on the direction?

Which kind of limit switches do you use, how are they connected to the Arduino (circuit diagram), how long are the cables?

Robin2:
You are using runSpeed() to move your motor and it does not implement acceleration. The run() function applies acceleration but it expects to know the total number of steps to be moved so that it can calculate the acceleration and deceleration.

When you are not applying acceleration the AccelStepper library does not offer much benefit. It is not that difficult to control a stepper motor with your own code and your own acceleration code. See this Simple Stepper Code and this simple acceleration code.

Either way I suggest you write a short program just for testing and learning.

...R

That is what i understood, im not running to a specific position.. i need to be able to stop or change direction at anytime. So stepper run wouldnt work

I originally started with the simple stepper, i saw your acceleration code so many times but i couldnt understand how to use it with a potentiometer.

For limit switchs im using basic micro switchs with NC , NO and COM pins. 2 wires each limit switch, one goes to GnD of arduino, other wire goes to a input.

A switch needs a pullup resistor, or you have to make it switch between Gnd and Vcc (3 wires). INPUT_PULLUP enables a pullup resistor, but it may be too high for your cables.

king6fab:
i saw your acceleration code so many times but i couldnt understand how to use it with a potentiometer.

If you want to change the rate of acceleration try using your potentiometer to change the value of the variable numAccelSteps and move this line from setup() into loop()

stepAdjustmentMicros = (slowMicrosBetweenSteps - fastMicrosBetweenSteps) / numAccelSteps;

However I suspect there is no need to change the acceleration rate while the program is running - just the top speed. Of course the acceleration rate in my demo program might not be suitable for your project.

Do some experiments based solely on the code in my demo.

...R