DRV8825 Stepper Motor Timer and Clock
Posted: Wed Nov 18, 2020 7:52 pm
by adamelli
The DRV8825 stepper motor driver [1] has a maximum step frequency of 250 kHz.
The ESP32 Dev Board I'm using has 2 MHz to 60 MHz oscillator.
How can this stepper motor driver be controlled by the ESP32?
[1]
https://www.ti.com/lit/ds/symlink/drv8825.pdf#page=7
Re: DRV8825 Stepper Motor Timer and Clock
Posted: Sat Nov 21, 2020 12:16 pm
by mikemoy
Why did you post your question in the "Showcase" section of the forum.
Re: DRV8825 Stepper Motor Timer and Clock
Posted: Sat Nov 21, 2020 3:36 pm
by ESP_Sprite
Good point. Moved to hardware.
Re: DRV8825 Stepper Motor Timer and Clock
Posted: Tue Nov 24, 2020 9:30 pm
by becorey
The clock frequency of the ESP32 is sort of like the maximum frequency you can achieve downstream. It doesn't just automatically mean that everything runs on that frequency.
From the datasheet:
STEP 22 I Rising edge causes the indexer to move one step.
It looks like with this chip, you send pulses to the STEP pin to get the motor to move in steps. So you can setup PWM on a GPIO pin of the ESP32, and connect that GPIO to the STEP pin of the motor driver. With PWM you can define the frequency, it could be 250 kHz or below. Then you can freely adjust that PWM pin to change the stepping speed of the motor.
If you wanted more precise control, moving in a small number of finite steps, you could set up the GPIO pin simply as an output. Then toggle it with pin.value(1), pin.value(0), to send a single pulse to the STEP pin. This is kind of like manual PWM, just one pulse at a time, you lose some control of the duty cycle and frequency but you gain control over the number of pulses. You can do a loop and counter to move a predefined number of steps.