Question
Servo Motor Frequency and Duty Cycle Problems stm32f407
Posted on October 14, 2013 at 12:47
Hi,
I am trying to drive a servo motor(for this case, TowerPro MG90S), so I want to get 50 hz frequency and duty cycle between %5 and %10. My board is STM32F407 Discovery. I tried to change Peripheral Lib example a little bit. It says that APB1 frequency has prescaler other than 1, so it will be multiplied by 2. As I calculated, timer3 frequency has to be 84 Mhz in this case. Afterwards, I am setting prescaler value as 42-1=41 and ARR = 4000-1=3999. The result is, servo is not driven. When I change prescaler as 84-1=83, it is working. So, Is Timer3clk 168Mhz? How can it be possible? TIM_TimeBaseStructure.TIM_Period = 3999; TIM_TimeBaseStructure.TIM_Prescaler = 83; In the statuation that prescaler is 83 and ARR is 3999, the motor is driven. I assigned CCR values from 200 to 400. Here is another problem due to motor is turning about 90 degrees. When I changed it from about 150 to about 500, it is turning about 180 degrees. Firstly I am tried to arrange duty cycle between %5 and %10, secondly I found this numbers after a lot of attemptions. I couldn't understand how it is working, can you help me to understand these? Thanks for your time. #stm32 #timer #pwm #discovery #output