Shop OBEX P1 Docs P2 Docs Learn Events
Out of variable space (programming servos) — Parallax Forums

Out of variable space (programming servos)

AntonuccioAntonuccio Posts: 17
edited 2012-08-13 16:45 in BASIC Stamp
I am currently trying to program 12 servos using a BS2, a Board of Education, and a Propeller Servo Controller Unit. The way I currently have my program setup I can only assign 10 servos without getting the program error "out of variable space". I am a serious novice when it comes to programing in general, so I do not know if there a way to program up to12 servos with my current setup. Or perhaps i will have to upgrade my hardware?

Here is the program I am trying to use to control the servos.

5testForum.bs2

Comments

  • Mike GMike G Posts: 2,702
    edited 2012-08-12 18:35
    Give this a look...
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    
    ' Set baud for all STAMP versions
    #SELECT $STAMP
      #CASE BS2SX, BS2P
        N2400        CON     1021 + $8000
        N38K4        CON     45 + $8000
      #CASE BS2PX
        N2400        CON     1646 + $8000
        N38K4        CON     84 + $8000
      #CASE #ELSE
        N2400        CON     396 + $8000
        N38K4        CON     6 + $8000
    #ENDSELECT
    
    
    Sdat         CON    15
    baud         CON    396
    
    FOOT1        CON    8
    FOOT2        CON    15
    FOOT3        CON    11
    FOOT4        CON    12
    LEG1         CON    6
    LEG2         CON    5
    LEG3         CON    9
    LEG4         CON    10
    ARM1         CON    4
    ARM2         CON    2
    ARM3         CON    9
    ARM4         CON    1
    DEFAULT_RAMP CON   10
    
    FOOT_UP      CON 850
    FOOT_DOWN    CON 650
    
    LEG_UP       CON 1000
    LEG_DOWN     CON 500
    
    ARM_UP       CON 900
    ARM_DOWN     CON 700
    
    'Vars
    id           VAR    Word
    ramp         VAR    Byte
    position     VAR    Word
    delay        VAR    Byte
    
    
    
    Init:
      ramp = DEFAULT_RAMP 'speed adjust
      delay = 100
    
    Main:
      id = FOOT1
      position = FOOT_UP
      GOSUb Write_PSC
    
      id = FOOT2
      GOSUb Write_PSC
    
      id = FOOT3
      GOSUb Write_PSC
    
      id = FOOT4
      GOSUb Write_PSC
    
    GOTO Main
    
    Write_PSC:
      SEROUT Sdat,Baud,["!SC", id, ramp, position.LOWBYTE, position.HIGHBYTE, CR]
      PAUSE delay
      RETURN
    
  • AntonuccioAntonuccio Posts: 17
    edited 2012-08-13 16:45
    I created a test program following your example and it seems to be working quite well. I will have to play with the program a bit more to be sure, but it looks like my problems are solved.

    Thanks for the help Mike G.
Sign In or Register to comment.