TIMER PWM mode driving stepper motor how to soft start or acceleration time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-12 2:14 AM
i am driving STEPPER MOTOR using TIMER in PWM mode use interrupt for counting PULSES
now how can i accelerate motor slowly(acceleration time 200ms) then running at set speed?
acceleration time(ex 200ms) is variable how can i do it? Can iuse dma for very frequency?
- Labels:
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-12 5:37 PM
- Set output channel to PWM mode 1 and set CCR for an active pulse width.
- Set timer to a downcounting mode and do not enable ARR preload.
- Use update interrupt to count full steps and adjust speed by modifying ARR.
- Use repetition counter for micro-steps, if necessary.
- At initialization and after stopping the counter, set the CNT to a value of CCR + 1 so that output is inactive and, when starting, timer doesn't have to do useless downcounting before the first pulse.
ARR period can be recalculated as follows:
nPeriod = (nPeriod * 15) / 16; // Acceleration
nPeriod = (nPeriod * 21) / 16; // Deceleration
Of course you have to replace the ratio constants with your specific ones. Just take a note that the divider is recommended to be a power of 2, as that will be optimized to a simple and fast bit shift instruction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-16 8:51 PM
what is 15 & 21 in nPeriod equation?
nPeriod value 16bit ? it is full pulse value ON+OFF time (50% duty)?
