Help with using 433MHz Transcievers with the BS2 Stamp
Slinkman44
Posts: 6
Hello, I am currently working on a school project and I need help. I am using two 433 MHz Transcievers with two basic stamps to try and get them to communicate with eachother. When I use the sample code in the documentation I seem to get random values that come up at random times in the debug terminal. I would apperciate it if someone could give me a brief introduction on how to program the transcievers to communicate with eachother on the BS2 stamp.
If I am posting in the wrong place I am sorry but I saw posts about the Transcievers all over the place.
If I am posting in the wrong place I am sorry but I saw posts about the Transcievers all over the place.
Comments
this first one is the receiving side.
LOW 1 ' T/R Line
DO
LOW 0
SERIN 0, 16468, [WAIT("!w"), x ]
HIGH 0
IF (x = 72) THEN Out_595F
IF (x = 85 ) THEN Back
IF (x = 41 ) THEN Lef
IF (x = 22 ) THEN Righ
IF (x = 54) THEN Cam
LOOP
STOP
So it looks like i actually used "!w"
here is a part of the transmit side
x VAR Byte
LR VAR Word
UD VAR Word
Main:
DEBUG "still"
x = 0
HIGH 1 ' T/R Line
DO
PULSOUT 0, 1200 'Sync pulse for the receiver
SEROUT 0, 16468, [ "!w",x]
PAUSE 10
HIGH 13
PAUSE 2
RCTIME 13, 1, UD
HIGH 14
PAUSE 2
RCTIME 14, 1, LR
IF IN4=1 THEN CamMain
IF (LR > 700) THEN moveL
IF (LR < 100) THEN MoveR
IF (UD > 675) THEN MoveF
IF (UD < 50) THEN MoveB
LOOP
MoveF:
DO
DEBUG "foward"
x = 72
HIGH 1 ' T/R Line
PULSOUT 0, 1200 'Sync pulse for the receiver
SEROUT 0, 16468, [ "!w", x]
PAUSE 10
HIGH 13
PAUSE 2
RCTIME 13, 1, UD
HIGH 14
PAUSE 2
RCTIME 14, 1, LR
PAUSE 10
IF (UD<675) THEN Main
LOOP
Basically what this is doing is that it is constantly transmitting the value "0" unless certain conditions are met, then the transmitted value changes. also notice on the reciever side that it stays in loop and is always communicating with each other even when nothing is happening. I am sure there is a better way but i know this worked for me. Any ways hope this helps. sorry its so sloppy. it is bassically my code from a project for school i had to hurry and finish Because i ran into the same problem as you and once i got the code to work, i didnt clean it up much. haha
Sending
' Tcvr_TxCode_v1.1.bs2
'{$STAMP BS2}
'{$PBASIC 2.5}
x VAR Word
y VAR Word
HIGH 1 ' T/R Line
DO
PULSOUT 0, 1200 'Sync pulse for the receiver
SEROUT 0, 16468, [ "!w", x]
x = x + 1
y = y + 1
PAUSE 10
LOOP
Recieving
'Tcvr_RxCode_v1.1.bs2
'{$STAMP BS2}
'{$PBASIC 2.5}
x VAR Word
y VAR Word
LOW 1 ' T/R Line
DO
LOW 0
SERIN 0, 16468, [WAIT("!w"), x]
HIGH 0
DEBUG ? x
DEBUG ? y
LOOP
Again any explinations tutorials or help at all would be apperciated. Thank you!
The bidirectional CRC examples do show a LOW Tx (like LOW 0) during initialization, but it precedes the LOW TxEnable (like LOW 1) so that, when the mode is switched to transmit later in the program, the state of the data line will be low initially.
x = 0
y = 0
right above the DO on the tx code
and take out the
debug ? y
on the rx code
And i know i was never able to get the sample code to work.
Is there any way to test to make sure the chip itself is not shot?
Pin 0 is data
pin 1 is TX-RX
pin 2 is PDN
pin 3 is RSSI
First thing is that my pins are backwards in the program, that should be an easy fix.
TX-RX pin 0
DATA pin 1
I do not have anything else plugged in.( Besides +5v and gnd of course)
Next thing is that i made a simple switch on the Tx side using pin 15. just use a 220ohm pull down resistor and use a wire to plug and unplug from +5v as the "switch".
Next... Well this is the easy part, just compile the programs into each of the basic stamp modules. I suggest doing the TX one first and then turn it off. After that, do the RX one and leave it plugged into the computer and you should see a debug terminal with nothing in it. Now go ahead and apply power back to the TX module and you should see 0's on the debug terminal for the RX. Once you plug the wire into the +5v (your switch), you should see the number 27, and then back to 0 once unpluged.
Hope this helps!!!
PROGRAMS
TX
' {$STAMP BS2}
' {$PBASIC 2.5}
X VAR Byte
TX CON 0
LN CON 1
MAIN:
x = 0
HIGH TX
DO
PULSOUT LN, 1200
SEROUT LN, 16468, [ "!w",x]
PAUSE 10
IF IN15 = 1 THEN SEND
LOOP
SEND:
x = 27
HIGH TX
DO
PULSOUT LN, 1200
SEROUT LN, 16468, [ "!w",x]
PAUSE 10
IF IN15 = 0 THEN MAIN
LOOP
RX
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Byte
TX CON 0
LN CON 1
DO
LOW TX
SERIN LN,16468,[WAIT ("!w"),x ]
DEBUG ? x
LOOP
Don't be afraid to change the code and try different pins on the stamp. You never know, the pins may be bad!!!