Shop Learn
Servo and Basic Stamp 1 boards — Parallax Forums

Servo and Basic Stamp 1 boards

I have a Basic Stamp HomeWork Board (accepts bs2 code) as well as a Basic Stamp 1 Project Board (accepts bs1 code). With the Homework Board, the Parallax-supplied servo works as described in the book "What Is A Microcontroller." However, when the servo is connected to the Project Board, the servo moves in unexpected ways. I don't know if the PULSOUT commands are supposed to work the same way on both of these boards (with the bs1 and bs2 versions of the programming language). Rather than figure this out by trial and error I'm hoping somebody can describe how to use the servo with the Project Board and bs1. I want to be able to rotate the servo's horn both clockwise and counter-clockwise, through its full range of positions. Thanks in advance.

Comments

  • No trial and error needed.

    PULSOUT on BS1 is 10 usec units; BS2 is 2 usec units. So you need to adjust BS2 code by a factor of 5. 150 gets you center; limits are 120-180 or so.

    PAUSE is the same for both; units are 1 msec.

  • Thanks Tom. I'll give that a try.

  • Yep, that did it! With my Stamp 1 Project Board and servo the valid range for pulses appears to be 50 to 210.
    Here's a test program that slowly rotates the servo horn in both directions.


    ' {$STAMP BS1}
    ' {$PBASIC 1.0}

    ' July 14, 2021
    SYMBOL inner =W2
    SYMBOL counter =W3
    SYMBOL looper =W4
    SYMBOL width =W5
    SYMBOL pete =B0

    DEBUG "Program start", CR
    ' Working toward a jerkily turning dance stage for a Pete the Cat ...
    ' So the port is called 'pete'
    pete = 1
    FOR inner = 1 TO 5
    PULSOUT pete, 50
    PAUSE 20
    NEXT

    FOR looper = 1 TO 10
    DEBUG "Now starting counter-clockwise turn.", CR
    PAUSE 999
    FOR width = 50 TO 210 STEP 2
    DEBUG "Loop 1, width is ", width, CR
    FOR inner = 1 TO 5
    PULSOUT pete, width
    ' DEBUG "Width is ", width, CR
    PAUSE 20
    NEXT
    DEBUG "End of loop with width ", width, CR
    PAUSE 200
    NEXT
    DEBUG "Now starting clockwise turn.", CR
    PAUSE 999
    width = 212
    FOR counter = 50 TO 210 STEP 2
    width = width-2
    DEBUG "Loop 2, width is ", width, CR
    FOR inner = 1 TO 5
    PULSOUT pete, width
    ' DEBUG "Width is ", width, CR
    PAUSE 20
    NEXT
    DEBUG "End of loop with width ", width, CR
    PAUSE 200
    NEXT
    NEXT

  • Good job, Geezer

    Nice use of DEBUG statements.

    BTW, If my handle was Geezer, it would have to be Geezer1942. We old farts have to stick together. ;-)

  • WRT "We old farts have to stick together. ;-)" I agree. Thanks for the help and the complements on my code.
    I should have Pete the Cat dancing on top of a servo the next time I see my granddaughters. :-)

Sign In or Register to comment.