cancel
Showing results for 
Search instead for 
Did you mean: 

Corrrect way to update frequency (ARR) to generate step pulse for stepper motor using stepper driver drv8711 and stm32 micro controller.

steja
Associate II

Hello,

I am Sai hope you are doing well

I am facing some issues with the timers .

I am using stm32f4,f7 micro controller to pulse step input of stepper motor driver. I have configured my timer using HAL layer. i want sweep the frequency from 100hz to say 200khz at the rate of few milliseconds(12ms) .

In my application peripherals are configured as tim3 as base timer and tim1 as output compare toggle mode(using it for step pulse) and at every timer 3 update event i am updating the period of timer1 in order to change the frequency(without knowing weather update event of tim1 occurred or not ). Everything is working as expected but most of the time my motor takes jerks i am assuming that multiple times updation of tim1 period creating some glitches in step pulse . I dont have any way to confirm.

If i generate step pulse using GPIO in output mode then motor is accelerating smoothly without any **** but same thing i want to do using timer.

Is it feasible to update the timer ARR value frequently.

I have refereed to Cross timer and general purpose time cookbook application notes but didnt got correct way to achieve this task efficiently.

thanks all

1 ACCEPTED SOLUTION

Accepted Solutions
berendi
Principal

I think that you are missing the ARR preload feature, enable it by

TIM1->CR1|=TIM_CR1_ARPE;

this way, the ARR register update will be delayed to occur at the next counter overflow. See the timing diagrams with and without ARPE in the timer feature description/counter modes chapter in the reference manual.

View solution in original post

3 REPLIES 3
berendi
Principal

I think that you are missing the ARR preload feature, enable it by

TIM1->CR1|=TIM_CR1_ARPE;

this way, the ARR register update will be delayed to occur at the next counter overflow. See the timing diagrams with and without ARPE in the timer feature description/counter modes chapter in the reference manual.

T J
Lead

You can use the PWM_timer "overflow bit" to trigger the DMA to update the ARR from a circular buffer table.

Piranha
Chief II

You can use one timer as a master step pulse generator and another timer as a slave microstep counter with a "period" of full step. Then in slave driver's update interrupt modify the master driver's period after each full step.