cancel
Showing results for 
Search instead for 
Did you mean: 

How to do STEP/DIR interface?

Stastny.Petr
Associate III

Hello,

I need to connect STEP/DIR driver (DRV8825 to STM32F103) for driving one axis stepper motor. I will use buttons for moving and I need to set acceleration and deceleration profile. Do you have some experience what way of pulse generation I shoud use? The maximum frequency I use is 200 kHz. According to my opition there are these ways:

1) using PWM and recalculate frequency each period

2) use timer interrupt to generate pulse and recalculate

Do you have some experience what way is best?

Thank you

3 REPLIES 3

What is the difference between "using PWM" and "use timer interrupt"?

JW

Stastny.Petr
Associate III

In this link, there is TIM in Interrupt mode and PWM mode: http://www.emcu.eu/stm32-basic-timer/

I used same words for principle description...

So it appears that it's toggling a GPIO pin in timer interrupt, versus PWM.

(Rant: I hate how the "mode" word is being used haphazardly for non-distinct features - you can have the timer generating interrupts, AND generating PWM, AND still being in one of its distinct modes, such as upcounting/downcounting/center-aligned.)

Interrupts are costly. You did not tell us which STM32 model are you using and at what clock, but say if you run it at 50MHz and you have 200kHz periodic interrupts, you have some 250 cycles between interrupts. Now with even simply looking code the ISR may easily take 50-100 cycles, so you'd burn a quarter to a half of your computing power there. In short, you don't want to run interrupts fast, you want to employ as much hardware as possible.

So for the output pulses use PWM, for the period recalculation/ramps use interrupts from some other timer at a lower rate.

JW