RF Tx/Rx units - any fault finding advice?

All things pertaining to wireless and RF links

Moderator: phalanx

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

RF Tx/Rx units - any fault finding advice?

Post by callagga » Sun Jun 20, 2010 4:57 am

Hi,

Background - I've just a pair of low cost RF Transmitter & Receiver (http://www.sparkfun.com/commerce/produc ... ts_id=8946, and http://www.sparkfun.com/commerce/produc ... ts_id=8950

Issue - I've set them up for the test program (see code below), however I'm not seeing any response from the receiving Arduino.  I note that when I put a multimeter on the transmitter the +ve voltage on VCC is OK, and when I look at teh DATA line I see it stays at around VCC voltage but the needle moves a little every second, so it seems as if it getting the transmit signal ok.  I don't have antenna wires on them, but they are only a few centimeters apart so this should be ok no?

Question - Any advice on how to trouble shoot in this situation?  I only order one of each of the units.  

Transmitter Code

Code: Select all

/* * Simple Transmitter Code 
* (TX out of Arduino is Digital Pin 1) 
* (RX into Arduino is Digital Pin 0) */

byte counter;

void setup(){ 
	//2400 baud for the 434 model 
        //Serial.println("setup");
	Serial.begin(4800); 
	counter = 0;
} 

void loop(){
	//send out to transmitter 
        digitalWrite(13, HIGH); // Flash a light to show transmitting
	Serial.print(counter); 
	counter++;
        delay(50);
        digitalWrite(13, LOW);
	delay(1000);
}

Receiver Code

Code: Select all

/* * Simple Receiver Code 
* (TX out of Arduino is Digital Pin 1) 
* (RX into Arduino is Digital Pin 0) */

int incomingByte = 0;

void setup() { 
  //2400 baud for the 434 model
  Serial.begin(4800);
  //Serial.println("setup");
} 

void loop(){
	// read in values, debug to computer 
	if (Serial.available() > 0) {
                digitalWrite(13, HIGH); // Flash a light to show receiving
		incomingByte = Serial.read(); 
		Serial.println(incomingByte, DEC);
                digitalWrite(13, LOW);
	} 
	incomingByte = 0; 
}
thanks

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: RF Tx/Rx units - any fault finding advice?

Post by waltr » Sun Jun 20, 2010 6:55 am

These are OOK transmitter/receivers. What does the receiver output look like on an O'scope?

Try bit-banging a 1200Hz waveform into the transmitter and see if it shows up at the receiver. Don't use serail tranfer functions yet. Just poll the input pin to detect the square wave.
Then read up on how to use OOK modulation for serial data.

stevech
Support Volunteer
Posts: 2907
Joined: Sat Jun 05, 2004 8:51 pm
Location: USA, California

Re: RF Tx/Rx units - any fault finding advice?

Post by stevech » Sun Jun 20, 2010 10:55 am

OOK receivers need a preamble to set the data slicer threshold (integrator), that being a long string of 1010101... then in the data, code it so that long strings of all 1's or 0's cannot occur. Manchester coding, or byte table lookups.

Or simplify, use Digi XBee series on modules from SFE. More costly, but plug and play.

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Sun Jun 20, 2010 4:17 pm

stevech wrote:OOK receivers need a preamble to set the data slicer threshold (integrator), that being a long string of 1010101... then in the data, code it so that long strings of all 1's or 0's cannot occur. Manchester coding, or byte table lookups.
thanks - can I ask:
a) but the code I've posted should work though correct?
b) re "need a preamble" - are you saying the receiver won't actually work without this? My understanding of these tx/rx pair that the receive line (on/off) should just reflect the transmitter (on/off), so if fact the preamble would be more to do with the arduino's serial operations expectation then? i.e. not to do with the transmitter itself

PS. I don't have a CRO :(

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: RF Tx/Rx units - any fault finding advice?

Post by waltr » Sun Jun 20, 2010 5:51 pm

Yes, to actually pass data the Preamble is mandatory with OOK modulation.
No, the code you posted will not work with OOK. Although with some modification it may work part of the time. You can try sending data that keeps changing the level of the bits as Steve suggested. The letter 'U' is ASCII is 0x55 and a good one to use. Change the code to send this a 100 times without any breaks or delays between characters. The Receiver and receive code should be able detect these.
This will prove that the RF units work. Then look up the info that Steve suggested.

Also, search through the threads here as the problem has been discussed and solutions presented a number of times.
There is a real reason why OOK RF units are so cheap. You pay by added complexity of the interface and supporting code.

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Sun Jun 20, 2010 5:55 pm

oh - I'm just wondering then how does this correlate with the code I'm trying which is actually based on the test program that is referenced from the vendor site? That is the specific doco with code:

http://www.sparkfun.com/datasheets/RF/K ... hrough.pdf

which is referenced from

http://www.sparkfun.com/commerce/produc ... ts_id=8946

60amp_relay
Posts: 44
Joined: Fri Feb 26, 2010 12:12 pm

Re: RF Tx/Rx units - any fault finding advice?

Post by 60amp_relay » Sun Jun 20, 2010 5:56 pm

This is something that trips up a lot of people. You need to have a low->high or high->low transition on the transmitter's data line at least once every 30ms or so. If you simply output a constant "1" on the transmitter, you'll get 30ms of "1" on the receiver and then a stream of garbage. In your program, when you delay(50), the receiver loses sync with the transmitter. Ditto for delay(1000).

About the baud rate: I use these units at 600 or 1200 baud - so far I've never gotten reliable data transmission at 4800 baud. But 600 baud works great (works fine at 50+ feet in my testing)

In your code, try setting the baud rate to 600 and removing all the delay()s so that you're constantly outputting data. With any luck, the receiving end should be able to pick up something.

Incidentally, a good starting point is to just constantly output the char "U" and see if you can read a "U" on the receiving end.

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Sun Jun 20, 2010 6:29 pm

ok - thanks (will try this tonight) - the reason I went to 4800 baud was I saw only this mentioned for the receiver at http://www.sparkfun.com/commerce/produc ... ts_id=8950, but perhaps this was just the max then?

Also I was going to use VirtualWire but it didn't seem to work after hooking things up, so I thought I'd try the simpler test. http://www.open.com.au/mikem/arduino/VirtualWire.pdf. The code I had was:

Transmitter

Code: Select all

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);   // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    //vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);      // Bits per sec
}

void loop()
{
    const char *msg = "hello";

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}
Receiver

Code: Select all

#include <VirtualWire.h>

void setup()
{
    Serial.begin(9600); // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    //vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);      // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
        int i;

        digitalWrite(13, true); // Flash a light to show received good message
        // Message with a good checksum received, dump it.
        Serial.print("Got: ");

        for (i = 0; i < buflen; i++)
        {
            Serial.print(buf[i], HEX);
            Serial.print(" ");
        }
        Serial.println("");
        digitalWrite(13, false);
    }
}

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Sun Jun 20, 2010 11:37 pm

PS another piece of advice I got from another forum was:

Connect the transmitter input to a pull-down resistor (5-10k should be fine) and use a button (or just touch a wire) to pull it up to the transmitter power. Connect the receiver output to a transistor switch and an LED, the same way you would do with n Arduino digital output pin. You should be able to turn the receiver LED on and off by taking the transmitter pin high and low.

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Mon Jun 21, 2010 3:09 am

Just tried removing delays, sending the "U" constantly, and setting to 600 baud rate (Serial.begin(600);) - but still can't receive anything.

Then I tried the no-Arduino test. Just applied (based on a button push) either 0V or 5V to the transmitter input. However at the receiver I don't see any change when I push the transmitter button. The receiver data pin just shows a constant 2V (where VCC = 4V for the receive). Does this imply do you think one of the devices is faulty? I'm assuming on the receiver that where it's got multiple 5V, GND pins etc, that I only have to connect one correct? (i.e. I don't have to hook up 5V inputs to the two +5V pins of the receiver)

EDIT - Actually I just connected an LED on the receiver directly from GND to DATA. I also took the LED out and just measured voltage on the receiving DATA pin and it sits at VCC (=4V) and doesn't change when I push the button on transmitter to toggle input voltage on it's data line.

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: RF Tx/Rx units - any fault finding advice?

Post by waltr » Mon Jun 21, 2010 6:31 am

I'm assuming on the receiver that where it's got multiple 5V, GND pins etc, that I only have to connect one correct? (i.e. I don't have to hook up 5V inputs to the two +5V pins of the receiver)
That is a bad assumption unless you know for certian that all of the common pins are connected together on the board. An Ohm meter would confirm whether they are or or not. My guess is that they are not.

60amp_relay
Posts: 44
Joined: Fri Feb 26, 2010 12:12 pm

Re: RF Tx/Rx units - any fault finding advice?

Post by 60amp_relay » Mon Jun 21, 2010 7:02 pm

How come you're using +4V to power the receiver? The (admittedly shoddy) datasheet says +4.5V is the bare minimum on Vcc, with +5V recommended.

You can use the unit with only one Vcc, Gnd, and Data pin connected. It's OK to leave the others disconnected, it still works fine. But the range is only a few feet if you don't hook up an antenna.

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Mon Jun 21, 2010 7:27 pm

I'm using the Arduino Pro 328 - 5V/16MHz http://www.littlebirdelectronics.com/pr ... 16MHz.html

It says on the web site it's a 5V Arduino, however I'm only seeing 4V at the VCC terminal? However it is just plugged into the USB port on my Mac....perhaps I need to get the power adaptor before it will produce 5V? (will try at home tonight)

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Tue Jun 22, 2010 4:43 am

Update: I'm still not able to receive serial data on the receiver HOWEVER I have managed to prove to myself that the receiver is receiving something from the transmitter.

When I connect an LED to the DATA pin of the transmitter and the other end to earth, I see the LED flickering, fairly soft (never hard on). I can adjust the timing of the transmitter with the delay() (i.e. put it back in for a bit) and I can see that the flickering on this LED on the receiver matches the timing of when the transmitter is sending.

When I connect the DATA pin up to PIN 0 of the receiver Arduino board however I note that:
(a) I still get no output in the Arduino serial monitor, i.e. when I click on "serial monitor", nor see the pin 13 on board LED flash
(b) I also not that the LED in the chain (Rx_Data_Pin => LED & Arduino Rx Pin 0) that the LED go full on with no flickering when I connect the Rx_Data_Pin to the Arduino Rx Pin 0 too? Is this an issue? Should the LED effectively from the Arduino Rx Pin 0 to GND still not keep flickering just as it was?

Any other ideas? Should I try bringing the RF Rx receiver signal into a normal Arduino input pin and monitor for a change in this and flash a LED if it changes, just to prove the RF Rx is picking up true on/off signals? (as opposed to just letting the RF Rx output com into the Arduino pin 0 Rx)

thanks

PS Receiver code again is:

Code: Select all

int incomingByte = 0;

void setup() { 
  Serial.begin(600);
} 

void loop(){
	if (Serial.available() > 0) {
		    digitalWrite(13, HIGH); // Flash a light to show receiving
		incomingByte = Serial.read(); 
		Serial.println(incomingByte, DEC);
		    digitalWrite(13, LOW);
	} 
	incomingByte = 0; 
}
Transmitter

Code: Select all

byte counter;

void setup(){ 
	//2400 baud for the 434 model 
        //Serial.println("setup");
	Serial.begin(600); 
	counter = 0;
} 

void loop(){
	//send out to transmitter 
        digitalWrite(13, HIGH); // Flash a light to show transmitting
        Serial.print("U"); 
	counter++;
        digitalWrite(13, LOW);
	//delay(10);
}

callagga
Posts: 21
Joined: Sun Jun 20, 2010 4:55 am

Re: RF Tx/Rx units - any fault finding advice?

Post by callagga » Tue Jun 22, 2010 5:24 am

PS I've been leaving my USB connections (two, one for each arduino) from my Macbook USB ports connected during testing. Is this ok? Doesn't pose any issues with my attempted use of the pin 1 and pin 0 serial communications?

Post Reply