Shop OBEX P1 Docs P2 Docs Learn Events
SERVO in C code... — Parallax Forums

SERVO in C code...

tank1075tank1075 Posts: 3
edited 2008-03-19 04:13 in Robotics
Hi,

Does anyone has programmed a Servo motor in C?? I'm currently working in a servo and would like to rotate 180 degrees constantly while is on rotating an Ultrasonic sensor.
Also, do you think that using PWM would work as well or does anyone has another suggestion???

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-16 20:16
    Servo motors require a control pulse roughly every 20ms. For many servo motors, this pulse is between 1000us and 2000us in width. For some servos, it may be as much as 500us to 2500us in width and the width of the pulse specifies the servo position with 1500us being approximately center position. How you make this pulse depends entirely on how you generate timed pulses in the C you're using.

    This is not really considered to be PWM although that also involves controlling the width of a periodic pulse.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-03-16 23:21
    The one thing not said was the 1 mSec to 2 mSec pulse width determines the position the Servo moves to.
  • tank1075tank1075 Posts: 3
    edited 2008-03-17 00:55
    Thank you guys, that was helpful, even though we discovered a few hours ago.. Might hit you w/ some other questions later on...

  • tank1075tank1075 Posts: 3
    edited 2008-03-19 00:33
    Hey Guys,
    Here goes another question, any hints on how rotate the servo motor to a full 180 degrees motion???? We've been trying to do so following some of the hints you gave us, but for some reason, the most we rotate is 120 degrees... Any clues??
  • FranklinFranklin Posts: 4,747
    edited 2008-03-19 04:13
    Get a different servo. Check the specs before you buy, most hobby servos are rated +- 60 degrees.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.