Parallax EB500 and EB600 (Bluetooth)
bsuguy
Posts: 7
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:
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:
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.
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
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.
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
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.
·
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
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.
bsuguy
I saw your message concerning the bluetooth adapters. Did somebody already tried out a Bluetooth flexipanel?
Kurt
bsuguy