Shop OBEX P1 Docs P2 Docs Learn Events
Servo Twitches Continuously After Program Ends — Parallax Forums

Servo Twitches Continuously After Program Ends

PadawanPadawan Posts: 3
edited 2010-05-06 19:56 in BASIC Stamp
Hi all,

I just recently got the 'What's a Microcontroller?' kit -- with the Homework Board -- and I have encountered a problem. After the ServoTest.bs2 code (from Chapter 4) is finished executing, my servo twitches every 3 to four seconds until I rerun the program or disconnect the battery. I have built my circuits and written my code exactly as depicted in the book. Is there something that I missed that might explain the servo's strange behavior? Any help would be appreciated.

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-06 00:24
    Your program ends with a STOP or END statement. This puts the Stamp into a low power mode which has the side effect of causing the I/O pins to switch to input mode briefly, then back to whatever mode they had been in. Depending on how the I/O pins are wired, this can cause a brief pulse to be produced which can make the servos twitch.

    Solutions:

    1) Connect a 4.7K or 10K resistor between the servo control line and ground (Vss) or

    2) End your program with a "HangHere: GOTO HangHere"

    The first will keep the I/O pin low when it's changed to input mode eliminating the "twitch".
    The second will keep the mode from changing to input by avoiding a STOP or END.

    Note that there's an implied END at the end of the program so you need something there to prevent this problem.
  • sumdawgysumdawgy Posts: 167
    edited 2010-05-06 04:12
    <EG>

    Since it's asleep...you could claim the twitch to be a design effect mimmicking a dreaming mamal,
    (As long as the servo's not running something like ....a paintball gun or a blade/hammer??? )

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-05-06 06:51
    The END statement is implied if the program just ends...a STOP command will halt execution without going into low power mode and will stop the twitch as wuld the GOTO loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-05-06 12:06
    You COULD simply put all your I/O pins into INPUT mode before the "END" or "STOP". That way, when the BS2 resets, it shouldn't pulse the servo, which causes the "twitch". If you do this, it might help to put a 10K resistor to ground from each servo signal pin, to guarantee RF noise doesn't trigger anything.
  • PadawanPadawan Posts: 3
    edited 2010-05-06 19:56
    Wow! Thank you all so much for the quick and informative responses. I will take all of your suggestions into consideration in the future when dealing with servos.

    Thanks you.
Sign In or Register to comment.