areong / StepperMotor

Call run() once and it will run forever.
1 stars 0 forks source link

Run in wrong direction at the first step. #1

Open areong opened 10 years ago

areong commented 10 years ago

Description

What's wrong

Call run(), the motor rotates in the wrong direction in the first step, then in the right direction in the following steps.

What should it be

Call run(), the motor rotates in the right direction for all steps.

Example

In the example RunningSequence, the steps should be 10 positive steps, 10 negative steps and 100 negative steps. However, the first 20 steps are 1-neg-10-pos-9-neg, or 1-neg-9-pos-1-pos-9-neg. The last 100 steps run correctly by rotate(180) with speed -2.

Possible cause

  1. Timing with delay() has some error at the starting and ending. It might be the cause because timing using TimerManager in rotate() runs correctly.
  2. Behavior of AccelStepper, or motor's physical limit.

    Possible solution

  3. Time with TimerManager, rather than delay().
  4. Run examples of AccelStepper, or use another motor.
areong commented 10 years ago

Actual cause

By running AccelStepper's example, ConstantSpeed, motor runs in the way I observed. The first step runs in wrong direction. So it is AccelStepper's behavior.

Thought

Why rotate() runs correctly while run() does wrong?