Shop OBEX P1 Docs P2 Docs Learn Events
increment values not working? — Parallax Forums

increment values not working?

gnomebotgnomebot Posts: 6
edited 2005-09-25 05:00 in BASIC Stamp
Hi·all,

I'm having some problems with some code I'm writing for my 2sx..

' {$STAMP BS2sx}
'
' servo control prog
Servleft· CON·· 2
Servright CON·· 3
xval····· VAR·· Word


· FOR xval = 1 TO 5
··· DEBUG "move forward: ", CR
··· DEBUG DEC xval, CR
··· PULSOUT Servleft, (90)
··· PULSOUT Servright, (-90)
· NEXT

xval is not incrementing..

I couldn't get (x = x + 1) to work withing a DO LOOP either..

Am I just missing something or do I need to update my stamps firmware?

Thanks,

Sean


Post Edited (gnomebot) : 9/25/2005 4:17:34 AM GMT

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-25 00:10
    Sean -

    Are you sure THAT program got loaded into the Stamp? The only odd thing I see about it, which shouldn't have any major impact, is that xval is defined as a word, as opposed to a byte or nib.

    Did you get any output on your DEBUG screen at all? If only once, see below.

    Are you powering your servos from the Stamp power supply, or from a separate power supply? I suppose you could be getting an inadvertant RESET if the load was too great if the servos were powered from the Stamp power supply. The BS-2SX is a bit power hungry.

    Regards,

    Bruce Bates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-25 00:27
    Sean,

    ·· Your PULSOUT values are not valid.· I believe the center value for the servos on a BS2sx is 1875.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • gnomebotgnomebot Posts: 6
    edited 2005-09-25 04:28
    Ok,

    Thanks guys.

    I was running the servos off of the Vss and Vdd. As soon as I switched them to a different power supply, it worked just fine.

    I have hacked my servos for continuous rotation by removing the potentiometer and inserting 2.2k Ohm resisters. The servos will not rotate until I send them a PULSOUT value greater or less than 0, depending on the rotation.


    I do have another code question though:

    x VAR Byte

    Main:
    · IF (x < 5) THEN
    ··· DEBUG "if then", CR
    ··· x = x + 1
    · ENDIF
    GOTO Main

    I get an "Expected a label" error and it puts the cursor after the "if.. then"

    Now.. I know I'm a noob to PBasic, but I have written enough code in various languages to be a bit puzzled.

    Thanks for all the help! [noparse]:)[/noparse]

    Sean




    Post Edited (gnomebot) : 9/25/2005 4:46:46 AM GMT
  • kelvin jameskelvin james Posts: 531
    edited 2005-09-25 05:00
    Use pbasic 2.5 directive for ENDIF.
    kelvin
Sign In or Register to comment.