Shop OBEX P1 Docs P2 Docs Learn Events
Serial Communication over RF Transceivers — Parallax Forums

Serial Communication over RF Transceivers

msoccer0607msoccer0607 Posts: 4
edited 2010-08-15 20:46 in BASIC Stamp
I'm somewhat new to basic stamp and am having problems sending data between two Parallax RF Transceivers. Here is the code I'm using for each transceiver:

Transmitter:

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

counter VAR Word
distance VAR Byte

rxd PIN 15
txflo PIN 13
txd PIN 14

distance = 20
FOR counter = 0 to 30
SEROUT txd\txflo, 84, [distance]
NEXT

Receiver:

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

counter VAR Word
distance VAR Byte

rxd PIN 4
txflo PIN 2
txd PIN 1

FOR counter = 0 TO 5
distance=0
DO WHILE (distance = 0)
SERIN rxd\txflo, 84, [distance(counter)]
LOOP
DEBUG DEC distance, CR
NEXT

Neither of these programs does anything. I'm just trying to use them to learn how to use RF communication. The problem I'm having is that I need to send distance 30 or more times just to get it 5 times at the receiver. I don't understand why that is being as I'm using flow control. Also, I have to have a "DO WHILE" loop around the SERIN otherwise SERIN reads a bunch of zeros and I get no useful data. I don't understand this either, but I'm assuming it has something to do with the transceivers. I would really appreciate it if someone could explain why I'm having these two problems!

Comments

  • MoskogMoskog Posts: 554
    edited 2010-08-15 00:22
    Hi

    I highly recommend that you take a look at the progamming examples in the 433 MHz RF Transceiver pdf-documentation:

    http://www.parallax.com/Portals/0/Downloads/docs/prod/rf/27982-433MHzRFTransceiver-v1.1.pdf

    If you still cant figure out how to solve your problems, please tell us!
  • msoccer0607msoccer0607 Posts: 4
    edited 2010-08-15 09:40
    That isn't exactly the same transceiver as i have, but they are very similar. After reading the manual, I still don't understand why my program doesn't work the way i want it to.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-15 09:54
    What transceiver do you have?

    Depending on the transceiver, you might need a "sync" pulse to properly activate the receiver. Also, you might need some error detection and correction. Some transceivers handle this themselves, many do not. Parallax provides sample code. If you can find the webstore page for the product, there's usually a link near the bottom of the page to documentation and sample code.
  • msoccer0607msoccer0607 Posts: 4
    edited 2010-08-15 10:17
    The Parallax part number for the transceivers is 27988. The product has been discontinued though, so I can't find any sample code. The documentation for the transceivers can be found here: http://datasheet.octopart.com/27988-Parallax-datasheet-127786.pdf
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-15 11:04
    I've never seen these modules before, so I can't help you with details. I did look at the documentation you furnished. The modules don't do any error detection or correction. If you're in a noisy RF environment, that may be part of your problem. You might be able to adapt the posted sample code for the current transceivers to work with the older ones.

    In your receive program, you do a SERIN using "distance(counter)". This assumes that "distance" is an array, yet you only declare "distance" as a single byte. PBasic does no checking and will just use the next several bytes as the array. You probably don't want the "(counter)" there.
  • MoskogMoskog Posts: 554
    edited 2010-08-15 13:01
    The datasheet says:

    If you purchased the RF Transceivers (Part#27988) then you can take advantage of this capability to send and
    receive data in a robust, error checking, fashion. The disk or CD that accompanies the RF Transceivers contains
    a number of source code examples for interfacing the RF Transceivers to two BASIC Stamp 2 modules..

    I never seen these RF modules before either, who sold them to you? Do you have this CD? If you don't then somebody here at the forums might still keep it and can help with some source code examples. Or we can wait and see if anyone from Parallax steps in here with some good ideas.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-08-15 13:37
    How about that mode pin, serial or switch (no conn = switch mode)?
    [Switch mode is for reading switch status, Serial mode (conn to +5) is for sending data.]
  • msoccer0607msoccer0607 Posts: 4
    edited 2010-08-15 20:20
    I have the mode pin connected to +5 volts for serial mode. I bought the transceivers on eBay and they didn't come with a CD. If anyone has a copy of the files on the CD and would like to share them I would greatly appreciate it.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-08-15 20:46
    Edit your Subject Title to include the Parallax model number (or p/n). It might stand out better then.
Sign In or Register to comment.