Shop OBEX P1 Docs P2 Docs Learn Events
Serial communication over RF (radio) — Parallax Forums

Serial communication over RF (radio)

searchsearch Posts: 28
edited 2007-12-27 21:58 in General Discussion
I am trying to figure out how to program one way serial communication using RF (radio) units from Quasar.

The transmitter module is connected to a Basis Stamp 1, and I am using SEROUT 7, T600, ("y") to send the character y when I push a button. Here is the TX module: http://www.quasaruk.co.uk/acatalog/FM_Transmitter_Module.html

The receiver module is connected to a Javelin Stamp. The data pin on the RX is connected directly to the rxUart pin on the Javelin. Here is the RX module: http://www.quasaruk.co.uk/acatalog/FM_Receiver_Module.html

I have a audio radio listening on the RX frequency and there is something transmitted over the air when I push the button, but the rxUart on the Javelin does not receive anything. BUT, if I turn the transmitter off completely, the rxUart starts receiving (random?) data.

I just dont know what to do. Do any of you have any tips for me?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-27 21:05
    Can you post some code?

    regards peter
  • searchsearch Posts: 28
    edited 2007-12-27 21:18
    Here is the source code I have written. bsTX=Basic Stamp+Transmitter jRX=Javelin Stamp+Receiver


    bsTX source:

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    
    ' BS1 TXC V2.1 Card
    
    
    Setup:
      DEBUG "Setup start"
      INPUT   0 ' Button pin
      OUTPUT  6 ' LED pin
    
    
    Main:
      IF PIN0 = 0 THEN SendData ' If button is pressed. Pin0 turns low when button is pressed
      PAUSE 100
    GOTO Main
    
    
    SendData:
      GOSUB FlashLED
      GOSUB SOut
    GOTO Main
    
    
    FlashLED:
      PIN6 = 1    ' LED on
      PAUSE 100
      PIN6 = 0    ' LED off
      PAUSE 100
    RETURN
    
    SOut:
      SEROUT 7, T600, ("y")
      PAUSE 1000
    RETURN
    




    jRX source:
    import stamp.core.*;
    
    public class JavRX2 {
      final static int SERIAL_RX_PIN = CPU.pin0;
    
      static Uart rxUart = new Uart ( Uart.dirReceive, SERIAL_RX_PIN, Uart.invert,
                                    Uart.speed600, Uart.stop1 );
    
      static StringBuffer buffer = new StringBuffer(128);
      static char c;
      static boolean a=true;
    
      static void bufferMessage(){
        c = 0xff;
        while (c != '\r') {
          if (rxUart.byteAvailable()){
            c = (char)rxUart.receiveByte();
            buffer.append(c);
          } // END if
        } // END while
      } // END buffer message
    
      public static void main(){
      System.out.println("Ready");
        do{
          buffer.clear();
          bufferMessage();
          System.out.println("Test");
          c = (char) rxUart.receiveByte();
          System.out.println("Byte received");
        } while (a==true); //(c == 'y' || c != 'n'); // END do
        System.out.println("Goodbye!");
      } // END main
    } // END public class
    
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-27 21:31
    You just send "y" so why do you expect to receive '\r' ???
    BufferMessage can never exit if it does not receive '\r'


    Try this:

    ··public·static·void·main(){
    ··System.out.println("Ready");
    ····do{
    ······//buffer.clear();
    ······//bufferMessage();
    ······//System.out.println("Test");
    ······c·=·(char)·rxUart.receiveByte();
    ······System.out.print(c); //this should display all "y"
    ····}·while·(a==true);·//(c·==·'y'·||·c·!=·'n');·//·END·do
    ····System.out.println("Goodbye!");
    ··}·//·END·main

    Also, are you sure the javelin receives inverted data? Have you tried Uart.dontInvert?

    regards peter
  • searchsearch Posts: 28
    edited 2007-12-27 21:58
    Thanks Peter.

    Your code worked and I am actually receiving the text I am sending over the radio now! smile.gif The System.out.print(c); shows some weird characters instead of what I am sending, but I get the same weird characters every time, so it is actually kind of working. Now I know my hardware is ok.

    I really dont know if the data is inverted or not, but I think it is inverted, because if i choose dontInvert I get different characters on each button push.

    I will work more on my code now.

    thanks again.
Sign In or Register to comment.