Shop OBEX P1 Docs P2 Docs Learn Events
Help needed - BS2SX as relay controller — Parallax Forums

Help needed - BS2SX as relay controller

VeeateVeeate Posts: 7
edited 2007-06-01 16:37 in BASIC Stamp
Hi. I'm a new stamp user and really could use some help getting started.
I'm trying to use a BS2SX to control some relays, but don't know exactly where to start.
To start, I'd like a list of commands to loop indefinately until I power the unit off.

The following simply switches relays 1 and 2 on/off:

SEROUT 0, 16390,[noparse][[/noparse]254,108,1]
PAUSE 750
SEROUT 0, 16390,[noparse][[/noparse]254,100,1]

SEROUT 0, 16390,[noparse][[/noparse]254,109,1]
PAUSE 750
SEROUT 0, 16390,[noparse][[/noparse]254,101,1]

What else do I need to include in my program? Obviously some sort of do/loop command?
Any help would be GREATLY appreciated!!!

Thanks,
Jason

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-31 15:12
    Jason,

    If it’s that simple then that is all you need…
    DO
      SEROUT 0, 16390,[noparse][[/noparse]254,108,1]
      PAUSE 750
      SEROUT 0, 16390,[noparse][[/noparse]254,100,1]
     
      SEROUT 0, 16390,[noparse][[/noparse]254,109,1]
      PAUSE 750
      SEROUT 0, 16390,[noparse][[/noparse]254,101,1]
    LOOP
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • VeeateVeeate Posts: 7
    edited 2007-05-31 15:35
    Actually, I had tried that without success. To test it, I used an additional debug print word to make sure the loop was cycling, and it was not. If I use a goto, it will loop, but I'm getting any response from my external relays. Any ideas? I know that's not a lot to go on...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-31 16:06
    That means you are not inserting the PBASIC 2.5 directive in your code. For the DO…LOOP to work you must specify 2.5 syntax. You can click the 2.5 icon on the toolbar or insert it from the Directive Menu under PBASIC/2.5. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • VeeateVeeate Posts: 7
    edited 2007-05-31 18:21
    Chris - you got me on the 2.5 directive, I had 2.0 incorrectly.
    Turns out my trouble was related only to the baud rate code (I was given a number for a BS2 not the SX).
    Everything is up and running now and I appreciate all the help.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-31 19:02
    Jason,

    You didn’t indicate in your earlier posts that you were having trouble with the code or that you had a BS2sx. In fact your first message indicated that the code you had was working. Just something to keep in mind for future posts. In any event I’m glad you got it working. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • WarrlokWarrlok Posts: 77
    edited 2007-06-01 16:37
    i was gonna say he was missing a pause before the loop command ,,,,but if it s working?!!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Problems are the "roads" of life,
    solutions are only "onramps" to the next problem



    ············································· "Brad Smith"
    ·
Sign In or Register to comment.