Shop OBEX P1 Docs P2 Docs Learn Events
Please help with SERVOS — Parallax Forums

Please help with SERVOS

Pedro ZepedaPedro Zepeda Posts: 3
edited 2006-02-23 01:24 in Learn with BlocklyProp
This is the program
Please I need to know how I can move the servo accurately and stay in the same position each time that I run the program again, because it is changing each time that I run the program. I want to move forward and backward 45 degrees each time. Thank you.

'{$STAMP BS2}
'{$PBASIC 2.5}
'I already center the cervo
x VAR Word
i VAR Word
FOR x=1 TO 3
FOR i=1TO 6
PULSOUT 12,850
PAUSE 100
NEXT
FOR i=1TO 6
PULSOUT 12,650
PAUSE 100
NEXT
NEXT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-22 22:34
    Hobby servos are not particularly accurate -- you might consider stepper motors if accuracy is your key concern.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Pedro ZepedaPedro Zepeda Posts: 3
    edited 2006-02-22 22:58
    I have borad of education and [url=mailto:BS2@Could]BS2. ·Could[/url] I use stepper motors with this
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2006-02-22 23:06
    Pedro,

    John is correct as far as "Hobby servos are not particularly accurate".

    However I noticed in your code that you are pausing for 100mS.
    Hobby servos are happy if they get a break anywhere from 15mS to 30mS.

    Try changing your PAUSE value to 20mS and increase the for next loop in both
    cases so that it reads...

    FOR i=1 TO 30

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-22 23:06
    With a proper driver, yes. You can use the ULN2003 with uni-polar motors, or the L293D with both uni-polar and bi-polar motors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Pedro ZepedaPedro Zepeda Posts: 3
    edited 2006-02-22 23:20
    FOR x=1 TO 10

    FOR i=1TO 10
    PULSOUT 12,850
    PAUSE 20
    NEXT

    FOR i=1TO 10
    PULSOUT 12,650
    PAUSE 20
    NEXT

    NEXT

    PULSOUT 12,735
    'This pulsout at the end correct the mistake and make the process 99% accurate.
    ' Thank you.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-23 01:24
    With only 12 iterations through your loop the servo doesn't have enough time to get from one extreme to the other before you change directions.· You really should do as Beau suggested and increase the loop time.
    FOR x=1 TO 10 
     
    FOR i=1TO 40
    PULSOUT 12,850
    PAUSE 20
    NEXT
     
    FOR i=1TO 40
    PULSOUT 12,650
    PAUSE 20
    NEXT
     
    NEXT
    
    

    You may or may not have to higher than 40 since you're going from one extreme to the other.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.