Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: vipulan12 on June 17, 2013, 06:17:02 PM

Title: how do servos maintain a certain position?
Post by: vipulan12 on June 17, 2013, 06:17:02 PM
how do servos maintain a certain position?
-what components are used?
-can this be done to all motors?
Title: Re: how do servos maintain a certain position?
Post by: jkerns on June 17, 2013, 06:31:42 PM
There is typically a potentiometer inside that is connected to the output shaft to measure the position and a closed loop controller to maintain the position to the target value which is a function of the width of the pulse received by the servo.

Yes, you can do this with other motors if you add a position sensor of some kind and a closed loop controller.
Title: Re: how do servos maintain a certain position?
Post by: vipulan12 on June 17, 2013, 07:01:03 PM
how does the closed loop controller maintain the motor in one direction?
how does it change the voltage applied to the motor exactly with the width thing(do you mean PWM)?
Title: Re: how do servos maintain a certain position?
Post by: waltr on June 17, 2013, 07:18:56 PM
Have you googled servos, servomotors, closed loop control and then other terms you find when reading.

One problem in trying to give you an answer is that there are a number of different methods to control the position of a geared motor output. So search and read then search and read some more.
Title: Re: how do servos maintain a certain position?
Post by: jwatte on June 18, 2013, 12:07:22 AM
A "servo" is made up of four things:

1) A motor or other actuating device.
2) A sensor of some sort (potentiometer, optical encoder, magnetic field sensor, etc.)
3) Driving circuitry for the motor (typically an H-bridge.)
4) Controlling logic to read 2) and apply output to 3).

Exactly how 4 is done depends on the type and manufacturer of the servo. A pneumatic servo for rock extraction in a mine is different from a battery-powered rudder servo for an RC plane :-)

In general, the servo controller will read the position, and compare to the desired position, and then apply more force to the motor (higher PWM duty cycle) the further away it is from the goal. Look at the Wikipedia entry for "PID controller" for the next step of learning about this.
Title: Re: how do servos maintain a certain position?
Post by: greywanderer012345 on June 20, 2013, 10:55:38 PM
Just in case you're asking the simpler question of "How do I tell a servo to go to a certain position?"
Here's the simple answer:
- Every 20milliseconds, give a ~1-2 millisecond 5V signal pulse to the signal wire.

A little more detail:
- I say "about(~)" 1-2 ms, but the maximum and minimum depends on the servo, and can be found in the specs.
- The length of the pulse determines the target position. 1ms = -180 , 2ms = +180. (from center)
- Yes, this is PWM.
- Yes, you can use PWM that's built-in to your MCU, Yes, you can program your own pulse
- Don't bother trying to get the built-in PWM working with admin's $50 robot design. It's not set up correctly for it.
- ... don't use admin's code for sending the signal either, as it sends the pulse AND sets the delay IN THE MAIN LOOP, so all of your other code is both slowed down, and interferes with the signal timing.