2023-12-03 11:30 AM
Hi, I encountered a problem while trying to control servo motor(SG90) with my custom STM32G030C8T6 board. Servo is not moving at all and only buzzing quietly. I am supplying servo from 5V, board and servo have same GND. I checked servo power supply with potentiometer and voltage seems good. I designed power supply to be able to work with 3A so it should not be a problem either. At first I thought there was a problem with frequency of generated PWM signal (servo is working with 50Hz) but I cannot see any mistake in calculations. APB freq is set to 16MHz. I've tried many combinations of prescaler and ARR values (16-1 prescaler and 20000-1 ARR for example) none of it worked. I have tried with other servos and every try failed. I would be very grateful if someone has any ideas how to deal with this problem.
Solved! Go to Solution.
2023-12-08 12:49 PM
Hi I know where the problem came from. I used too long wires for connecting power supply to my board and after shortening it everything seems to work properly.
2023-12-03 11:54 AM
Math seems okay. Can you view it on a scope or logic analyzer? It could be that the polarity is wrong. Try it with a compare value of 19000/18500.
2023-12-03 12:03 PM
Get a scope on it
Print out the CPU/AHB/APB clocks that it think's it's running from it's perspective.
2023-12-04 09:11 AM
I have tried values 18500/19000 to check if there is reversed polarity but it didnt work. Also tried to watch outputs from HAL_RCC_GetSysClockFreq(), HAL_RCC_GetHCLKFreq() and HAL_RCC_GetPCLK1Freq() functions via live expressions watching in debugger and values seems to be ok. I found topic on other chat that in my STM32 model problem with timers 16 and 17 have been found but changed to tim3 and problem still occurs. Tomorrow I will use scope and update topic.
2023-12-08 12:49 PM
Hi I know where the problem came from. I used too long wires for connecting power supply to my board and after shortening it everything seems to work properly.