Stepper motor EasyDriver speed control with potmeter.

Hello,

I know this has previously been prompted. But i couldn't find the right answer.

How do you control the speed of a stepper motor (NEMA 17) with a potmeter?
The stepper motor is actuated with an EasyDriver.

I want control the stepper motor from stationary up to the maximum speed.

Hopefully there is someone who can help me.

-Dominique

Have a look at Stepper Motor Basics and this Simple Stepper Code

The speed of a stepper motor depends on the interval between steps. You can detect the position of a potentiometer with analogRead() and convert the value into a suitable interval.

...R

You have to map the pot voltage input (0..5V) to 0.."Maximum number of steps".

"Maximum number of steps" depends on the microsteppin' mode of the easyDriver and the max speed you want to run your stepper motor.

rpt007:
You have to map the pot voltage input (0..5V) to 0.."Maximum number of steps".

"Maximum number of steps" depends on the microsteppin' mode of the easyDriver and the max speed you want to run your stepper motor.

The analogRead() function will return a value in the range 0-1023, not 0-5.

If the OP wishes to control the speed he needs to relate that value to the interval between steps, not to the number of steps.

...R

@Robin2:

you are right with

  1. the 0..1023 range (I was referring to the measured voltage as a physical value);
  2. I mixed up number of steps with the steps/sec (e.g. using accelstepper lib)

Thanks for the assistance!

I made this code:

int dirpin = 2;            
int steppin = 3;  
int potPin = A1;         
int potValue = 0;

void setup() {
  
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);

}
void loop() {

 potValue = analogRead(potPin) / 8;
       
       
       digitalWrite(dirpin, LOW);
       digitalWrite(steppin, LOW);
       delay(potValue);
       digitalWrite(steppin, HIGH);
}

This code works fine. But he is going really fast from fast to slow. There isn't a big area to control the stepper motor. When I turned the potmeter half you barely see the stepper motor turn.

Is there a way to make the work area bigger?

-Dominique

I think your code adjusts the interval between steps from 0 millisecs to 1023/8 = 127 msecs.

I suspect you are trying to get the motor to move much too fast when the pot reading is towards the zero end. Try adding a fixed 500 msecs - like this

potValue = 500 + analogRead(potPin) / 8;

and see what happens.

Then play around with the fixed value and the divisor.

...R

@Robin2:

it is working better now!