Shop OBEX P1 Docs P2 Docs Learn Events
EB 500 Relay Control — Parallax Forums

EB 500 Relay Control

Jeremy NorrisJeremy Norris Posts: 5
edited 2007-05-11 17:21 in BASIC Stamp
I have been trying to figure out how to throw a relay with the EB 500 bluetooth appmod, and so far i have just hooked an optocoupler up to the pin that goes high whenever there is a conection (pin 5).· That works fine so far, but I would like to write a program that would allow me to tie in multiple relays.· Any Input would be appreciated.

P.S.· Im trying to develop a small automotive control system, nothing special, I have a 1987 Trans Am, and I want my own version of "KITT" From the (Knight Rider series).

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-09 14:39
    Jeremy,

    The EB500 is serial in nature, so once you’ve established communication you can send a byte variable over to the BASIC Stamp with bits set for relays you want turned on/off connected to the I/O port. You could even write the variable directly to the appropriate OUTH/OUTL register. I would focus on serial communication first then send that control byte. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Jeremy NorrisJeremy Norris Posts: 5
    edited 2007-05-09 22:20
    Thanks Mr. Savage, that helps a lot.

    I just thought of an easier way to do what i want to do, the only problem is, i found out i realy dont know what im doing.

    the block of code i want to·modify comes right out of "Stamp Works" with a few modifications.

    ' =========================================================================
    '
    '·· File....... SW21-EX23-74HC595-1.BS2
    '·· Purpose.... Expanded outputs with 74HC595
    '·· Author..... (C) 2000 - 2005, Parallax, Inc.
    '·· E-mail..... support@parallax.com
    '·· Started....
    '·· Updated.... 01 SEP 2005
    '
    '·· {$STAMP BS2}
    '·· {$PBASIC 2.5}
    '
    ' =========================================================================

    '
    [noparse][[/noparse] Program Description ]
    '
    ' This program demonstrates a simple method of turning three BASIC Stamp
    ' I/O pins into eight digital outputs with a 74HC595 shift register.

    '
    [noparse][[/noparse] I/O Definitions ]
    Clock·········· PIN···· 0······················ ' shift clock (74HC595.11)
    SerData········ PIN···· 1······················ ' serial data (74HC595.14)
    Latch·········· PIN···· 2······················ ' output latch (74HC595.12)

    '
    [noparse][[/noparse] Constants ]
    DelayTime······ CON···· 100

    '
    [noparse][[/noparse] Variables ]
    pattern········ VAR···· Byte··················· ' zig-zag pattern

    '
    [noparse][[/noparse] Initialization ]
    Reset:
    · LOW Latch···································· ' make output and low
    · pattern = %00000001

    '
    [noparse][[/noparse] Program Code ]
    Main:
    · DO
    ····· GOSUB Out_595······························ ' put pattern on 74x595
    ··· PAUSE DelayTime···························· ' hold
    ··· pattern = pattern << 1····················· ' shift pattern left
    · LOOP UNTIL (pattern = %10000000)
    · DO
    ··· GOSUB Out_595
    ··· PAUSE DelayTime
    ··· pattern = pattern >> 1····················· ' shift pattern right
    · LOOP UNTIL (pattern = %00000001)
    · GOTO Main

    '
    [noparse][[/noparse] Subroutines ]
    Out_595:
    · SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern]· ' send pattern to '595
    · PULSOUT Latch, 5····························· ' latch outputs
    · RETURN



    This gives me a prety nice "KITT Scanner"· but i cant seem to figure out how to tie this in with the EB 500 detecting a connection on pin 5.· i know i have to switch around the pins to ones that the EB 500 does not use.· All i want is to connect with the EB 500 and make it execute the batch of code untill i disconnect the bluetooth.

    Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-09 22:54
    Providing you have 8 I/O pins available you can do the LED sequence without the 74HC595. I think with what you’re trying to do that may actually over complicate things. Maybe I am misunderstanding exactly what you want to do…What exactly are you trying to do? There might be a straight forward way to accomplish it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Jeremy NorrisJeremy Norris Posts: 5
    edited 2007-05-10 16:43
    I only need 3 I/O pins for the shift register to work so far.· I just want·the code to start LED sequence when it detects a connection on the EB 500, and end it when there isnt a connection.· I tried doing an IF, THEN command, but i just ended up confusing myself.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-10 17:34
    The quickest way I can think of is if you put a line right after the Main: label that says:

    IF IN5 = 0 THEN Main

    That will loop until a connection is made then start the sequence. It will keep looping until the connection is lost. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Jeremy NorrisJeremy Norris Posts: 5
    edited 2007-05-11 17:21
    That was so simple I'm amazed.· That completely solved·my problem, I just need to turn the power on to my LED's when the program starts now, but i know how to do that.

    Thanks a lot Mr Savage
Sign In or Register to comment.