rf interfacing with 8051 friendly

14
8051 HOW-TO GUIDE Interface RF433.92MHz with 8051

Upload: srinu589

Post on 27-Oct-2015

366 views

Category:

Documents


3 download

DESCRIPTION

Radio Frequency Signal INterfacing with 8051 related families of microcontrollers

TRANSCRIPT

Page 1: RF Interfacing With 8051 Friendly

8051 HOW-TO GUIDE

Interface RF433.92MHz

with 8051

Page 2: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

Contents at a Glance

8051 Friendly Board ......................................................... 3

RF433.92(Radio Frequency) .. Error! Bookmark not defined.

RF Transmitter ...................... Error! Bookmark not defined.

RF Receiver ........................... Error! Bookmark not defined.

Circuit Diagram to Interface RF with 8051 ........................ 5

Source Code .................................................................... 5

C Program to RF using 8051 ............................................. 7

Page 3: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

8051 Friendly Board

The 8051 Friendly board 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 Friendly 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 an 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.

Page 4: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

Receiver Module Transmitter Module

RF transmitter:

RF433.92MHz transmitter Module conneted 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.

Page 5: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

RF_PSW35

SW DIP-4

750KR51

TX_D3TX_D2

U18

HT-12E

A01

A12

A23

A34

A45

A56

A67

A78

Vss9

D810D911D1012D1113TE14

Vdd18

Dout17

Osc116

Osc215 TX_D1

TX_D0

TX_D0

TX_D2TX_D1

JP

12

TX Module

1 2 3 4

TX_D3

C16 0.1D

Ant

11

D10 LED R49 330E

D11 LED R50 330E

D12 LED R52 330E

D13 LED R53 330E

SW34

SW DIP-8

RF_P

Circuit Diagram to RF with 8051

Transmitter Section:

Page 6: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

RF_P

RF_P

D15 LED R57 330E

RF_P

D16 LED R58 330E

D17 LED R59 330E

D18 LED R60 330E

RX_D0

JP13Rx Module

1 2 3 4 5 6 7 8 9 10

11

12

13

14

15

16

17

DA

TA

IN

DATAIN

U19

HT-12D

A01

A12

A23

A34

A45

A56

A67

A78

Vss9

D810D911D1012D1113DIN14

Vdd18

VT17

Osc116

Osc215

R5633K

R551K

Q5BC547

1

2

3

D14 LEDR54

330E

RX_D1

Ant

11

RX_D2

C17 0.1D

SW36

SW DIP-8

RX_D3

RF_P

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.

Page 7: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

C Program to RF using 8051 ***************************************************************************************

Title : Program to transmitting and receiving data using RF433.92MHz range. ***************************************************************************************

#include <reg51.h> #include <stdio.h> #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);

Page 8: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

//---------------------------------- // 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 //----------------------------------

Page 9: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

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);

Page 10: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

} 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)

Page 11: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

{ 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) {

Page 12: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

ch = SBUF; if (curs == 0x80) lcd_cmd(0x01); Cnt = 1; } RI = 0; }

Page 13: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

Pantech solutions creates information packed technical

documents like this one every month. And our website is a rich

and trusted resource used by a vibrant online community of

more than 1, 00,000 members from organization of all shapes

and sizes.

Did you enjoy the read?

Page 14: RF Interfacing With 8051 Friendly

Join the Technical Community Today!

http://www.pantechsolutions.net

What do we sell?

Our products range from Various Microcontroller

development boards, DSP Boards, FPGA/CPLD boards,

Communication Kits, Power electronics, Basic electronics,

Robotics, Sensors, Electronic components and much more . Our

goal is to make finding the parts and information you need

easier and affordable so you can create awesome projects and

training from Basic to Cutting edge technology.