Serial Communication over RF Transceivers(Using Atmega32u4)

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello folks, need help again, I am using an Atmega32u4 and 2 UHF data transceiver(http://www.e-gizmo.com/KIT/images/uhfdatatranciever/5812A%20Tech%20Manual.pdf.

I am trying to transmit data from Atmega32u4 to one of this transceiver then to another transceiver serves as the receiver, connected to PC. When I tried to view my result, used the terminal program(Terminal V.1.9b),I got nothing. When I tried to connect the Atmega 32u4 directly to PC, I got the expected output. My set-up is attached.


https://www.avrfreaks.net/modules/PNphpBB2/files/circuit_diagram_175.jpg

I already check the properties. My thoughts is that the problem is in the set-up or in my code. My mentor said that I dont have to load a program on the receiver anymore. Here is my code to my Atmega.

#define F_CPU 16000000UL
#define BAUDRATE 9600
#define BAUD_PRESCALLER (((F_CPU / (BAUDRATE * 16UL))) - 1)


#include 
#include 


//Declaration of functions
void USART_init(void);
unsigned char USART_receive(void);
void USART_send(unsigned char data);
void USART_putstring(char* StringPtr);

/*message arrays*/

char msg1[] = {"The water is in level 1."};
char msg2[] = {"The water is in level 2."};
char msg3[] = {"The water is in level 3."};
char msg4[] = {"The water is in level 4."};
char msg5[] = {"No switch is on/Error!"};

int main(void)
{
	DDRB = 0x00; /*set PortB as input*/
	PORTB = 0x00;
	USART_init();
	
    while(1) //Infinite loop
    {
		
		
		
		if (PINB & 0x08)   {
		USART_putstring(msg4);	
		_delay_ms(5000);}
		
		else if (PINB & 0x04) {
		USART_putstring(msg3);
		_delay_ms(5000);  }
		
		else if (PINB & 0x02) {
		USART_putstring(msg2);	
		_delay_ms(5000); }
		
		else if (PINB & 0x01) {
		USART_putstring(msg1);	
		_delay_ms(5000);  }
		
		else  {
		USART_putstring(msg5);
		_delay_ms(5000);  }		
		
    }
	
}

void USART_send(unsigned char data){
	
	while(!(UCSR1A & (1<<UDRE1)));
	UDR1 = data;
}

void USART_putstring(char* StringPtr){
	
	while(*StringPtr != 0x00){
		USART_send(*StringPtr);
	StringPtr++;}
	
}

void USART_init(void){
	UBRR1H = (uint8_t)(BAUD_PRESCALLER >> 8);
	UBRR1L = (uint8_t)(BAUD_PRESCALLER);
	UCSR1B = (1 << TXEN1) | (1 << RXEN1);
	UCSR1C = (1 << UCSZ11) | (1 << UCSZ10);
}

unsigned char USART_receive(void){
	while(!(UCSR1A & (1<<RXC1)));
	return UDR1;
}

Any help why I cant received data using the transceiver? or my set-up is incorrect?
Thank you in advanced.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Eliminating the radio transmitters and keeping everything else makes it work so I can not only think that's the issue. Either the radio link is failing or the rx to PC link is failing.

Do you have antennae installed on the boards?
Do you see D2 flashing on the receiver?

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes..I have antenna installed on the 2 transceivers. I cannot see D2 blinking, so it might be the transmitter part that cannot send?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why didn't you try Clancy's idea of removing the transmitter and using a terminal program on the PC to test your USART code?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I already tried to connect my AVR directly to PC, using Terminal program and it works fine...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sorry, I missed that sentence in your OP. Does the transceiver have status cmds that you can send it and listen for their response? I'd contact the company if the boards aren't responding and see what insights ( or refund/exchange ! ) they may have.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Couple dumb questions ;)

You made the antennae out of 18 gauge 24cm solid core wire?
You have the crystals populated?

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yeah... all was set correctly... I am wondering if it depends on the way I received the data...the way I did it is I think a pooling type.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It uses SPI I/F for control and have you verified they can talk correctly to each other and it's configured how you want it ( MCU's SPI must be in correct SPI mode ) ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It doesn't use SPI for communcation. It does use SPI internally between the radio chip and uC, but for communication with the target system, it uses UART, which Jeffrey has set up.

Clancy _________________ Step 1: RTFM Step 2: RTFF (Forums) Step 3: RTFG (Google) Step 4: Post

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yeah,,you're right, the transceiver use SPI internally between the radio chip and the uC. I already to make the 2 transceiver to communicate, so I set it that whatever I transmit, it is what I should receive, but I did not receive any. Also, the receive led should blink when the power is on and it didn't.