DRV8825 Stepper Motor Timer and Clock

Posts: 1
Joined: Wed Nov 18, 2020 7:45 pm

DRV8825 Stepper Motor Timer and Clock

Postby adamelli » Wed Nov 18, 2020 7:52 pm

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?


Posts: 488
Joined: Fri Jan 12, 2018 9:10 pm

Re: DRV8825 Stepper Motor Timer and Clock

Postby mikemoy » Sat Nov 21, 2020 12:16 pm

Why did you post your question in the "Showcase" section of the forum.

Posts: 4108
Joined: Thu Nov 26, 2015 4:08 am

Re: DRV8825 Stepper Motor Timer and Clock

Postby ESP_Sprite » Sat Nov 21, 2020 3:36 pm

Good point. Moved to hardware.

Posts: 22
Joined: Sat Mar 28, 2020 4:18 pm

Re: DRV8825 Stepper Motor Timer and Clock

Postby becorey » Tue Nov 24, 2020 9:30 pm

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.

Who is online

Users browsing this forum: No registered users and 19 guests