AccelStepper + Type DRIVER + Microstepping

Hi,

When looking at AccelStepper source code, there seems to be no support for microstepping with type DRIVER. Common drivers (A4988, DRV8825) support microstepping with simple pin combination. I have no problem controlling the pins separately but I am afraid the whole speed/position/etc infrastructure of AccelStepper will be incorrect with microstepping.

Please has anyone any experience with this?

I will need Firmata interface - the protocol already supports different step size stepper configuration message in protocol/accelStepperFirmata.md at master · firmata/protocol · GitHub . Unfortunately the current AccelStepperFirmata ignores this information for the DRIVER type ConfigurableFirmata/AccelStepperFirmata.cpp at master · firmata/ConfigurableFirmata · GitHub because there is no support in AccelStepper.

Thanks a lot for any suggestions.

Best regards,

Pavel.

If you select microstepping with the settings on the driver then just adjust the numbers of steps and the step rate in the inputs to the library.

Be aware that the Accelstepper library is not capable of the very high step rates that may be desirable if a high degree of microstepping is chosen.

I believe others have achieved high step rates with the examples in this Simple Stepper Code. You may also be interested in this simple acceleration code

...R

Robin, thanks a lot.

Robin2:
If you select microstepping with the settings on the driver then just adjust the numbers of steps and the step rate in the inputs to the library.

I will have to select microstepping outside of the library - directly by the controller pins. The different numbers will then ruin the accumulated sums (especially current position) which is a bit pitty. But I can keep the position in my application, outside the library.

Be aware that the Accelstepper library is not capable of the very high step rates that may be desirable if a high degree of microstepping is chosen.

Fortunately I do not have a problem with speed in microstepping. My use case (turning multi-turn potentiometer while measuring output level) involves control feedback - I need to move first fast with no microstepping to some approximate precalculated position and fine-tune the position with microsteps based on feedback data.

I will try the existing solution by using the library only for commands, without reading current position which I will maintain separately. Thanks a lot!

phofman:
Robin, thanks a lot.
I will have to select microstepping outside of the library - directly by the controller pins. The different numbers will then ruin the accumulated sums (especially current position) which is a bit pitty.

I understand the problem, but I suspect it would not be so easy to solve. Suppose the motor has moved 873 steps at 4x microstepping and you now change to single stepping - where do you assume the motor to be?

Maybe you could tell AccelStepper to zero the position before you change the step rate?

Also, keep in mind that the AccelStepper library was never meant to encompass every stepper control issue.

...R

Robin2:
I understand the problem, but I suspect it would not be so easy to solve. Suppose the motor has moved 873 steps at 4x microstepping and you now change to single stepping - where do you assume the motor to be?

I would assume the answer be 873/4 steps = 218.25 - there are floating-point representations available, firmata uses one protocol/accelStepperFirmata.md at master · firmata/protocol · GitHub. Or two values - integer part in int and remaining 1/32s in byte. If no microsteps were used, the remainder would be ignored by the calling code.

Upon changing the microstep, the sum (current position) would accumulate in the new rate.

Also, keep in mind that the AccelStepper library was never meant to encompass every stepper control issue.

I understand that, nevertheless today very cheap microstepping controller boards (1USD) are available which was not the case a few years ago when the library was developped. IMO these controllers are much more convenient than H-bridge switches directly controlled by arduino since apart of microstepping the modern controllers offer current control, protection etc. Cost is basically same as H-bridges.

I know the proper solution is sending a patch :slight_smile:

phofman:
I know the proper solution is sending a patch :slight_smile:

Indeed - that is the beauty of Open Source code.

Or just create a library that fulfils your needs and publish that.

Either way, make sure to provide good documentation.

...R