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.
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.
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.