Shop OBEX P1 Docs P2 Docs Learn Events
Can't get the Javelin and BS1 to communicate with the 433 MHz RF modules — Parallax Forums

Can't get the Javelin and BS1 to communicate with the 433 MHz RF modules

Ahmed BAhmed B Posts: 5
edited 2006-12-04 08:34 in General Discussion
Hi everyone,

For my senior design project, I'm working on an RF-based security system. I'm trying to make a BS1 send back the status of a reed switch over one of the 433 Mhz RF transmitters. I've been starting off by modifying the sample programs from the spec, but I can't get the Javelin to correctly decode the info from the BS1. This is my modified Java Receiver source code, and the BS1 code for the transmitter is right after it:

public class RFmoduleRxTest {

static Uart rxUart = new Uart(Uart.dirReceive, CPU.pin15, Uart.invert, Uart.speed2400, Uart.stop1);
static StringBuffer buffer = new StringBuffer(128);
static byte c;
static byte x=0;
static byte y=0;

static void bufferMessage() {
c=0;
do {
c=(byte)rxUart.receiveByte();
} while(c!=33);
x=(byte)rxUart.receiveByte();
y=(byte)rxUart.receiveByte();
}

public static void main() {
System.out.println("Hi");
while(true) {
buffer.clear();
bufferMessage();
System.out.println(x);
System.out.println(y);
}
}

}



' {$STAMP BS1}
SYMBOL x = W1
SYMBOL y = W2

Start:

PULSOUT 14,300
SEROUT 14, N2400, ("!", B3, B2, B5, B4)
PAUSE 100
x = x + 1
y = y + 1
PAUSE 150

GOTO Start


I luckily have two Javelins and two super carrier boards to play with, so I can get two Javelins to talk to each other, but nothing I do can make the Javelin understand anything coming from the BS1. I've been modifying baud rates and adding delays, but nothing seems to work!

I would greatly appreciate any help anyone could provide; my project is due soon, and I've been stuck on this for the last two weeks.

Thanks!

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-12-03 06:32
    x and y must be int

    public class RFmoduleRxTest {

    static Uart rxUart = new Uart(Uart.dirReceive, CPU.pin15, Uart.invert, Uart.speed2400, Uart.stop1);
    static StringBuffer buffer = new StringBuffer(128);
    static byte c;
    static int x=0;
    static int y=0;

    static void bufferMessage() {
    c=0;
    do {
    · c=(byte)rxUart.receiveByte();
    } while(c!='!');
    x=(byte)rxUart.receiveByte();···· //low byte
    x |= (rxUart.receiveByte()<<8);··//high byte
    y=(byte)rxUart.receiveByte();····//low byte
    y |= (rxUart.receiveByte()<<8); //high byte
    }

    public static void main() {
    System.out.println("Hi");
    while(true) {
    buffer.clear();
    bufferMessage();
    System.out.println(x);
    System.out.println(y);
    }
    }

    }


    ' {$STAMP BS1}
    SYMBOL x = W1
    SYMBOL y = W2
    Start:
    PULSOUT 14,300 'required for RF transmitter
    SEROUT 14, N2400, ("!", B2, B3, B4, B5) 'send low,high,low,high @2400baud true mode
    x = x + 1
    y = y + 1
    PAUSE 250
    GOTO Start


    Edit: just realised the pulsout is required for the RF transmitter
    so the·error·was probably the assembly of the x and y which should be ints
    as in the code above.



    regards peter


    Post Edited (Peter Verkaik) : 12/3/2006 6:45:43 AM GMT
  • Ahmed BAhmed B Posts: 5
    edited 2006-12-03 19:19
    Thanks for the fast response, Peter. I really appreciate it.

    I tried the new code; the Javelin still can't decode the info from the BS1. I've checked the antennas and the BS1's, so I am confident the problem is not hardware-related. I have a feeling that it has something to do with the order in which the Javelin's receiving the data from the BS1 (maybe it's receiving everything in backwards order?)

    This is the output from the message window, which I captured right after resetting the Javelin:

    Hi
    -10
    -66
    14
    14
    15
    15
    -68
    -120
    -2
    -80
    -99
    -40
    -4
    -96
    -25
    -29
    18
    18
    -107
    -6
    19
    19
    -43
    -48
    21
    21


    I have however, been able to get the Javelin to transmit data to the BS1, and the BS1 decodes the info properly. If it provides any insight into the problem, this is how I accomplished it:

    import stamp.core.*;

    public class RFmoduleTxTest {
    static Uart txUart = new Uart (Uart.dirTransmit, CPU.pin14, Uart.invert, Uart.speed2400, Uart.stop1);

    static byte x=0;
    static byte y=0;

    public static void main() {
    while(true) {
    if (x>=10) x=0;
    else x++;
    if (y>=10) y=0;
    else y++;
    /*x++;
    y++;*/
    CPU.pulseOut(300, CPU.pin14);
    txUart.sendString("!");
    txUart.sendByte(x);
    txUart.sendByte(y);
    CPU.delay(3000);
    }
    }
    }

    ' {$STAMP BS1}
    SYMBOL x = W1
    SYMBOL y = W2

    Start:
    SERIN 1, N2400, ("!"), W1,W2
    DEBUG B2, B3, B4, B5 'B2 and B4 contain the low bytes, while B3 and B5 contain the high bytes

    GOTO Start

    Thanks again!
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-12-03 20:59
    I don't see how you can succesfully transmit from javelin to bs1.
    You send 2 bytes with the javelin and the bs1 must receive 2 words,
    which are 4 bytes.

    regards peter
  • Ahmed BAhmed B Posts: 5
    edited 2006-12-04 03:46
    Since the test program was simply sending the numbers 0 through 9, I was not concerned with using both bytes, I was happy enough to see two numbers getting to the BS1. Regardless of this, can anyone think of any other reasons why the Javelin is still refusing to decode the information correctly? Has anyone else can any experiences with the Linx RF modules that they could talk about?

    Thanks for all the help!
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-12-04 08:34
    Lets try single byte values first.

    public class RFmoduleRxTest {

    static Uart rxUart = new Uart(Uart.dirReceive, CPU.pin15, Uart.invert, Uart.speed2400, Uart.stop1);
    static StringBuffer buffer = new StringBuffer(128);
    static int c;
    static int x=0;

    static void bufferMessage() {
    c=0;
    do {
    · c=rxUart.receiveByte();
    } while(c!='!');
    x=rxUart.receiveByte();
    }

    public static void main() {
    System.out.println("Hi");
    while(true) {
    buffer.clear();
    bufferMessage();
    System.out.println(x);
    }
    }

    }


    ' {$STAMP BS1}
    SYMBOL x = B2
    Start:
    PULSOUT 14,300 'required for RF transmitter
    SEROUT 14, N2400, ("!", B2) 'send values 0-255 @2400 baud, invert mode
    x = x + 1
    PAUSE 250
    GOTO Start

    The javelin should print
    0
    1
    2
    ...
    255
    0
    1
    etc.

    regards peter
Sign In or Register to comment.