You are currently viewing How to Interface RF433.92MHz with 8051 Evaluation Board

How to Interface RF433.92MHz with 8051 Evaluation Board

Spread the love

This blog post summarize how to interface RF433.92MHz with 8051 Evaluation Board

8051 Evaluation Board

8051 Development board This is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Evaluation Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

RF433.92MHz (Radio Frequency):

Radio Frequency, any frequency within the electromagnetic spectrum associated with radio wave propagation. When  RF current is supplied to an antenna, an electromagnetic field is created that then is able to propagate through space. Many wireless technologies are based on RF field propagation.

RF transmitter:

RF433.92MHz transmitter module connected with 4-bit encoder, user can evaluated RF interface in two ways (Standalone without MCU, user can give inputs through 4-way DIP switchSW35) while making switch SW35 to ON positions inputs low goes to the encoder. Data will transmit through the module. Also provided to configure address lines of the encoder.

RF Receiver:

RF433.92MHz Receiver Module connected with 4-bit decoder, user can evaluated RF signal with the help of LED indications. Whenever receives data through transmitter VT LED, indicates for valid transmission.

Circuit Diagram to Interface RF with 8051

Transmitter Section:

Receiver Section:

Source Code

The Interfacing RF with 8051 program is very simple and straight forward that uses a transmitting and receiving data. In C programs you cannot be sure of delay, because it depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to Interface RF with 8051

#include 
#include 
 
#define DATA P1
 
//Define control pins
sbit RS   = P3^4;                                                     //Register Select
sbit RW   = P3^5;                       //LCD Read/Write
sbit lcd_e = P3^6;                       //LCD Enable
 
sbit EXINT0 = P3^2;
sbit EXINT1 = P3^3;
 
Code unsigned char msg[]   = (" FRINDLY 8051   "); //Display the message
Code unsigned char msg1[] = ("RF 433MHz COMM..");
 
Unsigned char U_N, L_N, Word, Cnt=0;
Unsigned char ch,up,lw;
Unsigned char curs = 0x80;
 
//----------------------------------
//         LCD Functions
//----------------------------------
Void lcd_init(void);
Void lcd_cmd(unsigned char);
Void lcd_display(unsigned char);
Void DelayMs(int);
 
//----------------------------------
//       LCD command Function
//----------------------------------
Void lcd_cmd(unsigned char cmnd)    
{
            DATA = cmnd;
            RS = 0;
            RW = 0;
            lcd_e = 1;
            DelayMs(35);
            lcd_e = 0;
}
 
//----------------------------------
//       LCD Data Function
//----------------------------------
Void lcd_display(unsigned char dat)   
{
            DATA = dat;
            RS = 1;
            RW = 0;
            lcd_e = 1;
            DelayMs(35);
            lcd_e = 0;
}
 
//----------------------------------
//       LCD Delay Function
//----------------------------------
Void DelayMs(int k)          
            {
            unsigned int a;
            for(a=0;a<=k;a++);
            }
 
//----------------------------------
//       LCD Initialization
//----------------------------------
Void lcd_init(void)
{
            Unsigned char i;
           
 lcd_cmd(0x38);                          //2x16 Character 5x7 dot
 DelayMs(15);                             //matrix LCD,8-bit format
  lcd_cmd(0x0c);                         //Display On, cursor off
  DelayMs(15);
  lcd_cmd(0x06);                        //Shift Cursor to right
  DelayMs(15);
  lcd_cmd(0x01);                        //Clear display screen
  DelayMs(15);
 
//-------------------------------------------
//       First Line Message Display
//-------------------------------------------
                        lcd_cmd(0x80);                                          //First Line Initialization
            DelayMs(35);
                        i=0;
                        While (msg[i]!='\0')
                        {
                                    lcd_display(msg[i]);
                                    i++;
                        }
            DelayMs(50);
 
//-------------------------------------------
//       Second Line Message Display
//-------------------------------------------
                        lcd_cmd(0xc0);                                           //Second Line Initialization
                        DelayMs(35);
                        i=0;
                        While (msg1 [i]! ='\0')
                        {
                                    lcd_display(msg1[i]);
                                    i++;
                        }
            DelayMs(50);
}
 
 
Void Serial_Init(void)
{
            TMOD = 0x20;
            SCON = 0x50;
            TH1 = 0xFD;
            TR1 = 1;
            TI         = 1;
}
 
Void Recieve (unsigned char Pos)
{
            if (Pos == 0)
            {
                        L_N = (P2 & 0xF0) >> 4;
                       
            }
            else
            {
                        U_N = (P2 & 0xF0);                      
            }          
}
 
//^^^^^^^^^^^^^^^^^^^^^^^^^^
//Main Program Starts Here
//^^^^^^^^^^^^^^^^^^^^^^^^^^
 
void main(void)
{
           
            P2 = 0xFF;
            Serial_Init();
            lcd_init();
            EA = 1;
            ES = 1;
            EX0 = 1;
            EX1 = 1;
            while (1)
            {
                        if (Cnt == 1)
                        {
                                    lw = 0xF0 | (ch & 0x0F);
                                    up = 0xF0 | ((ch & 0xF0)>>4);
                                    P2 = lw;
                                    DelayMs(220);
                                   
                                    Recieve (0);
                                    P2 = up;
                                    DelayMs(200);                                                                   
                                    Recieve (1);
                                   
                                    Word = U_N | L_N;
                                    SBUF = Word;
                                    if (curs == 0x90)
                                    {
                                                curs = 0xC0;
                                    }
                                    if (curs == 0xD0)
                                    {
                                                curs = 0x80;
                                    }
                                    lcd_cmd(curs++);
                                    lcd_display(Word);
                                    Cnt = 0;
                                    P2 = 0xFF;
                        }
 
            }                      
}
 
//^^^^^^^^^^^^^^^^^^^^^^^^^^
//Serial Interrupt Routine //^^^^^^^^^^^^^^^^^^^^^^^^^^
 
void Serial_Interr (void) interrupt 4
{
            if (RI == 1)
            {
                        ch = SBUF;
                        if (curs == 0x80)
                                    lcd_cmd(0x01);     
                        Cnt = 1;
            }
            RI = 0;
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.