Skip to main content
sangarius
Associate II
October 23, 2020
Solved

Controlling servo with potentiometer

  • October 23, 2020
  • 3 replies
  • 1338 views

I want to control servo movement with potentiometer. I'm using ADC and getting the pot value. But i don't know how to control the pwm with this value. What should i use?

Thanks in advance.

This topic has been closed for replies.
Best answer by Tesla DeLorean

I don't know, I haven't seen your code. Check the pulse width signal with a scope.

Scaled properly, doing the math in the right order there is no reason one shouldn't be able to have linear motion over the whole range of the servo.

Figure out where the exact physical limits of the servo are with respect to the pulse width (1-2ms) with 1.5ms dead center is a notional range for them, but it might be tighter.

Either look at the technical documentation for the specific servo, or use the scope to determine the upper/lower bounds of motion, and then figure that into your scaling equation so the full scale on the pot relates to fully physical range of the servo.

3 replies

Tesla DeLorean
Guru
October 23, 2020

Set up a TIM in PWM mode, period of 20ms, and have the ADC value translate to a 1 to 2 ms pulse length​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sangarius
sangariusAuthor
Associate II
October 23, 2020

I did the servo movement but there is just 1 issue left. When i start to rotate the pot between 0-1009 value, at 0-150 and 850-1009 ; the servo is not moving. Is it because of the potentiometer or any issue in my codes?

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 23, 2020

I don't know, I haven't seen your code. Check the pulse width signal with a scope.

Scaled properly, doing the math in the right order there is no reason one shouldn't be able to have linear motion over the whole range of the servo.

Figure out where the exact physical limits of the servo are with respect to the pulse width (1-2ms) with 1.5ms dead center is a notional range for them, but it might be tighter.

Either look at the technical documentation for the specific servo, or use the scope to determine the upper/lower bounds of motion, and then figure that into your scaling equation so the full scale on the pot relates to fully physical range of the servo.

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