Monday, December 8, 2008

Wireless Data Communication


Last term we were assigned to do a project which involved communication between two microcontrollers through wireless media. The first thought was to make a new protocol which would use only two pins of the microcontroller for serial data communication. The input data placed at one port would be converted into serial data and one pin of another port is used to transmit it. But later we decided that it’d be far better to use a standard protocol because not only it provides better error checking, but it also is easily understood by others, so is ready for future development rather than shooting our mouth off with a new protocol. So we used usart protocol instead which uses RXD(14) & TXD(15) pins.



The project itself was quite simple itself. The only difficult part was to calibrate the baud rate so that the infrared sensors used could securely detect and demodulate the data sent. The cheap IR receiver used failed to detect for baud rate > 1500 bps. We used UBRR=49 which yield BAUD=fosc/(16*(UBRR+1))=1250 bps . Although infrared was used for simplicity, frequency modulation or the use of Bluetooth should be a better option constancy.

Code:
#include
#include
#include

unsigned char USART_Receive( void );
void USART_Transmit( unsigned char data );
void USART_init(void);

unsigned char rx_data;
unsigned char send_data;
void delay_(unsigned int i){
while(i--){
_delay_ms(10);
}
}
ISR(USART_RXC_vect){
rx_data = USART_Receive();
}

unsigned char USART_Receive( void )
{
while ( !(UCSRA & (1< ; return UDR;
}


1 comment:

Anonymous said...

Cool story as for me. It would be great to read more about this topic. The only thing I would like to see here is some pictures of any devices.
David Karver
Cell phone jammer