gin66 / FastAccelStepper

A high speed stepper library for Atmega 168/328p (nano), Atmega32u4, Atmega 2560, ESP32, ESP32S2, ESP32S3, ESP32C3 and Atmel SAM Due
MIT License
282 stars 67 forks source link

Rotate a fixed number of times #242

Closed moebassist closed 2 months ago

moebassist commented 3 months ago

Hi,

Great library!

I’ve managed to spin my motor very quickly, in either direction. Acceleration/deceleration works great too. I can also determine the number of turns by dividing the current position by my steps/revolutions.

However, I haven’t worked out how to spin the motor a fixed number of turns….e.g.;

  1. Accelerate to speed.
  2. Turn xxx times
  3. Decelerate when approaching xxx turns and stop upon reaching.

Any hints?

thanks!

petmakris commented 3 months ago

For (2) You will use the methods

int8_t move(int32_t move, bool blocking = false);
int8_t moveTo(int32_t position, bool blocking = false);

the argument move is in number of steps and position is an absolute position. To rotate the motor for say 5 rotations, you need to know you microstepping setting. Assuming 400 steps per revolution you would call move(5 * 400, false)

It's all there in FastAccelStepper.h

gin66 commented 2 months ago

stale