Shop OBEX P1 Docs P2 Docs Learn Events
servo programming problem — Parallax Forums

servo programming problem

dmehlingdmehling Posts: 25
edited 2008-07-03 00:35 in BASIC Stamp
I am trying to program my basic stamp 1 to control a servo and I seem to be having trouble positioning the servo correctly. I'm trying to get the servo to move from its minimum and maximum articulation, but it doesn't want to move. It acts like it's at its limit and cannot turn in a certain direction any further and it cannot seem to go the opposite direction either. Below is a sample of the code for my program.

' {$STAMP BS1}
Main:

PULSOUT 1, 500
PAUSE 8000
PULSOUT 1, 1000
PAUSE 8000
GOTO main

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-07-02 20:26
    I'm not where I can look up the exact syntax but this is the idea. One pulseout will not be enough to get to the other stop. try this and adjust the pulseout numbers according to your needs.

    ' {$STAMP BS1}
    Main:

    for i = 1 to 20
    PULSOUT 1, 500
    PAUSE 20
    next
    for i = 1 to 20
    PULSOUT 1, 1000
    PAUSE 20
    next
    GOTO main

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-07-02 20:41
    Hello,

    The PULSOUT values you’re both specifying are for the BS2 which uses 2us increments. The BS1 however uses 10us increments and so those values are way outside the range. You should be using values from 100-200 with 150 being the center pulse value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • FranklinFranklin Posts: 4,747
    edited 2008-07-03 00:35
    Thanks Chris, I was just copying dmehlings code as when I do any coding I have to look these things up every time.

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