Accelstepper stepping selection

Hi everyone.
I need your support with Accelstepper lib, please.
Here's my setup: I use Arduino Uno, Chinese driver HYQD80-H8600 and bipolar stepper.
Trying to run tutorial from Accelstepper Constand speed, motor clics quite loud and can be stopped by fingers. Driver set to appropriate current and microstepping is 2 (doesnt have full step option).
Ony thing I've changed in example is declaration - AccelStepper stepper(1, 3, 2);. So to use Driver, Step pin 3, dir pin 2.
If I try another StepperDriver lib, everything work like a charm. But the problem is that I need to control 2 steppers with proportional control, which is supported by Accelstepper lib.
Can someone suggest what am I missing?

If I try another StepperDriver lib, everything work like a charm.

Post the program that works AND the program that does not work. You are probably missing something simple.


Here’s the code that works (again, it’s another library):

#include <Arduino.h>
#include "BasicStepperDriver.h"

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 120

// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 2

// All the wires needed for full functionality
#define DIR 2
#define STEP 3
//Uncomment line to use enable/disable functionality
//#define ENABLE 13

// 2-wire basic config, microstepping is hardwired on the driver
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);

//Uncomment line to use enable/disable functionality
//BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP, ENABLE);

void setup() {
    stepper.begin(RPM, MICROSTEPS);

void loop() {
    // energize coils - the motor will hold position
    // stepper.enable();
     * Moving motor one full revolution using the degree notation

     * Moving motor to original position using steps

    // pause and allow the motor to be moved by hand
    // stepper.disable();


And this one doesn’t (as expected):

#include <AccelStepper.h>

AccelStepper stepper(1,3,2); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

void setup()

void loop()

Ok, if I understand right, speed in Accelstepper lib is actually stepping. So with my driver set to 1/2 step and with motor 1.8deg per step, speed of 400 gives some result. With gearbox on, motor starts to spin now, not just click. But still, most of steps are missing.

Ok, it works with speed of 400. Tried another example with prop. control. and it doesn't work (well, with gearbox on motor). Problem is in stepper.runSpeedToPosition() func. Motor just clicks with it. And continiously rotates with stepper.runSpeed();

Ok, it works with speed of 400.

Before I waste time studying the code in Reply #2 tell me whether you still have a problem, what the latest problem is, and post the latest version of your code.

Have you tried the examples in the AccelStepper library?


All code is from examples.
Yes, problem is still here. Ok, some order in all that chaos I've wrote:) Here's where I'm at now. A bit modded setup: stepper with gearbox, same driver, Arduino Uno. Driver set to 2 microstep (lowest possible).
Accelstepper library example (const. speed, proportional control) works ok (with some jitter thou). The most reliable movement was achieved with speed of 200. But, if while movement, motor behaves normally, when it stops, it starts to jitter. Also, speed of 200 is to low for me, because gearbox (worm gearbox) is 1:100.
Trying example from library written by Laurentiu Badea, BasicStepperDriver, motor spins fast with no jitter even with gearbox.
Again, the reason I want to use Accelstepper is that I need to control 2 steppers simultaneously by 2 pots.

You haven't called setAcceleration() in setup() - you need to tune both maxspeed and max acceleration to
the motor and its load.

try microstepping x8 or x16 if you have resonance issues. An unloaded stepper is the worst case for resonance
as is full stepping.

Again, the reason I want to use Accelstepper is that I need to control 2 steppers simultaneously by 2 pots.

Let’s go back to the very basics.

Describe what you want to achieve. Maybe there is no need to use any library - especially if you just want the motors to get up to some speed and stay at that speed for a long time.

Most stepper libraries are designed for making motors move a specific number of steps and that does not seem to be what you need.

Have a look at these links
Stepper Motor Basics
Simple Stepper Code

and it is not difficult to write your own acceleration code.


Thanks for the links.
Well, as noted before, this is example that came with library. There wasn't any accel setup. Anyway, I've tried it with no luck. Also, I've tried other microstepping setting on driver, but without significant improvement.
Motor does rotate good, but when it stops in certain position, it starts hard jittering.
I do not need acceleration, I just need to control two steppers proportionally with given signal. In real setup I plan to use rc tx/rx. So I map pwm signal to needed amount and use that amount for stepper control. So the main problem it jitter. I've tried filtering suggested in another threads, but it doesnt help nearly at all.
Also, testing Constant speed example from Accelstepper library, the movement is sort of clacky. Don't know how to describe it correctly. While trying Laurentiu Badea BasicStepperDriver example, rotation is clean and constant. And sounds much better.
Motor model is 86HS15560A4, nema34 btw, it's a huge motor. I've tried this setup with much smaller nema17, but with similar results.

I do not need acceleration, I just need to control two steppers proportionally with given signal.

What do you mean by proportionally? Do you mean different speeds or different numbers of steps? what is the maximum range of variation?

What is the input signal?

I would be so much easier to help if you tell us what you are trying to make


Well, I did told:) I'm trying to control 2 steppers with RC controls, in servo style (this is what I mean by proportional).
So I have PWM input. Read it from appropriate channel, map it to desired range, i.e. impulse length 1500-2000 map to 0-400 range (400 steps for my 1.8deg motors with halfstep setting should make full rotation). And trying to use moveTo() func from Accelstepper lib.

If you want a stepper motor to behave like a servo - for example moving half-way when you move the joystick half-way - then I wonder if the AccelStepper library is worth the trouble.

The first complexity I see is the likelihood that the joystick will be moved to a new position before the motor (or servo) gets to its destination. AFAIK the AccelStepper library does not have a convenient mechanism to deal with that. The AccelStepper library is designed for symmetrical acceleration and deceleration from 0 to max and back to zero. If you change the destination before the motor stops, what do you want to happen?

The next complexity is acceleration. Servos have acceleration built into them so you don't have to think about it. You can operate stepper motors without acceleration but they will need to be operated at a slow enough step rate if they are not to miss steps.

Then (though it is not a library issue) there is the complexity of establishing the zero position for a stepper motor. Servos have potentiometers on their output shafts which establish the position. Stepper motors don't and they need to have their zero position established every time the Arduino starts. And if they miss steps during movements they will need to re-establish the zero position.

If you do want to experiment with the AccelStepper library then use one of the non-blocking functions - such as run() - and change the value of moveTo() whenever the joystick position changes. Make sure to call run() in loop() - not inside any other function or IF statement - and call it as often as possible. The code at the bottom of your loop() might be;;


I do not need acceleration

You do need acceleration, always, for a stepper of that size - your stepper driver is 7A and a NEMA34 motor, that's a chunky motor with a lot of inertia, so you must use acceleration or it will stall, guaranteed.

Well, I was inspired by accelstepper proportional tutorial. And totally missed the idea if missing steps. OK, steppers not that good for beeng servos. Thanks for helping me understand that.
Another question. MarkT told,that acceleration is necessary. I've decided not to control stepper angle, but its speed instead. With limiting switches at range ends. So I'm setting speed according to data from tx receiver and it work, but still with sone jitter. As I understand, I need to add acceleration between that speed changes. Imbusing runSpeedToOsition, which doesn't use acceleration. Wat function should I use instead?

Wat function should I use instead?

Read the AccelStepper documentation - don't expect someone else to read it for you.


I usually d

Read the AccelStepper documentation - don’t expect someone else to read it for you.


Of course I did. But only nonblocking func is stepperA.runSpeed(), but MarkT suggested I need acceleration, wich is runToPosition(). And it doesnt work for me.

Of course I did. But only nonblocking func is stepperA.runSpeed(), but MarkT suggested I need acceleration, wich is runToPosition(). And it doesnt work for me.

And what did I suggest in Reply #11 ?

You have not been reading the documentation sufficiently carefully.


PS … saying “it does not work for me” is no help unless you post the code where you tried it and tell us exactly what happened when you tried it.