Controlling Servo motors with Timers problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 3:52 AM - last edited on 2024-03-21 4:53 AM by mƎALLEm
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:
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:
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
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 5:15 AM
Attached an example (in draft) of a servomotor controlled by NUCLEO-F401RE board.
Hope it can help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 4:53 AM
Hello,
Check if your PWM timings fit the servo requirements:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 5:06 AM
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 5:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-03-21 5:35 AM - edited 2024-03-21 5:48 AM
