cancel
Showing results for 
Search instead for 
Did you mean: 

one timer for puls output - another timer for counting the pulses - other solution ?

mehmet.karakaya
Associate III
Posted on January 14, 2013 at 14:55

hello forum ,

I am using %50 duty PWM output of one timer

for sending pulses ( position command ) to servo motor

however I need counting the same pulses in order to know

that exact number of pulses have been sent

( think acceleration and deceleration ramps of position command )

so I do count the pulses with another timer every 5 milisecond 

and if the count is less I increase the frequency, if it is more I decrease the frequency of PWM

in the next 5 milisecond ( my scan time )

so far this technic is working 

however I need 4 position command 

and I need 8 timers

the max frequency will be 400 KHz

my question ;

is there another solution to this problem?

I mean only one timer per position command

thank you 

#position-control-timer-stm32f4
1 REPLY 1
Posted on January 14, 2013 at 21:37

This sounds like frequency modulation not pulse-WIDTH modulation.

On the STM32's you can generate a singular frequency per timer (TIM unit), and different channels can have different widths, and you can count pulse via the update interrupt, or slaving a second timer. You can modulate the frequency by changing the ARR at each Update.

For low frequencies you can play a game of advancing the CCR's for multiple channels to get multiple outputs per timer, but as the frequency increases you'll get to a point where the system saturates servicing the interrupts.

Now in terms of tracking pulse counts, you could simply use an internal counter, like the one in the trace unit, and use that time line to compute the cycles on your individual timers, given everything shares a common synchronous clock. Shouldn't be that hard to figure the current cycle count and phase, and keep track of things.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..