Shop OBEX P1 Docs P2 Docs Learn Events
Help on programming PSC — Parallax Forums

Help on programming PSC

fleurdelis158fleurdelis158 Posts: 5
edited 2006-05-19 14:07 in Robotics
Greetings.

I'm new to this programming stuff of Basic Stamp. I need some help in programming two servos to make my robot move forward (or backward). I'm using BS2p24 microcontroller and Board of Education Rev C. I also use the Parallax Servo Controller (#28023). I've tried to program it but all i can do is making the servo rotating in the same direction. I know that in order to make the robot move forward (or backward), one servo must rotate clockwise and the other must rotate counterclockwise, but i really don't know how. What position should i put in my program?(GWS servos are used). Which command should I use?

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-05-08 23:46
    Usually, a pulse of 1.5 mSec, repeated every 20 mSec, makes a modified servo (modified so it will rotate continuosly) 'stand still'. Pulses of more than 1.5 mSec make it rotate one way, and less than 1.5 mSec rotate the other.

    For a BS2, "PULSOUT ServoPin1, 750" will generate a 1.5 mSec pulse (since that's 750 * 2 uSec). Some people use
    "PULSOUT ServoPin1, 500", and "Pulsout ServoPin2, 1000" to get a 1 mSec (spin one way) and 2 mSec (spin the other way) pulse. Then you need a "Pause 20" before doing it again.
  • fleurdelis158fleurdelis158 Posts: 5
    edited 2006-05-09 00:48
    i'm using this program but i don't think it's right..the servos rotate in the same direction..how can i fix this?

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    ch VAR Byte
    ch2 VAR Byte
    pw VAR Word
    pw2 VAR Word
    ra VAR Byte
    Sdat CON 15
    baud CON 396
    i VAR Byte
    ra = 7
    ch = 14
    ch2= 15

    FOR i=1 TO 10
    pw = 1240
    pw2= 1240
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch2, ra, pw2.LOWBYTE, pw2.HIGHBYTE, CR]
    PAUSE 500

    pw = 260
    pw2= 260
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch2, ra, pw2.LOWBYTE, pw2.HIGHBYTE, CR]
    PAUSE 500
    NEXT
    END
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-09 03:49
    You're using the same pulse values for both servos...You should try lowering one to 500 and see if the servo goes the other way as it should.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • fleurdelis158fleurdelis158 Posts: 5
    edited 2006-05-09 08:16
    Thanks for the reply..

    Anyway, I've tried lowering the pulses of one of the servo to 500.but its still not working.does it has anything to do with the potentiometer inside the servo?
  • PengatomPengatom Posts: 21
    edited 2006-05-19 13:05
    FOR i=1 TO 10
    pw = 1240   <-- change this to 260
    pw2= 1240
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch2, ra, pw2.LOWBYTE, pw2.HIGHBYTE, CR]
    PAUSE 500
    
    pw = 260    <-- and this to 1240
    pw2= 260
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    SEROUT Sdat, 1021,[noparse][[/noparse]"!SC", ch2, ra, pw2.LOWBYTE, pw2.HIGHBYTE, CR]
    PAUSE 500
    
    

    If you change it like this, the servos should go seperate ways
    Don't know if the FOR loop is working though?

    Pengatom

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1 + 1 = 10· |· 4 + 4 = 10· |· 5 + 5 = 10· |· 8 + 8 = 10
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-19 14:07
    Have the servos been centered?· If you send them a 750 pulse do they still turn?

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