Shop OBEX P1 Docs P2 Docs Learn Events
Help With Servo Control — Parallax Forums

Help With Servo Control

deanthornedeanthorne Posts: 5
edited 2012-01-28 14:43 in BASIC Stamp
I recently purchased the BASIC Stamp Activity Kit w/ Homework Board and am working my way through the accompanying "What is a Microcontroller" Text and now I'm stuck on Chapter 4 on controlling the servo.

No matter what I do I can not get the servo to move as the book describes. I have used this code to attempt to center the servo, then go all the way one way, then all the way the other, but all the servo does is jerk clockwise about 30 degrees per pulse until it reaches maximum limit.
PAUSE 1000
FOR x =1 TO 10
  DEBUG HOME
  DEBUG CR, "Center to 90 Degrees"
  PULSOUT 0, 750
  PAUSE 20
  DEBUG HOME
  DEBUG CR, "Zero to Min (0 Degrees)"
  PULSOUT 0, 250
  PAUSE 20
  DEBUG HOME
  DEBUG CR, "Zero to Max (180 Degrees)"
  PULSOUT 0, 1250
  PAUSE 20
  DEBUG HOME
  DEBUG CR, CR, CR,"Cycles Remaining: ", DEC 10 - x
  PAUSE 1000
NEXT

I have even isolated the servo to it's own power supply (4 'AA' batteries) and still no luck.

So is it me or the servo or something else??

Thnaks in advance

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2012-01-28 14:18
    From your description, it sounds as though the servo is not sharing the same ground connection as the Basic Stamp. Without a shared connection, it is suseptable to external interference...the 60Hz from the mains is enough in proximity to cause this kind of behavior with servos if the ground connection is not shared.

    There is also too much delay in your program between the PAUSE 1000 and your DEBUG statements that will cause your servos to behave this way
  • Mike GMike G Posts: 2,702
    edited 2012-01-28 14:24
    You are not giving the servo enough time to reach a position.
    FOR x =1 TO 50
      PULSOUT 0, 750
      PAUSE 20
    NEXT
    FOR x =1 TO 50
      PULSOUT 0, 250
      PAUSE 20
    NEXT
    

    It can take many PULSOUT commands before the servos makes it to the desired stopping point. Even then, you must continue to send pulses every 20ms for the servo to hold position.
  • deanthornedeanthorne Posts: 5
    edited 2012-01-28 14:43
    Awesome!!
    Mike, Beau Thanks for both your comments. Now I understand my problem.
Sign In or Register to comment.