Shop OBEX P1 Docs P2 Docs Learn Events
RN-42 Bluetooth Module & Basic Stamp 2 Problem — Parallax Forums

RN-42 Bluetooth Module & Basic Stamp 2 Problem

MooneyguyMooneyguy Posts: 77
edited 2014-10-17 10:15 in BASIC Stamp
I have a Basic Stamp 2 Module on a bread board and a lot of wires already going to the Stamp. As a result I changed the PIN numbers from the provided sample software to the following (the original sample software downloaded from Parallax is below):

Reset PIN 0 ' To RN-42 RST pin
TX PIN 1 ' To RN-42 RX pin
RX PIN 2 ' To RN-42 TX pin
CTS PIN 3 ' To RN-42 RTS pin
RTS PIN 4 ' To RN-42 CTS pin

My problem description is at the bottom of this page. I am not sure I have the syntax correct in the main part of the program since I changed the pin numbers as stated above.

' File...... RN-42 Set Baud Rate.bs2
' Purpose... Sets the default baud rate to 9600bps

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

Reset PIN 1 ' To RN-42 RST pin
TX PIN 2 ' To RN-42 RX pin
RX PIN 7 ' To RN-42 TX pin
CTS PIN 12 ' To RN-42 RTS pin
RTS PIN 11 ' To RN-42 CTS pin

Baud CON 84 ' 9600bps on BS2

response VAR Byte(10) ' Buffer

InitIO:
HIGH TX ' Initialize TX line
PAUSE 100 ' Allow time to settle

Main:
PAUSE 2000 ' Allow hardware to be ready
SEROUT TX\CTS, 84, ["$$$"] ' Set Command Mode
PAUSE 500 ' Allow time for Command Mode
SEROUT TX\CTS, 84, ["SU,96", CR, LF] ' Change Baud Rate to 9600
SERIN RX\RTS, 84, [STR response\10\13] ' Buffer response
IF response(0) = "A" THEN ' Check for AOK
IF response(1) = "O" THEN
IF response(2) = "K" THEN
DEBUG CLS, "SUCCESS!", CR ' Command executed successfully
ENDIF
ENDIF
ELSE
DEBUG CLS, "FAILURE!", CR ' Command failed
ENDIF
END

When I power up the Stamp I start out with a blinking green light, then when I run the program the blinking green light changes to a solid green and solid blue at the same time, then with the solid green and solid blue light I get a red light that flashed for a moment and then a warning on the computer that says no basic stamp found.

While trying to fix the Bluetooth problem I inadvertantly set my ports to be ignored and don't know how to make my ports work again for the debug program. So also, how do I get my ports working again? I have spent hours on this...

Comments

  • Courtney JacobsCourtney Jacobs Posts: 903
    edited 2014-10-07 09:48
    This thread has been moved to the BASIC Stamp forum, where it might be better seen by users who can help.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-10-07 10:19
    In the BASIC Stamp Editor you can go to the Edit Menu, Preferences...then select Edit Ports and right-click on any you want to change exclusions on. This is assuming they are listed at all. I hope this helps.
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-07 14:46
    I will try that when I get home, but I think I already tried that and it did not work to fix the ports. How do you get the ports listed if they are not listed?

    Also, am I able to change the sample Bluetooth code as I have done above and will it work or do I have to change something else down below? Like change reponse(0). I don't understand what that command does yet and don't know if that 0 is related to the PIN 0 that I changed to PIN 1 because PIN 0 was already used. I tired it both ways without success last night.

    I can't seem to figure out why the blue light doesn't stay on so I can communicate through Bluetooth.
    I am working with the sample Bluetooth program and my main device program. I am using the sample Bluetooth program to see if I can get Bluetooth to work from my Dell PC with Windows 7. My main program uses a Baud19200 for the LCD display. Will that impact how the Bluetooth works with a similar looking Baud 9600 command?

    I tried Edit, Preferencec, Debug Port, Edit Port and included all of the ports as in the attached picture. Still not allowing me to stay in Bluetooth mode to communicate to the Stamp.

    Edit Ports.jpg
    1024 x 640 - 112K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-10-07 15:46
    If the port isn't showing up, which seems to be the case in your situation then either the USB driver isn't installed properly or the board isn't being seen by the PC. This could be due to a faulty cable or unlikely, but a problem with the board itself. The Blue LED going out means the connection was lost (Bluetooth). The numbers in parenthesis are elements in the array and not pic numbers. Changing the pin numbers would mean having to change the actual pins you're connected to.
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-08 12:44
    Still no luck getting the Bluetooth. Any help would be appreciated.

    Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-10-08 16:33
    Well it seems you have two issues. We should solve one and then the other rather than getting confused as to which one we're working on. I would start with getting the BASIC Stamp to show up in the port listings or you won't have any way to test communication.
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-09 13:46
    It now shows up in the port listings but I have the same original problem statement when I try to run it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-10-09 14:19
    Are you referring to the Bluetooth link being lost?
  • MooneyguyMooneyguy Posts: 77
    edited 2014-10-16 09:36
    I can't seem to get the Bluetooth module to work so I think I am going back to the wired connection now and will try to return the Bluetooth module this weekend if I can’t get it to work. I have been looking at this for a long time and now am not even certain what pins are being referred to in the documentation and sample software – probably due to over thinking it. At this point I am not certain if they are referring to the Basic Stamp 2 module pins, some other board’s pins or the RN-42 Bluetooth module pins. I just tried even taking everything off the board except the Basic Stamp 2 Module and the Bluetooth module, wired it to print, and used the supplied sample software. No go.

    I get the blinking green lite with power on, I still see the device on my computer as a working port when I run the sample program, but when I run the sample program debug I get the solid green and blue lite and then a warning on my computer that says No Stamp Can be found. Sometimes I get a short red lite flash. I just don't get it.

    Thank you PJ Allen for your reply to one of my earlier, confusing set of posts where you said: “If you are trying to get the Bluetooth module to run from the Stamp's 5V then forget it, its capabilities are modest. Likewise from a "9V" battery - No Sale. Your peripherals' demands (for current) are likely forcing the Stamp into brown-out. “

    But if that is true, I can’t imagine how the board ever got released for production – applying more current or voltage than the Bluetooth is rated for wouldn’t a good thing either.

    I admit I am a novice at this stuff so I thank everyone for their understanding and help.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-10-17 10:15
    I have moved your repost into the original thread. As with some of your other posts you are continuing to start new threads for the same topic. Please start one thread per topic and continue to follow-up in that thread. Posting new threads on the same subject is cross/duplicate posting and causes confusion.
Sign In or Register to comment.