Shop OBEX P1 Docs P2 Docs Learn Events
PSC code help, anyone?? — Parallax Forums

PSC code help, anyone??

demodemo Posts: 19
edited 2007-01-05 21:27 in BASIC Stamp
Can somebody help to make this simple servo movement with PSC?



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


counter VAR Byte

FOR counter = 1 TO 100
PULSOUT 12, 1250
PAUSE 20
NEXT

FOR counter = 1 TO 100
PULSOUT 12, 2500
PAUSE 20
NEXT

END

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-01-04 19:06
    Take a look at the documentation here. www.parallax.com/detail.asp?product_id=28023 There are examples.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • demodemo Posts: 19
    edited 2007-01-04 19:29
    Hi Stephen, Thanks for reply.
    I have all the documentation, problem is that when I try to make that same thing with PSC, servo just starts spinning and never change direction or stop.
  • FranklinFranklin Posts: 4,747
    edited 2007-01-04 23:57
    What code are you using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • demodemo Posts: 19
    edited 2007-01-05 18:59
    Here's the code:

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

    ch VAR Byte
    pw VAR Word
    ra VAR Byte
    sDat CON 15
    Baud CON 1021
    counter VAR Byte

    ra = 1
    ch = 1


    FOR counter = 1 TO 100
    pw = 1250
    SEROUT sDat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    PAUSE 20
    NEXT
    FOR counter = 1 TO 200
    pw = 2500
    SEROUT sDat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    PAUSE 20
    NEXT
    END
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-05 20:55
    Demo,

    You’re treating the PSC as if it was a serial servo, but it is not. Your code is sending the command to move to one position 100 times, and then sending the command to move to another position 200 times. You don’t need to refresh the PSC every 20 mS like a servo. The PSC keeps itself refreshed. You simply send a command and when ready send another. The thing is the pulse value you are sending is outside the range of the PSC. The PSC uses values from 500 to 1000 where 750 is the center point. The values you are sending are for a BS2sx using PULSOUT directly to a servo. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • demodemo Posts: 19
    edited 2007-01-05 21:27
    Hi Chris,

    It works! Thanks so much for your help!



    Demo
Sign In or Register to comment.