Shop OBEX P1 Docs P2 Docs Learn Events
Parallax EB500 and EB600 (Bluetooth) — Parallax Forums

Parallax EB500 and EB600 (Bluetooth)

bsuguybsuguy Posts: 7
edited 2005-04-12 22:03 in Learn with BlocklyProp
I'm currently doing a project for my hardware class using a BoE (BS2, PBASIC2.5) and two EB500s. The premise behind my project is a remote light sensor that uses Bluetooth to communicate wirelessly. My plan is to place the BoE w/ attached EB500 in a separate room with a varying light level. Using a photoresistor and CR circuit, I'll get the RCTIME value saved to a variable and do a little formatting. On the other end I'll have a PC connected to another BoE w/ attached EB500, which will receive the value and DEBUG it to the STAMP plotting program (forgot the name of the program). My troubles, which I'm hoping some of you out there can help me with, stem from the fact that I am unsure of the PBASIC code necessary for my project. I've spent plenty of time digging through the EB500 and Basic STAMP manuals, so I'm at least partially familiar with the necessary commands and code structure. I already have the code for the light sensing part, so I just need to figure out how to get the two devices to connect and communicate the necessary information.

So far I have this code for the PC side:
' {$STAMP BS2}
' {$PBASIC 2.5}

'Variable(s)
lightlevel  VAR  Word

‘I/O Line 5 provides the connection status
INPUT 5

‘Wait for the eb500 radio to be ready
PAUSE 1000

‘Connect
SEROUT 1,84,[noparse][[/noparse]“con MAC address”,CR]
SERIN 0,84,[noparse][[/noparse]WAIT(“ACK”,CR)]

WaitForConnection:
    IF in5 = 0 THEN WaitForConnection

DEBUG “Connected”,CR

DO

        'Receive light level data
        SERIN 0,84,[noparse][[/noparse]DEC lightlevel]

        'Display light level data
        DEBUG DEC lightlevel

LOOP




This should get the two devices connected. Any suggestions/corrections to the above code? What code should I use on the other side--the BoE w/ the light sensor in the other room? I want the second BoE to wait for the connection to be established before it starts sending data back to the PC, but how could I do this without just using a PAUSE ####? Would I just use the WaitForConnection code block again on the other side to check for the connection before continuing? I also want the remote BoE to send data only when it is queried by the PC-side BoE, so what's the best way to do that? Or should I just have it continually spit out the data as soon as it detects a connection and not worry about it?

I'm imagining the light-sensing device's code will look something like this, tell me what's right/wrong:

' {$STAMP BS2}
' {$PBASIC 2.5}

'Variables
rcvalue  VAR  Word
dischargetime  VAR  Word
light  VAR  Word

‘I/O Line 5 provides the connection status
INPUT 5

‘Wait for the eb500 radio to be ready
PAUSE 1000

WaitForConnection:
    IF in5 = 0 THEN WaitForConnection

DO
        
        HIGH 15
        PAUSE 100
        RCTIME 15, 1, rcvalue
        dischargetime = rcvalue * 2
        light = (65535 - dischargetime)

        SEROUT 1,84,[noparse][[/noparse]DEC light]

LOOP




I'll just let it loop forever until I unplug the power. How does that look? I need feedback, suggestions, constructive criticism, hints, clues, and even miracles.

Am I also correct in assuming that I can simply load the program into the BoE, unplug it, move it to the other room, plug it back in, and it should run fine? I thought the BoE used NVRAM, but I can't remember.

Thanks in advance.

Comments

  • edited 2005-04-03 17:13
    In the command

    SEROUT 1,84,[noparse][[/noparse]“con MAC address”,CR]

    are you substituting the mac address of the remote EB500 in place of the text "...MAC address"?

    If not, there might be a problem getting the two modules to talk to each otehr. The eb500 Users Manual on the Parallax site show how to do this on pages 18 and 19.
  • bsuguybsuguy Posts: 7
    edited 2005-04-03 21:18
    Yes, I just put "MAC address" in there as a temporary placeholder.· Any other thoughts/suggestions on the code and other questions?
  • K de JongK de Jong Posts: 154
    edited 2005-04-03 22:38
    You can use polling.

    That is the PC-side EB500 calls the remote EB500 with its MAC-address. The remote 'sees' the call on its connection status pin 8 going high. The remote can then make pin 9, mode control, high and send data to the PC-side EB500.

    I hope this helps,

    Klaus
  • bsuguybsuguy Posts: 7
    edited 2005-04-04 01:51
    Great idea, thanks.· But how exactly do I do that? confused.gif·· Programming is not my strong suit, unfortunately.· Thanks in advance.
  • edited 2005-04-04 05:30
    Make sure this simplest form of the program functions first so that you can have a baseline for trouble-shooting as you expand the program.

    After the simple program is working, take a look at this: Your PBASIC program running in the BASIC Stamp connected to the PC could use the optional Timeout and Tlabel arguments in its SERIN command. Otherwise, if the connection is lost, it could get stuck endlessly waiting at the SERIN command for a message that never comes. Check either the BASIC Stamp Editor's Help or the BASIC Stamp Manual for more about the SERIN command and it's Timeout and Tlabel arguments. If the Timeout duration is exceeded, the SERIN command can send the program to a label that checks (or re-checks) the connection.
  • bsuguybsuguy Posts: 7
    edited 2005-04-04 05:38
    Thanks, I'll look into those.
  • bsuguybsuguy Posts: 7
    edited 2005-04-08 21:59
    OK, so now I can't seem to get two EB500s on two Board of Educations to connect...?· I know how to use the SEROUT command to tell one EB500 to connect to the other EB500, and I've done this successfully using an EB600 adapter and HyperTerminal (testing with the Hello World.bs2 included on the CD).· But how do I get two EB500s on two BoEs to connect?· I do the SEROUT 1,84,[noparse][[/noparse]"con xx[noparse]:xx:[/noparse]xx[noparse]:xx:[/noparse]xx:xx"], obviously substituting in the real MAC address, but I don't get the "Connection established" debug that I'm looking for.· Do I have to set any special code into the other BoE to tell it to wait for a connection?· Right now, I start the program off with a PAUSE 1000 to get the radio ready, and then I use this little code block to have it wait for a connection:
    ·
    [b]WaitForConnection:[/b]
    [b]  IF IN5=0 THEN WaitForConnection[/b]
    
    

    Is this the right code to use to have the BoE/EB500 go into a loop and wait for a connection, and then break out of the loop when a connection is established?

    Also, I'm having some trouble with my EB600 now.· It was working perfectly before when I had an EB500 plugged into it and used HyperTerminal to connect, but now it does not seem to connect.· I've recreated the HyperTerminal connection, tried both of my EB500s, and tried different PCs.· At first when I connected w/ HT, it seemed like it kept receiving a carriage return every few seconds even though I was not touching anything.· I tried a different PC and it didn't do that, but I could not get a response from the EB500.· Finally it did give me a response, but it just kept returning NAK to all my commands.· I went back to the original PC and had the same problem... and then it started to work again!?· Now it has stopped working again, it just doesn't seem to respond to any commands I give it.· HyperTerminal does not even bring up the ">" character to let me know that it's waiting.· I tried both of my EB500s, and it's just doing the same thing.· I recreated the HT connections, no difference.· Is the EB600 going bad?· Any ideas?

    bsuguy
  • edited 2005-04-11 21:08
    In the EB500 user's manual, they have an example that connects two EB500 modules. Try copying and pastind directly from the PDF to the BASIC Stamp editor, then edit the code so that it sends DEBUG commands instead of servo pulses.

    Avoid touching the solder joints on the underside of the board when working with these modules. The modules are pretty sensitive, and if your fingers are applying applying static or creating resistance between pins, it can cause problems.
  • bsuguybsuguy Posts: 7
    edited 2005-04-11 22:57
    Thanks, I'll give that a shot.

    bsuguy
  • KiwiKiwi Posts: 85
    edited 2005-04-12 18:13
    hello,

    I saw your message concerning the bluetooth adapters. Did somebody already tried out a Bluetooth flexipanel?

    Kurt
  • bsuguybsuguy Posts: 7
    edited 2005-04-12 22:03
    Nope, sorry.

    bsuguy
Sign In or Register to comment.