Skip to main content
Associate
March 21, 2024
Solved

Controlling Servo motors with Timers problem

  • March 21, 2024
  • 1 reply
  • 6016 views

I set the parameter of TIM5 of my MCU on CubeMX,the frequency of the clock is 72 MHz,PSC is 7199,ARR is 199,the information about my settings is below:屏幕截图 2024-03-21 183646.png屏幕截图 2024-03-21 183735.png

TIM5 is used to output 4  channels of PWM to control four SG90 servos,TIM1 toTIM4 is used to control four Ultrasonic ranging module,I use this sentence to initialize four servos:屏幕截图 2024-03-21 184516.png

I think these servos should turn to 0 degree,but in fact it turn to 90 degrees and stuck there,I don't know the reason why it happened.I hope someone can heip me solve this problem,it has been made me confused for several days 

This topic has been closed for replies.
Best answer by mƎALLEm

Attached an example (in draft) of a servomotor controlled by NUCLEO-F401RE board.

Hope it can help you.

 

 

1 reply

mƎALLEm
Technical Moderator
March 21, 2024

Hello,

Check if your PWM timings fit the servo requirements:

SofLit_0-1711021953109.png

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
WINNERAuthor
Associate
March 21, 2024

PWM frequency=(ARR+1)*(PSC+1)/72MHz=0.2s=20ms,

if I want to make four sevros turn to 0 degree,I should give it a high level for 0.5ms,so

0.5/20*200=5, I think my PWM setting is okay.Can you provide me another suggestion?Thank you very much!!

mƎALLEm
mƎALLEmBest answer
Technical Moderator
March 21, 2024

Attached an example (in draft) of a servomotor controlled by NUCLEO-F401RE board.

Hope it can help you.

 

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."