cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling servo with potentiometer

sangarius
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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
Up vote any posts that you find helpful, it shows what's working..

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?

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
Up vote any posts that you find helpful, it shows what's working..