accelstepper not behaiving as in example

To test a motor i wrote a simple sketch according to the included examples.
But it wasn’t working as should be:

#include <AccelStepper.h>                  // http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

int      XAxisDIR          =  12;
int      XAxisPWM          =  10;

AccelStepper stepperX(1, XAxisPWM, XAxisDIR);
int xMotorSpeed            =   0;          // Maximum steps per second
int xMotorAccel            =   1;          // Steps per second for acceleration
i
void setup() {
  // put your setup code here, to run once:
  stepperX.setMaxSpeed(2000);
  stepperX.setAcceleration(25);
}

void loop() {
  // put your main code here, to run repeatedly:
  stepperX.runSpeed();
}

With the following code it works, sort of. It is running for a constand speed but just for the set distance.

#include <AccelStepper.h>                  // http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

int      XAxisDIR          =  12;
int      XAxisPWM          =  10;

AccelStepper stepperX(1, XAxisPWM, XAxisDIR);
int xMotorSpeed            =   0;          // Maximum steps per second
int xMotorAccel            =   1;          // Steps per second for acceleration
i
void setup() {
  // put your setup code here, to run once:
  stepperX.setMaxSpeed(2000);
  stepperX.setAcceleration(25);
  stepperX.moveTo(100000);
}

void loop() {
  // put your main code here, to run repeatedly:
  stepperX.run();
}

Is this normal behaivior or do i am something wrong?

In the first piece of code you are not providing any destination. Stepper motors are intended to move a precise number of steps.

It looks like you are using a stepper driver board that takes step and direction signals. If so this simple stepper code should work and may be easier to understand as it does not use any library.

Note that you do NOT use PWM to control a stepper motor.

...R Stepper Motor Basics

gharryh: To test a motor i wrote a simple sketch according to the included examples. But it wasn't working as should be: With the following code it works, sort of. It is running for a constand speed but just for the set distance.

What it should be doing is ramping up to the set speed at the set acceleration, holding that speed, then ramping down at the same acceleration rate to stationary, covering in total the set number of steps, which is precisely what AccelStepper is designed to do.

Is this normal behaivior or do i am something wrong?

How is this connected and to what? The code looks like its designed for a step+direction stepper driver, but you've named the step pin "PWM" which is worrying.

Sorry for the wrong naming but its a two ;line configuration. If you look at at: this example the first example should work.

gharryh: If you look at at: this example the first example should work.

If the code is correct the problem must lie elsewhere.

Post a link to the datasheet for the motor you are using What stepper driver are you using Make pencil drawing of your wiring diagram and post a photo of it. Provide details of the motor power supply - volts and amps.

...R