Shop OBEX P1 Docs P2 Docs Learn Events
Futaba servos — Parallax Forums

Futaba servos

Andy BAndy B Posts: 17
edited 2005-03-17 17:16 in BASIC Stamp
hi all
I·am a newbie at the robotic scene.blush.gif
What i am trying to find out is how i control a servo with the pulsout command

I:E Pulsout 15,750
What i am trying to do is make a servo SCAN ( FULL LEFT THEN FULL RIGHT )
if someone could show me the code to do this i will understand it.
Then i can work out the same for UP AND DOWN

I am trying to make a simple pan and tilt using the two servos X,Y

many thanks hop.gif

Andy

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-17 04:03
    Have a look at our "Whats A Microcontroller?" and "Robotics" text books (available online as PDF) -- they will explain everything in detail.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Andy BAndy B Posts: 17
    edited 2005-03-17 05:37
    many thanx.

    i tried this from the book:-

    ' Test the servo at three different position signals.
    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    counter VAR Word
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, -100

    PAUSE 20
    NEXT

    DEBUG "Counterclockwise 10 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 1000
    PAUSE 20
    NEXT
    DEBUG "Clockwise 2 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 500
    PAUSE 20
    NEXT
    DEBUG "All done."
    END


    My Servos seem to not centre at all

    Are servo's different in the code they need?
    i am using FUTABA S3003
  • Andy BAndy B Posts: 17
    edited 2005-03-17 05:39
    please ignore the PULSOUT 14, -100
    i tried - 100 also
    but didnt seem to make any difference

    andy
  • Ken GraceyKen Gracey Posts: 7,387
    edited 2005-03-17 05:53
    Andy:

    Try this assuming it is a standard (not continuous rotation) servo.

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}

    Counter VAR Word

    RotateCCW:
    FOR Counter = 500 to 1000 Step 10
    'DEBUG DEC4 Counter, CR
    PULSOUT 12, Counter
    PAUSE 20
    NEXT

    RotateCW:
    FOR Counter = 1000 to 500 Step 10
    'DEBUG DEC4 Counter, CR
    PULSOUT 12, Counter
    PAUSE 20
    NEXT

    Reduce or increase the Step value as you experiment. Add a GOTO RotateCCW to the end of the code. Add in your DEBUG commands after the label. Download the What's Microcontroller? text, too, please. This book offers superior explanation to what you could receive on the forums. And it's not difficult to read, not to mention you can jump to the relevant section you need to read for servo control.

    Ken Gracey
    Parallax, Inc.
  • Andy BAndy B Posts: 17
    edited 2005-03-17 07:54
    many thanx KEN

    that worked wonderful, one last question.
    i had to set my servo's go get full CCW and full CW as this:

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}

    Counter VAR Word

    RotateCCW:
    FOR Counter = 499 to 3000 Step 10
    'DEBUG DEC4 Counter, CR
    PULSOUT 12, Counter
    PAUSE 20
    NEXT

    RotateCW:
    FOR Counter = 3000 to 499 Step 10
    'DEBUG DEC4 Counter, CR
    PULSOUT 12, Counter
    PAUSE 20
    NEXT

    that worked perfect !
    Question is:- i added another part for Example:

    scancentre:
    FOR Counter = 1500 to 499 Step 10
    'DEBUG DEC4 Counter, CR
    PULSOUT 12, Counter
    PAUSE 20
    NEXT

    this again scanned CCW and then CW then centred itself, But !
    when it started the CCW scan again it spins fast (about STEP 50) to the far CW possition then does its normal slow scan

    infact what i am trying to do and i have read from the book also is get the servo's to scan CCW and the CW
    and return to centre position.

    any ideas?

    many thanxs
    Andy B
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-03-17 08:26
    First of all be sure that you are not 'straining' your servos. The exact numbers you use will vary from Servo to servo. Spinning really fast usually is the result of trying to send a position or motion from a starting position that the servo isn't actually at when the command was sent- so with no ramping at all it tries to jump to where it is told to start. From what you describe it sounds as if you scanned CCW, then CC, then centered. The code then went to the CCW scan, which did not start from 'right side' but from center (where you last left it) - so it jumped to the side because of where the CCW assumes you are positioned when you start.

    i.e. counter is 499 when you end CC, but counter STARTS at 1500 in the centering part. This will cause a fast 'jump' as you describe it.

    Also you should read up on ramping, it's easy to do.

    Ryan

    Post Edited (LostboY) : 3/17/2005 8:29:51 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-17 14:15
    Servos usually want a pulse betwee 1000 (CCW) and 2000 (CW) microseconds. With the BS2 we use 500 and 1000 and the PULSOUT values as the resolution for PULSOUT is 2 uS. For the BS2sx you need to change this the values to:

    1000 uS / 0.8 uS/unit = 1250
    2000 uS / 0.8 us/unit = 2500

    Give those values a try and see if thing start behaving.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Andy BAndy B Posts: 17
    edited 2005-03-17 17:16
    Thank - you so much guys.

    i will give that a go tonight,i'm currently at work.

    andy b
Sign In or Register to comment.