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
283 stars 67 forks source link

info - migrating from ESP32 - FlexyStepper #182

Closed programmeddeath1 closed 1 year ago

programmeddeath1 commented 1 year ago

Hi,

We are trying to migrate to FastAccelStepper from our existing implementation in flexystepper due to some possible jerk issues.

I just want to know quickly if these functions that are currently provided by flexystepper can be replicated as is using FastAccelStepper for ESP32:

The motor is initialized as an array as follows: ESP_FlexyStepper MOTOR[MOTOR_COUNT];

1) isStartedAsService/startAsService - lets you run each motor as a separate service that runs that motor independently using rtos. usage - MOTOR[0].setCurrentPositionAsHomeAndStop(); if (!MOTOR[0].isStartedAsService()) MOTOR[0].startAsService(); MOTOR[0].processMovement(); 2) setSpeedInMillimetersPerSecond - is there a similar function that is in steps/s or mm/s - Which of these would work closest to this fn - (setSpeedInTicks - setSpeedInUs - setSpeedInHz - setSpeedInMilliHz)

3) MOTOR[num].setAccelerationInMillimetersPerSecondPerSecond

4) MOTOR[num].setTargetPositionRelativeInMillimeters

5) setCurrentPositionAsHomeAndStop - This sets current position as home and stores it.

@aaryanmurgunde - FYR

Thank you for your help in advance!

gin66 commented 1 year ago

FastAccelStepper is not a drop in replacement of Flexystepper, so an adjustment will be needed.

The steppers need to be initialized one by one, but this can be done table driven as in StepperDemo. FastAccelStepper only understands steps. Normally the relation between steps and distance is linear, so a multiplication with a factor should be sufficient. This way speed in mm/s converts to steps/s and acceleration in mm/s² to steps/s². And a move to a distance is a move to a step. A similar function exists for setCurrentPositionAsHomeAndStop.

In general it is wise to read the API description and eventually have a look at the examples.