Hi, I have been playing around with the Adafruit stepper example CircuitPython code. I am using a Feather S3 board and a DC Motor + Stepper FeatherWing Add-on.
Is there any way to control the speed of the stepper? I am interested in running it smoothly and slowly. I have been using the time.sleep method but changing the sleep time does not have the effect I am looking for. I think I came across a really slow/smooth running sketch in Arduino/AccelStepper. Is there anything I can try in CircuitPython? Thanks!
Stepper question
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Stepper question
To make a stepper move slowly and smoothly, you need to microstep: controlling the coils so the rotor moves part of the way from one detente to the next.
The roughest version of microstepping is half-stepping: activating coil A, then adding coil be so both A and B are active, then shutting off A so only B is active. The rotor will move to the following positions:
A : at detente A
A+B : halfway between detente A and detente B
B : at detente B
Microstepping just activates the coils with less than 100% current. If coil A has 3x as much current as coil B, the rotor will stop 1/4 of the way from detente A to detente B. Then you can use equal currents to move the rotor halfway between detente A and detente B, then give coil B 3x as much current as coil A so the rotor stops 3/4 of the way from detente A to detente B.
The adafruit_motor module handles all that math for you. You just need to tell it how many positions you want between detentes:
https://docs.circuitpython.org/projects ... .MICROSTEP
Smooth slow motion involves lots of small microsteps at intervals short enough that you don't notice the rotor stopping at each position.
The roughest version of microstepping is half-stepping: activating coil A, then adding coil be so both A and B are active, then shutting off A so only B is active. The rotor will move to the following positions:
A : at detente A
A+B : halfway between detente A and detente B
B : at detente B
Microstepping just activates the coils with less than 100% current. If coil A has 3x as much current as coil B, the rotor will stop 1/4 of the way from detente A to detente B. Then you can use equal currents to move the rotor halfway between detente A and detente B, then give coil B 3x as much current as coil A so the rotor stops 3/4 of the way from detente A to detente B.
The adafruit_motor module handles all that math for you. You just need to tell it how many positions you want between detentes:
https://docs.circuitpython.org/projects ... .MICROSTEP
Smooth slow motion involves lots of small microsteps at intervals short enough that you don't notice the rotor stopping at each position.
- forum_questions_1
- Posts: 111
- Joined: Tue Oct 25, 2022 4:05 pm
Re: Stepper question
Thanks for this good info Mike.
I was looking at the documentation and saw that it might be possible to change the default microsteps from 16 to 8 and also the 100 kHz frequency?
This is a beginner coding question. Where in code would I put "steppers_microsteps=8"? And how would I change the frequency? I'm just interested in how the motor changes with these.
Are these added in the parenthesis when I create the "kit"? Or somewhere else? I currently have kit defined as follows:
kit = MotorKit(i2c=board.I2C())
I was looking at the documentation and saw that it might be possible to change the default microsteps from 16 to 8 and also the 100 kHz frequency?
This is a beginner coding question. Where in code would I put "steppers_microsteps=8"? And how would I change the frequency? I'm just interested in how the motor changes with these.
Are these added in the parenthesis when I create the "kit"? Or somewhere else? I currently have kit defined as follows:
kit = MotorKit(i2c=board.I2C())
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Stepper question
Yep, add the optional parameters when you create the Motorkit object:
(the default PWM frequency is 1.6kHz rather than 100kHz)
Code: Select all
kit = MotorKit( i2c=board.I2C(), stepper_micrrosteps=4, pwm_frequency=1000 )
Please be positive and constructive with your questions and comments.