RN-42 Bluetooth Module & Basic Stamp 2 Problem
Mooneyguy
Posts: 77
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...
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
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.
Thanks.
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 cant imagine how the board ever got released for production applying more current or voltage than the Bluetooth is rated for wouldnt a good thing either.
I admit I am a novice at this stuff so I thank everyone for their understanding and help.