Help with a basic RF link

I recently bought a wireless [reciever and [transmitter. I’ve got one Atmega168 constantly sending ‘a’ over the transmitter, and another one with the receiver that should be receiving the bit and printing it to the terminal screen. The problem is that nothing happens when I turn the microcontrollers on. But when I turn the transmitter off and on a bunch of gibberish gets printed to the screen, which makes me think that there is some kind of connection between the transmitter/receiver. Can anyone think of what the problem might be? They’re running at 4800bps.

Thanks!

Here’s my code… Transmitter:

#include <stdio.h>
#include <avr/io.h>

#define FOSC 8000000
#define BAUD 4800
#define MYUBRR FOSC/16/BAUD-1

#define sbi(var, mask)   ((var) |= (uint8_t)(1 << mask))
#define cbi(var, mask)   ((var) &= (uint8_t)~(1 << mask))

void ioinit(void);
static int uart_putchar(char c, FILE *stream);
uint8_t uart_getchar(void);

static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

void delay_ms(uint16_t x);

int main(void)
{
	ioinit ();
	int i = 0;
	
	while (1) {
		printf ("a");
	}
	return 0;
}

/**
 * Initalizes basic input/output on ports and serial communications
 */

void ioinit (void)
{
    //1 = output, 0 = input
    DDRB = 0b11111111; //
    DDRC = 0b11111111; //
    DDRD = 0b11111110; //PORTD (RX on PD0)

    //USART Baud rate: 9600
    UBRR0H = MYUBRR >> 8;
    UBRR0L = MYUBRR;
    UCSR0C = (3 << UCSZ00);
    UCSR0B = (1<<RXEN0)|(1<<TXEN0);
    
    stdout = &mystdout; //Required for printf init
}

/**
 * Prints a character to the serial stream
 */

static int uart_putchar(char c, FILE *stream)
{
    if (c == '\n') uart_putchar('\r', stream);
  
    loop_until_bit_is_set(UCSR0A, UDRE0);
    UDR0 = c;
    
    return 0;
}

/**
 * Reads a character from the serial stream
 */

uint8_t uart_getchar(void)
{
    while( !(UCSR0A & (1<<RXC0)) );
    return(UDR0);
}

/**
 * General delay.  Probably not actually delaying for x number of millisecs, but whatever.
 */

void delay_ms(uint16_t x)
{
  uint8_t y, z;
  for ( ; x > 0 ; x--){
    for ( y = 0 ; y < 90 ; y++){
      for ( z = 0 ; z < 6 ; z++){
        asm volatile ("nop");
      }
    }
  }
}

Receiver:

#include <stdio.h>
#include <avr/io.h>

#define FOSC 8000000
#define BAUD 4800
#define MYUBRR FOSC/16/BAUD-1

#define sbi(var, mask)   ((var) |= (uint8_t)(1 << mask))
#define cbi(var, mask)   ((var) &= (uint8_t)~(1 << mask))

void ioinit(void);     
static int uart_putchar(char c, FILE *stream);
uint8_t uart_getchar(void);

static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

void delay_ms(uint16_t x);

int main(void)
{
	ioinit ();
	int i = 0;
	int handshake_count;
	char in_char;
	
	while (1) {
		in_char = uart_getchar ();
		printf ("%c", in_char);
	}
	return 0;
}

/**
 * Initalizes basic input/output on ports and serial communications
 */

void ioinit (void)
{
    //1 = output, 0 = input
    DDRB = 0b11111111; //
    DDRC = 0b11111111; //
    DDRD = 0b11111110; //PORTD (RX on PD0)

    //USART Baud rate: 9600
    UBRR0H = MYUBRR >> 8;
    UBRR0L = MYUBRR;
    UCSR0C = (3 << UCSZ00);
    UCSR0B = (1<<RXEN0)|(1<<TXEN0);
    
    stdout = &mystdout; //Required for printf init
}

/**
 * Prints a character to the serial stream
 */

static int uart_putchar(char c, FILE *stream)
{
    if (c == '\n') uart_putchar('\r', stream);
  
    loop_until_bit_is_set(UCSR0A, UDRE0);
    UDR0 = c;
    
    return 0;
}

/**
 * Reads a character from the serial stream
 */

uint8_t uart_getchar(void)
{
    while( !(UCSR0A & (1<<RXC0)) );
    return(UDR0);
}

/**
 * General delay.  Probably not actually delaying for x number of millisecs, but whatever.
 */

void delay_ms(uint16_t x)
{
  uint8_t y, z;
  for ( ; x > 0 ; x--){
    for ( y = 0 ; y < 90 ; y++){
      for ( z = 0 ; z < 6 ; z++){
        asm volatile ("nop");
      }
    }
  }
}

](RF Link Transmitter - 434MHz - WRL-08946 - SparkFun Electronics)](RF Link 4800bps Receiver - 434MHz - WRL-08950 - SparkFun Electronics)

Lots of examples of how to do this are out there.

http://winavr.scienceprog.com/example-a … llers.html

Also, with the radios out of the picture, have you gotten the sending and receiving microprocessors to “talk” with direct-connect?

Yeah I’ve seen that link, thanks. That’s how I have everything wired up and nothing happens. When I connect the RX to the TX of each Atmega, and vice versa, they communicate successively with the same code as above.

I’ve also tried it at 2400 bps and that doesn’t do anything either.

You probably need to use Manchester code.

Err, could you point me to a page that would show me how to do that?

e: And if the wireless receiver was working but just not getting the stuff the transmitter sent, shouldn’t I at least be getting static? I don’t even get static, I just get nothing.

http://en.wikipedia.org/wiki/Manchester_code

I’d have thought that you’d be receiving something when the transmitter is sending data, though, even if it didn’t make any sense.

Right, and when I hook the receiver directly to the the Max3232 IC it doesn’t output anything either so I don’t think the receiver is getting any data at all.

I found this posted on the product page:

If that can help some people…

I buy this to use with a pic18f from microchip with a mikroe board, after one week, i go to be crazy because i get nothing out of the data pin.

I found the right doc and I read that the high level is 0.7*Vdd so ~3.5V → 1 and 0V → 0, but the pic don’t get it at this level.

So I have to put one transistor command with the output data pin and powered with 5V.

And with that it’s working !! UART don’t work good with my case, so i use Manchester coding ( I think it is best ), and no problem now !

http://www.8051projects.net/e107_files/ … 433mhz.pdf

http://www.8051projects.net/e107_files/ … 433mhz.pdf

Is he just saying that he didn’t get anything when it was getting 3.5 V, so he gave it 5 V and it worked?

No. He was using a PIC with a low voltage supply, and needed to use a transistor to provide a higher voltage to the transmitter input. If you are powering your MCU from 5V you should be OK. Note that he was using Manchester code.

Yeah, I got that. The problem is I’m not getting anything from the receiver, and I don’t see how using Manchester code will change that.

I’d listen to the transmitter on another receiver to make sure that it was working properly, I’ve got a couple of amateur radio transceivers with wide-band receive.

I’m afraid I don’t have any other receivers. Is there anyway I could use something like a household radio to test it?

That won’t work unless you design and build a suitable down-converter. You could make a simple RF detector with a dipole antenna and Shottky diode, with a micro-ammeter. Alternatively, buying another transmitter and receiver could help. You might have damaged something.

Well unfortunately I don’t have any of that stuff either.

Do you think the the transmitter or receiver is broken so I should get a new one, or I’m just doing something wrong so I should keep at it?

If it helps, I can post a schematic or picture of my current setup.

It might help. I’ve not used those modules but I, or someone else, might notice something.

Transmitter:

[<LINK_TEXT text=“http://img682.imageshack.us/img682/8467 … ter.th.jpg”>http://img682.imageshack.us/img682/8467/transmitter.th.jpg</LINK_TEXT>

Receiver:

[

The receiver is going directly into the Max3232, which is why I didn’t take a picture of the rest of that breadboard (there’s also a lot of other wires for my H bridge and the programmer so I figured it’d be easier to look at like this).

The schematic is the same as the one [here, except with Atmega168s instead of Atmega8s, no antennas, and no crystals.

Again, thanks very much for the help.](http://winavr.scienceprog.com/example-avr-projects/running-tx433-and-rx433-rf-modules-with-avr-microcontrollers.html)](ImageShack - Best place for all of your image hosting and image sharing needs)](http://img682.imageshack.us/i/transmitter.jpg/)

Have you tested a wired link by connecting the uController to the PC (with the MAX232). Be sure this works first.

Yeah, that does work.

Yes0:
Yeah, that does work.

Ok, then Leon's suggestions on testing whether the transmitter is really transmitting is next.