4 Channel Rf Remote Control Device

119
CONTENTS PAGE NO.s Abstract I List of Figures II Symbols & Abbreviations III Chapter 1. Introduction 1.1 Overview 1 1.2 Classification of digital Watermarking 7 1.3 Applications of Wavelet Transformations 8 1.4 Attacks 10 1.5 Image Performance Measures 14 Chapter 2. Discrete Wavelet Transform 1.6 Functions of Discrete Wavelet Transforms 20 1.7 The Continuous Wavelet Transforms and Wavelet Series 21 1.8 Discrete Wavelet Transformations 22 1.9 DWT and Filter Banks 23 1.10 Wavelet Families 26 Chapter 3. Proposed Algorithm 1.11 Watermark Embedding 28 1.12 Watermark Extraction 31 1.13 Program Code 32 Chapter 4. Results 1.14 PSNR and NCC 46

description

Electricity plays an important role in our everyday life. A lot of emphasis is placed on power save as the demand is high and the production is low for it.We use electricity at our homes and offices for several purposes including lighting, fans, and electrical appliances so on. If we consider an example at our homes, for lighting, we turn the switches on at dusk at several places. Some of the lights are intended to be switched off after some time, for instance veranda. But due to laziness, we ignore it and switch them off only at late night. We would like to design and develop a system so that the electrical switches work remotely. A person doesn’t need to reach the physical location of the switch; they can accomplish the task remotely. i.e. a light switch in veranda can be controlled from the bed room itself. The application for this type of system is numerous and is limited to only one’s imagination. Upon completion of this project we expect to get good knowledge on circuit design, development and troubleshooting techniques. We intend to use micro controller and RF modules in the system so that we gain knowledge on building a system around these core components. Finally, we will get good embedded system knowledge as well.

Transcript of 4 Channel Rf Remote Control Device

Page 1: 4 Channel Rf Remote Control Device

CONTENTS PAGE NO.s

Abstract I List of Figures IISymbols & Abbreviations III

Chapter 1. Introduction 1.1 Overview 1 1.2 Classification of digital Watermarking 71.3 Applications of Wavelet Transformations 81.4 Attacks 101.5 Image Performance Measures 14

Chapter 2. Discrete Wavelet Transform1.6 Functions of Discrete Wavelet Transforms 201.7 The Continuous Wavelet Transforms and Wavelet Series 211.8 Discrete Wavelet Transformations 221.9 DWT and Filter Banks 23 1.10 Wavelet Families 26

Chapter 3. Proposed Algorithm1.11 Watermark Embedding 281.12 Watermark Extraction 31

1.13 Program Code 32

Chapter 4. Results1.14 PSNR and NCC 46 1.15 Results for Attacks 49

Chapter 5. GUI

1.16 Embedding 531.17 Attacks 541.18 Extracting 55

Chapter 6. Conclusion 56Chapter 7. References 57

Page 2: 4 Channel Rf Remote Control Device

Abbreviations

Symbol Name

ACC Accumulator

B B register

PSW Program status word

SP Stack pointer

DPTR Data pointer 2 bytes

DPL Low byte

DPH High byte

P0 Port0

P1 Port1

P2 Port2

P3 Port3

IP Interrupt priority control

IE Interrupt enable control

TMOD Timer/counter mode control

TCON Timer/counter control

T2CON Timer/counter 2 control

T2MOD Timer/counter mode2 control

TH0 Timer/counter 0high byte

TL0 Timer/counter 0 low byte

Page 3: 4 Channel Rf Remote Control Device

TH1 Timer/counter 1 high byte

TL1 Timer/counter 1 low byte

TH2 Timer/counter 2 high byte

TL2 Timer/counter 2 low byte

SCON Serial control

SBUF Serial data buffer

MAX MAXIM (IC manufacturer )

TTL Transistor to Transistor Logic

ATM Automatic Teller Machine

RS 232 Recommended Standard

AC Alternating Current

DC Direct Current

LCD Liquid Crystal Display

PC Personal Computer

RPS Regulated Power Supply

RMS Root Mean Square

EEPROM Electrically Erasable Programmable ROM

ROM Read Only Memory

RAM Random Access Memory

BIOS Basic Input Output System

Page 4: 4 Channel Rf Remote Control Device

SRAM Static RAM

EPROM Erasable Programmable ROM

DRAM Dynamic Random Access Memory

ISR Interrupt Service Routine

ICCIntegrated Circuit Chip

CAD Card Acceptance Device

IFD Interface Device

IDE Integrated Development Environment

ABSTRACT

Page 5: 4 Channel Rf Remote Control Device

Electricity plays an important role in our everyday life. A lot of emphasis is placed on power save

as the demand is high and the production is low for it.

We use electricity at our homes and offices for several purposes including lighting, fans, and

electrical appliances so on. If we consider an example at our homes, for lighting, we turn the

switches on at dusk at several places. Some of the lights are intended to be switched off after

some time, for instance veranda. But due to laziness, we ignore it and switch them off only at late

night. We would like to design and develop a system so that the electrical switches work

remotely. A person doesn’t need to reach the physical location of the switch; they can accomplish

the task remotely. i.e. a light switch in veranda can be controlled from the bed room itself. The

application for this type of system is numerous and is limited to only one’s imagination. Upon

completion of this project we expect to get good knowledge on circuit design, development and

troubleshooting techniques. We intend to use micro controller and RF modules in the system so

that we gain knowledge on building a system around these core components. Finally, we will get

good embedded system knowledge as well.

The block diagram for 4 channel RF controlled remote operated device is shown in the above

figure, in system level. The 230V ac is rectified, the regulator provides a constant 5V DC which

is required for the Micro controller and control circuit.

Based on the input from the switch the micro controller transmits and receives the data through

RF modules and controls the switch operation accordingly

Page 6: 4 Channel Rf Remote Control Device

1.INTRODUCTION

1.1EMBEDDED SYSTEM:

An embedded system is a special-purpose system in which the computer is

completely encapsulated by or dedicated to the device or system it controls. Unlike a general-

purpose computer, such as a personal computer, an embedded system performs one or a few

predefined tasks, usually with very specific requirements. Since the system is dedicated to

specific tasks, design engineers can optimize it, reducing the size and cost of the product.

Embedded systems are often mass-produced, benefiting from economies of scale.

Personal digital assistants (PDAs) or handheld computers are generally considered

embedded devices because of the nature of their hardware design, even though they are more

expandable in software terms. This line of definition continues to blur as devices expand. With

the introduction of the OQO Model 2 with the Windows XP operating system and ports such as a

USB port — both features usually belong to "general purpose computers", — the line of

nomenclature blurs even more.

Physically, embedded systems ranges from portable devices such as digital watches and

MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems

controlling nuclear power plants terms of complexity embedded systems can range from very

simple with a single microcontroller chip, to very complex with multiple units, peripherals and

networks mounted inside a large chassis or enclosure.

1.2Wireless communication:

Going wireless always starts with a basic RF communication, using serial encoders and decoders.

This process and methodology is easily understandable if you are new to this subject. Wireless

communication is the transfer of information between two or more points that are not connected

FIG :- EMBEDDED SYSTEM

Page 7: 4 Channel Rf Remote Control Device

by an electrical conductor. The most common wireless technologies use electromagnetic

wireless telecommunications, such as radio. With radio waves distances can be short, such as a

few meters for television remote control, or as far as thousands or even millions of kilometers for

deep-space radio communications. It encompasses various types of fixed, mobile, and portable

applications, including two-way radios, cellular telephones, personal digital assistants (PDAs),

and wireless networking. Other examples of applications of radio wireless

technology include GPS units, garage door openers, wireless computer

mice, keyboards and headsets, headphones, radio receivers, satellite, broadcast

television and cordless telephones.

Wireless operations permit services, such as long-range communications, that are impossible or

impractical to implement with the use of wires. The term is commonly used in the

telecommunications industry to refer to telecommunications systems (e.g. radio transmitters and

receivers, remote controls etc.) which use some form of energy (e.g. radio waves, acoustic

energy, etc.) to transfer information without the use of wires.  Information is transferred in this

manner over both short and long distances

One of the best-known examples of wireless technology is the mobile phone, also known as a

cellular phone, with more than 4.6 billion mobile cellular subscriptions worldwide as of the end

of 2010.These wireless phones use radio waves to enable their users to make phone calls from

many locations worldwide. They can be used within range of the mobile telephone site used to

house the equipment required to transmit and receive the radio signals from these instruments.

Page 8: 4 Channel Rf Remote Control Device

2. BLOCK DIAGRAM

1.3Block diagram description:

A general RF communication block diagram is shown above. Since most of the

encoders/decoders/microcontrollers are TTL compatible, most of the inputs by the user will be

given in TTL logic level. Thus, this TTL input is to be converted into serial data input using an

encoder or a microcontroller. This serial data can be directly read using the RF Transmitter,

which then performs ASK (in some cases FSK) modulation on it and transmit the data through

the antenna. In the receiver side, the RF Receiver receives the modulated signal through the

antenna, performs all kinds of processing, filtering, demodulation, etc and gives out a serial data.

This serial data is then converted to a TTL level logic data, which is the same data that the user

has input. So now, let’s look into the hardware that are required.

FIG: - RF COMMUNICATION BLOCK DIAGRAM

Page 9: 4 Channel Rf Remote Control Device

3. SCHEMATICS

1.4 Transmitter Section:

Make the following circuit on a breadboard. You are requested to implement the following circuit

at your own risk! We will NOT be responsible for any damages caused due to implementation of

the circuit, physically, mentally or financially.

Schematic explanation:-

Here, we have used four switches S1, S2, S3 and S4 to give 4-bit parallel data (D0-D3). Since the

switches are in active low state (i.e. low signal is sent when the switch is pressed), we need to add

external pull-up resistors as shown, so as to provide a high signal by default. A resistance as high

as 1Mohm is required in between OSC1 and OSC2 pins. The Transmitter Enable (TE, pin 14) pin

is an active low pin. Thus, it is permanently grounded, so as to enable  the transistor always. The

output serial data DOUT is fed to the RF Transmitter Module directly.

The most important thing lies in the address pins (A0-A7, pin1-8). Suppose you have two

wireless devices (A and B) in your house, both have different remote controls (AA and BB) and

both implement the same type of RF module (say 433 MHz). AA is the remote control of A and

Fig: - Transmitter interfacing

Page 10: 4 Channel Rf Remote Control Device

BB is of B. Now, you obviously wouldn’t want AA to control B (which is the most probable case

since both the devices use same kind of RF module, having same frequency!).  This is where

address pins come into play. There are 8 address pins, thus giving you an opportunity to have 8!

(8 factorial) different and independent ways to connect to a device, so that there is no

interference. The address pins must have the same address in both transmitter and receiver, or

else the data won’t be transferred.

1.5 Receiver section

Schematic explanation:-

The circuit of the receiver is also quite simple. Capacitor C1 is used between Vcc and GND for

noise filtering. Apart from that, all the address pins (A0-A7, pin 1-8) are grounded, just as in

transmitter. This is to ensure that the transmitted data is being received. Both the transmitter and

the receiver MUST have the same address pins configuration. Pin 17 (VT) is enabled whenever

the receiver receives any data. The serial data received by the RF Receiver module is directly fed

Fig: - Receiver interfacing

Page 11: 4 Channel Rf Remote Control Device

to pin 14 (DIN), which is then converted into 4-bit parallel data (D0-D3). A 33 ohm resistor is

connected in between OSC1 and OSC2.When the switch is connected to the battery and when

Hardware Components

The Hardware components used in this project are

1.6 Regulated Power Supply

1.7 Microcontroller

1.8 RF transmitter

1.9 RF receiver

1.20 Encoder

1.21 Decoder

1.22 Relays

1.23 Frequency matcher

1.24 LED

1.6 REGULATED POWER SUPPLY:-

The power supplies are designed to convert high voltage AC mains electricity to a

suitable low voltage supply for electronics circuits and other devices. A RPS (Regulated Power

Supply) is the Power Supply with Rectification, Filtering and Regulation being done on the AC

mains to get a Regulated power supply for Microcontroller and for the other devices being

interfaced to it.

A power supply can by broken down into a series of blocks, each of which performs a

particular function. A d.c power supply which maintains the output voltage constant irrespective

of a.c mains fluctuations or load variations is known as “Regulated D.C Power Supply”

For example a 5V regulated power supply system as shown below:

Page 12: 4 Channel Rf Remote Control Device

1.61 Transformer:

A transformer is an electrical device which is used to convert electrical power from

one Electrical circuit to another without change in frequency.

Transformers convert AC electricity from one voltage to another with little loss of power.

Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up

transformers increase in output voltage, step-down transformers decrease in output voltage. Most power

supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage.

The input coil is called the primary and the output coil is called the secondary. There is no electrical

connection between the two coils; instead they are linked by an alternating magnetic field created in the

soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core.

Transformers waste very little power so the power out is (almost) equal to the power in. Note that as

voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the

turn’s ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its

primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on

its secondary (output) coil to give a low output voltage.

Fig 1 Components of linear power

supply

Page 13: 4 Channel Rf Remote Control Device

Fig 2 : An Electrical Transformer

Turns ratio = Vp/ VS = Np/NS

Power Out= Power In

VS X IS=VP X IP

Vp = primary (input) voltage

Np = number of turns on primary coil

Ip  = primary (input) current    

1.62 RECTIFIER:

A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of

conversion a.c to d.c is called “rectification”

TYPES OF RECTIFIERS:

Half wave Rectifier

Full wave rectifier

1. Centre tap full wave rectifier.

2. Bridge type full bridge rectifier.

Comparison of rectifier circuits:

Page 14: 4 Channel Rf Remote Control Device

Parameter

Type of Rectifier

Half wave Full wave Bridge

Number of diodes 1 2 4

PIV of diodes Vm 2Vm Vm

D.C output voltage Vm/ 2Vm/ 2Vm/

Vdc,at no-load 0.318Vm 0.636Vm 0.636Vm

Ripple factor 1.21 0.482 0.482

Ripple frequency f 2f 2f

Rectification efficiency 0.406 0.812 0.812

Transformer

UtilizationFactor(TUF)

0.287 0.693 0.812

RMS voltage Vrms Vm/2 Vm/√2 Vm/√2

1.621 Full-wave Rectifier:

From the above comparison we came to know that full wave bridge rectifier as more

advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier

circuit.

1.622 Bridge Rectifier:

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-

wave rectification. This is a widely used configuration, both with individual diodes wired as

shown and with single component bridges where the diode bridge is wired internally.

A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig

(3) to achieve full-wave rectification. This is a widely used configuration, both with individual

Page 15: 4 Channel Rf Remote Control Device

diodes wired as shown and with single component bridges where the diode bridge is wired

internally.

Fig 3 : Bridge rectifier

Operation:

During positive half cycle of secondary, the diodes D2 and D3 are in forward biased while D1

and D4 are in reverse biased as shown in the fig(4). The current flow direction is shown in the fig

(4) with dotted arrows.

Fig (4): Bridge Rectifier Positive Cycle

Page 16: 4 Channel Rf Remote Control Device

During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward biased

while D2 and D3 are in reverse biased as shown in the fig(5). The current flow direction is shown

in the fig (5) with dotted arrows.

Fig(5) : Bridge Rectifier Negative Cycle

1.63 Filter:

A Filter is a device which removes the a.c component of rectifier output but allows

the d.c component to reach the load

1.631 Capacitor Filter:

We have seen that the ripple content in the rectified output of half wave rectifier is 121% or

that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is

not acceptable for most of the applications. Ripples can be removed by one of the following

methods of filtering.

(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples voltage though

it due to low impedance. At ripple frequency and leave the D.C. to appear at the load.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to high

impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

Page 17: 4 Channel Rf Remote Control Device

(c) Various combinations of capacitor and inductor, such as L-section filter section filter, multiple

section filter etc. Which make use of both the properties mentioned in (a) and (b) above. Two cases of

capacitor filter, one applied on half wave rectifier and another with full wave rectifier.

Filtering is performed by a large value electrolytic capacitor connected across the DC supply to

act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling.

The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to

the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 × RMS

value).

To calculate the value of capacitor(C),

C = ¼*√3*f*r*Rl

Where,

f = supply frequency,

r = ripple factor,

Rl = load resistance

Note: In our circuit we are using 1000µF hence large value of capacitor is placed to reduce ripples

and to improve the DC component.

1.64 Regulator:

Voltage regulator Ics is available with fixed (typically 5, 12 and 15V) or variable

output voltages. The maximum current they can pass also rates them. Negative voltage regulators

are available, mainly for use in dual supplies. Most regulators include some automatic protection

from excessive current (‘overload protection’) and overheating (‘thermal protection’). Many of

the fixed voltage regulators Ics have 3 leads and look like power transistors, such as the 7805

+5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the

positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input

pin, connect the negative lead to the Common pin and then when you turn on the power, you get a

5 volt supply from the output pin.

Page 18: 4 Channel Rf Remote Control Device

Fig 6: A Three Terminal Voltage Regulator

78XX:

The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The

LM78XX offer several fixed output voltages making them useful in wide range of applications.

When used as a zener diode/resistor combination replacement, the LM78XX usually results in an

effective output impedance improvement of two orders of magnitude, lower quiescent current.

The LM78XX is available in the TO-252, TO-220 & TO-263packages,

Features:

• Output Current of 1.5A

• Output Voltage Tolerance of 5%

• Internal thermal overload protection

• Internal Short-Circuit Limited

• Output Voltage 5.0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V

1.7 Micro controller

1.7.1 Introduction

Page 19: 4 Channel Rf Remote Control Device

An embedded system is a special-purpose system in which the computer is completely

encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose

computer, such as a personal computer, an embedded system performs one or a few pre-defined

tasks, usually with very specific requirements. Since the system is dedicated to specific tasks,

design engineers can optimize it, reducing the size and cost of the product. Embedded systems are

often mass-produced, benefiting from economies of scale

1.7.11 Atmel

Atmel® microcontrollers deliver a rich blend of highly efficient, integrated designs, proven

technology, and groundbreaking innovation that is ideal for today's smart, connected products. In

this era of The Internet of Things, microcontrollers are a key technology fueling machine-to-

machine (M2M) communications. Building on decades of experience and industry leadership,

Atmel has proven architectures that are optimized for low power, high-speed connectivity,

optimal data bandwidth, and rich interface support. A wide variety of configuration options

enables developers to devise complete system solutions for all kinds of applications. Atmel

microcontrollers can also support seamless integration of capacitive touch technology, to

implement buttons, sliders, and wheels. No matter what your market or device, Atmel offers a

compelling solution that is tailored to your needs—today and tomorrow.

Atmel AVR 8- and 32-bit microcontroller — Atmel AVR 8- and 32-bit

microcontrollers deliver a unique combination of performance, power efficiency, and

design flexibility. Optimized to speed time to market, and easily adapt to new ones,

they are based on the industry’s most code-efficient architecture for C and assembly

programming. The extensive AVR portfolio makes it easy to reuse knowledge when

improving your products and expanding to new markets.

ARM Processor-Based Microcontrollers — Atmel offers a wide range of industry-

leading AT91SAM ARM-based Flash MCUs and eMPU solutions. This broad

portfolio of 32-bit ARM® solutions can meet the needs of virtually any device or

marketplace. Flexible and highly integrated, Atmel ARM-based solutions are

designed to optimize system control, wired and wireless connectivity, user interface

management, low power, and ease of use.

MCU Wireless — To support today's increasingly connected applications, Atmel

offers a complete line of IEEE 802.15.4-compliant and ZigBee certified wireless

solutions. They are based on the Atmel rich family of RF transceivers, AVR and

ARM microcontrollers, as well as single chip wireless microcontrollers.

Page 20: 4 Channel Rf Remote Control Device

8051 Architecture Microcontroller — Atmel has a rich portfolio of microcontrollers

based on the 8051 instruction set combines proven technology with the latest features

and functionality. Developers can choose from 8-bit microcontrollers based on the

powerful, low-power Single-Cycle AT89LP core, as well as MCS-51® industry

standard socket drop-in devices—all featuring advanced Flash technologies.

Convenience, security, reliability and power efficiency drive low-frequency RF application

requirements. You can rely on Atmel® to help you design cost-effective, highly reliable RF

products. Atmel wireless technologies enable innovative, scalable and dedicated designs that fit

small footprints, consume very little power, and operate in rugged environments—indoors or

outdoors.

Atmel wireless technologies span these in-demand wireless areas:

MCU Wireless — To support today's increasingly connected applications, Atmel

offers a complete line of IEEE 802.15.4-compliant and ZigBee Certified wireless

solutions. These are based on the rich family of Atmel RF transceivers, as well as

Atmel AVR®, ARM®-based and single-chip wireless microcontrollers.

RF Identification — Address the needs of contactless identification products

operating at 125 kHz, 134.2 kHz and 13.56 MHz bandwidth ranges and support the

ISO 14443-B standard.

Smart RF — Target proprietary (non-standards based) wireless industrial and

consumer applications such as automatic metering, alarm systems and home control,

as well as toys and gaming.

Wi-Fi — Address the needs for Wi-Fi capability in embedded systems. Atmel low-

power Wi-Fi solutions cover a wide range of applications requiring support for legacy

Wi-Fi, as well as Wi-Fi Direct. Wi-Fi Direct is a software-based extension of standard

Wi-Fi that allows devices to communicate directly without the data passing through a

wireless access point (Wi-Fi Router or Gateway).

For the user, touch technology is all about sensitivity, speed, and accuracy—in other words, an

interface that senses and responds to their touches precisely and reliably, in the blink of an eye.

As a global leader in capacitive touch technology, with more than 15 years of experience, Atmel

can be your partner in delivering transformative touch innovations to the market, quickly and cost

Page 21: 4 Channel Rf Remote Control Device

effectively. Our robust, noise-resistant integrated circuits (ICs) are designed to provide superior

performance and response times while conserving power and saving space. For enhanced

functionality and design ease, you can also integrate our touch technology with leading-edge

Atmel AT91SAM and AVR® microcontrollers.

1.7.12 Atmel mega8 microcontroller:-

Features

• High-performance, Low-power Atmel®AVR® 8-bit Microcontroller

• Advanced RISC Architecture

– 130 Powerful Instructions – Most Single-clock Cycle Execution

– 32 × 8 General Purpose Working Registers

– Fully Static Operation

– Up to 16MIPS Throughput at 16MHz

– On-chip 2-cycle Multiplier

• High Endurance Non-volatile Memory segments

Fig: -Atmel micro controller

Page 22: 4 Channel Rf Remote Control Device

– 8Kbytes of In-System Self-programmable Flash program memory

– 512Bytes EEPROM

– 1Kbyte Internal SRAM

– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

– Data retention: 20 years at 85°C/100 years at 25°C(1)

– Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation

– Programming Lock for Software Security

• Peripheral Features

– Two 8-bit Timer/Counters with Separate Prescalar, one Compare Mode

– One 16-bit Timer/Counter with Separate Prescalar, Compare Mode, and Capture

Mode

– Real Time Counter with Separate Oscillator

– Three PWM Channels

– 8-channel ADC in TQFP and QFN/MLF package

Eight Channels 10-bit Accuracy

– 6-channel ADC in PDIP package

Six Channels 10-bit Accuracy

– Byte-oriented Two-wire Serial Interface

– Programmable Serial USART

– Master/Slave SPI Serial Interface

– Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

• Special Microcontroller Features

– Power-on Reset and Programmable Brown-out Detection

– Internal Calibrated RC Oscillator

– External and Internal Interrupt Sources

– Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and

Standby

• I/O and Packages

Page 23: 4 Channel Rf Remote Control Device

– 23 Programmable I/O Lines

– 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF

• Operating Voltages

– 2.7V - 5.5V (ATmega8L)

– 4.5V - 5.5V (ATmega8)

• Speed Grades

– 0 - 8MHz (ATmega8L)

– 0 - 16MHz (ATmega8)

• Power Consumption at 4 MHz, 3V, 25°C

– Idle Mode: 1.0mA

– Power-down Mode: 0.5µA

FIG : - ATMEL MEGA 8 IC

Page 24: 4 Channel Rf Remote Control Device

1.7.13 Pin diagram: -

Features:

Pin Number Description

1 (RESET) PC6

2 (RXD) PD0

Page 25: 4 Channel Rf Remote Control Device

3 (TXD) PD1

4 (INT0) PD2

5 (INT1) PD3

6 (XCK/T0) PD4

7 VCC

8 GND

9 (XTAL1/TOSC1) PB6

10 (XTAL2/TOSC2) PB7

11 (T1)PD5

12 (AIN0) PD6

13 (AIN1) PD7

14 (ICP1) PB0

15 (OC1A) PB1

16 (SS/OC1B) PB2

17 (MOSI/OC2) PB3

18 (MISO) PB4

19 (SCK) PB5

20 AVCC

21 AREF

22 GND

23 (ADC0) PC0

24 (ADC1) PC1

25 (ADC2) PC2

26 (ADC3) PC3

27 (ADC4/SDA) PC4

28 (ADC5/SCL) PC5

Page 26: 4 Channel Rf Remote Control Device
Page 27: 4 Channel Rf Remote Control Device

Architecture explanation: -

The Atmel AVR core combines a rich instruction set with 32 general purpose working registers.

All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two

independent registers to be accessed in one single instruction executed in one clock cycle.

The resulting architecture is more code efficient while achieving throughputs up to ten times

faster than conventional CISC microcontrollers.

The ATmega8 provides the following features: 8 Kbytes of In-System Programmable Flash

with Read-While-Write capabilities, 512 bytes of EEPROM, 1 Kbyte of SRAM, 23 general

purpose I/O lines, 32 general purpose working registers, three flexible Timer/Counters with

compare modes, internal and external interrupts, a serial programmable USART, a byte

oriented Two- wire Serial Interface, a 6-channel ADC (eight channels in TQFP and QFN/MLF

packages) with 10-bit accuracy, a programmable Watchdog Timer with Internal Oscillator, an

SPI serial port, and five software selectable power saving modes. The Idle mode stops the CPU

while allowing the SRAM; Timer/Counters, SPI port, and interrupt system to continue

functioning. The Power- down mode saves the register contents but freezes the Oscillator,

disabling all other chip functions until the next Interrupt or Hardware Reset. In Power-save

mode, the asynchronous timer continues to run, allowing the user to maintain a timer base while

the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O

modules except asynchronous timer and ADC, to minimize switching noise during ADC

conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest of the

device is sleeping. This allows very fast start-up combined with low-power consumption.

The device is manufactured using Atmel’s high density non-volatile memory technology. The

Flash Program memory can be reprogrammed In-System through an SPI serial interface, by a

conventional non-volatile memory programmer, or by an On-chip boot program running on the

AVR core. The boot program can use any interface to download the application program in the

Page 28: 4 Channel Rf Remote Control Device

Application Flash memory. Software in the Boot Flash Section will continue to run while the

Application Flash Section is updated, providing true Read-While-Write operation. By

combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic

chip, the Atmel ATmega8 is a powerful microcontroller that provides a highly-flexible and

cost-effective solution to many embedded control applications.

The ATmega8 is supported with a full suite of program and system development tools,

including C compilers, macro assemblers, program debugger/simulators, In-Circuit Emulators,

and evaluation kits.

Block Description:

VCC- Digital supply voltage.

GND - Ground.

Page 29: 4 Channel Rf Remote Control Device

Port B (PB7..PB0) XTAL1/XTAL2/TOSC1/ TOSC2

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port B output buffers have symmetrical drive characteristics with both high sink and

source capability. As inputs, Port B pins that are externally pulled low will source current if

the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition

becomes active, even if the clock is not running.

Depending on the clock selection fuse settings, PB6 can be used as input to the inverting

Oscil- lator amplifier and input to the internal clock operating circuit.

Depending on the clock selection fuse settings, PB7 can be used as output from the

inverting

Oscillator

amplifier.

If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as

TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.

Port C (PC5..PC0) Port C is an 7-bit bi-directional I/O port with internal pull-up

resistors (selected for each bit). The Port C output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs, Port C pins that are

externally pulled low will source current if the pull-up resistors are activated. The Port C pins

are tri-stated when a reset condition becomes active, even if the clock is not running.

PC6/RESET If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin.

Note that the electrical char- acteristics of PC6 differ from those of the other pins of Port C.

If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset

input. A low level on this pin for longer than the minimum pulse

length will generate a Reset, even if the clock is not running..

Shorter pulses are not guaranteed to generate a Reset.

Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up

Page 30: 4 Channel Rf Remote Control Device

resistors (selected for each bit). The Port D output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs, Port D pins that are

externally pulled low will source current if the pull-up resistors are activated. The Port D

pins are tri-stated when a reset condition becomes active, even if the clock is not running.

.

RESET Reset input. A low level on this pin for longer than the minimum

pulse length will generate a reset, even if the clock is not running.. Shorter pulses are not

guaranteed to generate a reset.

Types of memory:

The 89C51 have three general types of memory. They are on-chip memory, external

Code memory and external Ram. On-Chip memory refers to physically existing memory on the

micro controller itself. External code memory is the code memory that resides off chip. This is

often in the form of an external EPROM. External RAM is the Ram that resides off chip. This

often is in the form of standard static RAM or flash RAM.

a) Code memory

Code memory is the memory that holds the actual 89C51 programs that is to be run. This

memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have

4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory

is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

b) Internal RAM

The 89C51 have a bank of 128 of internal RAM. The internal RAM is found on-chip. So

it is the fastest Ram available. And also it is most flexible in terms of reading and writing.

Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128 bytes of internal

memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains 8

registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These bits

are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are

numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB

and CLR.

FLASH MEMORY:

Page 31: 4 Channel Rf Remote Control Device

Flash memory (sometimes called “flash RAM”) is a type of constantly-powered non

volatile that can be erased and reprogrammed in units of memory called blocks. It is a variation of

electrically erasable programmable read-only memory (EEPROM) which, unlike flash memory,

is erased and rewritten at the byte level, which is slower than flash memory updating. Flash

memory is often used to hold control code such as the basic input/output system (BIOS) in a

personal computer. When BIOS needs to be changed (rewritten), the flash memory can be written

to in block (rather than byte) sizes, making it easy to update. On the other hand, flash memory is

not useful as random access memory (RAM) because RAM needs to be addressable at the byte

(not the block) level.

Flash memory gets its name because the microchip is organized so that a section of

memory cells are erased in a single action or “flash.” The erasure is caused by Fowler-Nordheim

tunneling in which electrons pierce through a thin dielectric material to remove an electronic

charge from a floating gate associated with each memory cell. Intel offers a form of flash

memory that holds two bits (rather than one) in each memory cell, thus doubling the capacity of

memory without a corresponding increase in price.

.

Page 32: 4 Channel Rf Remote Control Device

Memory Type Features

FLASH Low-cost, high-density, high-speed

architecture; low power; high reliability

ROM

Read-Only Memory

Mature, high-density, reliable, low cost;

time-consuming mask required, suitable for

high production with stable code

SRAM

Static Random-Access Memory

Highest speed, high-power, low-density

memory; limited density drives up cost

EPROM

Electrically Programmable Read-Only

Memory

High-density memory; must be exposed to

ultraviolet light for erasure

EEPROMorE2PROM

Electrically Erasable Programmable Read-

Only Memory

Electrically byte-erasable; lower reliability,

higher cost, lowest density

DRAM

Dynamic Random Access Memory

High-density, low-cost, high-speed, high-

power

Technical Overview of Flash Memory

Flash memory is a nonvolatile memory using NOR technology, which allows the user to

electrically program and erase information. Intel® Flash memory uses memory cells similar to an

EPROM, but with a much thinner, precisely grown oxide between the floating gate and the source

. Flash programming occurs when electrons are placed on the floating gate. The charge is stored

on the floating gate, with the oxide layer allowing the cell to be electrically erased through the

source. Intel Flash memory is an extremely reliable nonvolatile memory architecture.

REGISTERS:

32

Page 33: 4 Channel Rf Remote Control Device

In the CPU, registers are used to store information temporarily. That information could

be a byte of data to be processed, or an address pointing to the data to be fetched. The vast

majority of 8051 registers are 8–bit registers. In the 8051 there is only one data type: 8bits. The

8bits of a register are shown in the diagram from the MSB (most significant bit) D7 to the LSB

(least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into

8-bit chunks before it is processed. Since there are a large number of registers in the 8051, we

will concentrate on some of the widely used general-purpose registers and cover special registers

in future chapters.

D7 D6 D5 D4 D3 D2 D1 D0

The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4,

R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above registers are 8-

bits, except DPTR and the program counter. The accumulator, register A, is used for all

arithmetic and logic instructions.

SFRs (Special Function Registers)

Among the registers R0-R7 is part of the 128 bytes of RAM memory. What about

registers A, B, PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051,

registers A, B, PSW and DPTR are part of the group of registers commonly referred to as SFR

(special function registers). There are many special function registers and they are widely used.

The SFR can be accessed by the names (which is much easier) or by their addresses. For

example, register A has address E0h, and register B has been ignited the address F0H, as shown

in table.

The following two points should noted about the SFR addresses.

1. The Special function registers have addresses between 80H and FFH. These

addresses are above 80H, since the addresses 00 to 7FH are addresses of RAM

memory inside the 8051.

2. Not all the address space of 80H to FFH is used by the SFR. The unused locations

80H to FFH are reserved and must not be used by the 8051 programmer.

33

Page 34: 4 Channel Rf Remote Control Device

Regarding direct addressing mode, notice the following two points: (a) the address value

is limited to one byte, 00-FFH, which means this addressing mode is limited to accessing RAM

locations and registers located inside the 8051. (b) If you examine the l st file for an assembly

language program, you will see that the SFR registers names are replaced with their addresses as

listed in table.

Symbol Name Address

ACC Accumulator 0E0H

B B register 0F0H

PSW Program status word 0D0H

SP Stack pointer 81H

DPTR Data pointer 2 bytes

DPL Low byte 82H

DPH High byte 83H

P0 Port0 80H

P1 Port1 90H

P2 Port2 0A0H

P3 Port3 0B0H

IP Interrupt priority control 0B8H

IE Interrupt enable control 0A8H

TMOD Timer/counter mode control 89H

TCON Timer/counter control 88H

T2CON Timer/counter 2 control 0C8H

T2MOD Timer/counter mode2 control 0C9H

34

Page 35: 4 Channel Rf Remote Control Device

TH0 Timer/counter 0high byte 8CH

TL0 Timer/counter 0 low byte 8AH

TH1 Timer/counter 1 high byte 8DH

TL1 Timer/counter 1 low byte 8BH

TH2 Timer/counter 2 high byte 0CDH

TL2 Timer/counter 2 low byte 0CCH

RCAP2H T/C 2 capture register high

byte

0CBH

RCAP2L T/C 2 capture register low byte 0CAH

SCON Serial control 98H

SBUF Serial data buffer 99H

PCON Power control 87H

Table: 8051 Special function register Address

A Register (Accumulator)

35

Page 36: 4 Channel Rf Remote Control Device

Fig : Accumulator register

This is a general-purpose register which serves for storing intermediate results during operating.

A number (an operand) should be added to the accumulator prior to execute an instruction upon

it. Once an arithmetical operation is preformed by the ALU, the result is placed into the

accumulator. If a data should be transferred from one register to another, it must go through

accumulator. For such universal purpose, this is the most commonly used register that none

microcontroller can be imagined without (more than a half 8051 microcontroller’s instructions

used use the accumulator in some way).

B Register

B register is used during multiply and divide operations which can be performed only upon

numbers stored in the A and B registers. All other instructions in the program can use this register

as a spare accumulator (A).

Fig : B register

During programming, each of registers is called by name so that their exact address is not

so important for the user. During compiling into machine code (series of hexadecimal numbers

recognized as instructions by the microcontroller), PC will automatically, instead of registers’

name, write necessary addresses into the microcontroller.

R Registers (R0-R7)

36

Page 37: 4 Channel Rf Remote Control Device

Fig : RAM

This is a common name for the total 8 general purpose registers (R0, R1, and R2 ...R7).

Even they are not true SFRs, they deserve to be discussed here because of their purpose. The

bank is active when the R registers it includes are in use. Similar to the accumulator, they are

used for temporary storing variables and intermediate results. Which of the banks will be active

depends on two bits included in the PSW Register. These registers are stored in four banks in the

scope of RAM.

The following example best illustrates the useful purpose of these registers. Suppose that

mathematical operations on numbers previously stored in the R registers should be performed:

(R1+R2) – (R3+R4). Obviously, a register for temporary storing results of addition is needed.

Everything is quite simple and the program is as follows:

MOV A, R3; Means: move number from R3 into accumulator

ADD A, R4; Means: add number from R4 to accumulator (result remains in accumulator)

MOV R5, A; Means: temporarily moves the result from accumulator into R5

MOV A, R1; Means: move number from R1 into accumulator

ADD A, R2; Means: add number from R2 to accumulator

SUBB A, R5; Means: subtract number from R5 (there are R3+R4)

37

Page 38: 4 Channel Rf Remote Control Device

8051 Register Banks and Stack

RAM memory space allocation in the 8051

There are 128 bytes of RAM in the 8051. The 128 bytes of RAM inside the 8051 are

assigned addresses 00 to7FH. These 128 bytes are divided into three different groups as follows:

1. A total of 32 bytes from locations 00 to 1FH hex are set aside for register banks and

the stack.

2. A total of 16 bytes from locations 20 to 2FH hex are set aside for bit-addressable

read/write memory.

3. A total of 80 bytes from locations 30H to 7FH are used for read and write storage, or

what is normally called Scratch pad. These 80 locations of RAM are widely used for

the purpose of storing data and parameters nu 8051 programmers.

Register banks in the 8051

A total of 32bytes of RAM are set aside for the register banks and stack. These 32

bytes are divided into 4 banks of registers in which each bank has registers, R0-R7. RAM

locations 0 to 7 are set aside for bank 0 of R0-R7 where R0 is RAM location 0, R1 is RAM

location 1, and R2 is location 2, and so on, until memory location7, which belongs to R7 of

bank0. The second bank of registers R0-R7 starts at RAM location 08 and goes to location 0FH.

The third bank of R0-R7 starts at memory location 10H and goes to location 17H. Finally, RAM

locations 18H to 1FH are set aside for the fourth bank of R0-R7. Fig shows how the 32 bytes are

allocated into 4 banks.

As we can see from fig 1, the bank 1 uses the same RAM space as the stack. This is a

major problem in programming the 8051. We must either not use register bank1, or allocate

another area of RAM for the stack.

Default register bank

If RAM locations 00-1F are set aside for the four register banks, which register bank of

R0-R7 do we have access to when the 8051 is powered up? The answer is register bank 0; that is ,

RAM locations 0, 1,2,3,4,5,6, and 7 are accessed with the names R0, R1, R2, R3, R4, R5, R6, and

R7 when programming the 8051. It is much easier to refer to these RAM locations with names

such as R0, R1 and so on, than by their memory locations as shown in fig 2.The register banks are

38

Page 39: 4 Channel Rf Remote Control Device

switched by using the D3 & D4 bits of register PSW

Fig : 8051 Register Banks and their RAM Addresses

PSW Register (Program Status Word)

39

Page 40: 4 Channel Rf Remote Control Device

Fig 16: PSW register

This is one of the most important SFRs. The Program Status Word (PSW) contains

several status bits that reflect the current state of the CPU. This register contains: Carry bit,

Auxiliary Carry, two register bank select bits, Overflow flag, parity bit, and user-definable status

flag. The ALU automatically changes some of register’s bits, which is usually used in regulation

of the program performing.

P – Parity bit If a number in accumulator is even then this bit will be automatically set (1),

otherwise it will be cleared (0). It is mainly used during data transmission and receiving via serial

communication.

- Bit 1. This bit is intended for the future versions of the microcontrollers, so it is not supposed to

be here.

OV Overflow occurs when the result of arithmetical operation is greater than 255 (decimal), so

that it can not be stored in one register. In that case, this bit will be set (1). If there is no overflow,

this bit will be cleared (0).

RS0, RS1 – Register bank selects bits. These two bits are used to select one of the four register

banks in RAM. By writing zeroes and ones to these bits, a group of registers R0-R7 is stored in

one of four banks in RAM.

RS1 RS2 Space in RAM

0 0 Bank0 00h-07h

0 1 Bank1 08h-0Fh

1 0 Bank2 10h-17h

1 1 Bank3 18h-1Fh

40

Page 41: 4 Channel Rf Remote Control Device

F0 – Flag 0. This is a general-purpose bit available to the user.

AC – Auxiliary Carry Flag is used for BCD operations only.

CY – Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and shift

instructions.

DPTR Register (Data Pointer)

These registers are not true ones because they do not physically exist. They consist of

two separate registers: DPH (Data Pointer High) and (Data Pointer Low). Their 16 bits are used

for external memory addressing. They may be handled as a 16-bit register or as two independent

8-bit registers. Besides, the DPTR Register is usually used for storing data and intermediate

results which have nothing to do with memory locations.

Fig : DPTR register

SP Register (Stack Pointer)

41

Page 42: 4 Channel Rf Remote Control Device

Fig : SP register

The stack is a section of RAM used by the CPU to store information temporarily. This

information could be data or an address. The CPU needs this storage area since there are only a

limited number of registers.

Program counter:

The important register in the 8051 is the PC (Program counter). The program counter

points to the address of the next instruction to be executed. As the CPU fetches the OPCODE

from the program ROM, the program counter is incremented to point to the next instruction. The

program counter in the 8051 is 16bits wide. This means that the 8051 can access program

addresses 0000 to FFFFH, a total of 64k bytes of code. However, not all members of the 8051

have the entire 64K bytes of on-chip ROM installed, as we will see soon.

Types of instructions

Depending on operation they perform, all instructions are divided in several groups:

Arithmetic Instructions

Branch Instructions

Data Transfer Instructions

Logical Instructions

Logical Instructions with bits

The first part of each instruction, called MNEMONIC refers to the operation an instruction

performs (copying, addition, logical operation etc.). Mnemonics commonly are shortened form of

name of operation being executed. For example:

INC R1; Increment R1 (increment register R1)

42

Page 43: 4 Channel Rf Remote Control Device

LJMP LAB5 ; Long Jump LAB5 (long jump to address specified as LAB5)

JNZ LOOP: Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to address

specified as LOOP)

Another part of instruction, called OPERAND is separated from mnemonic at least by

one empty space and defines data being processed by instructions. Some instructions have no

operand; some have one, two or three. If there is more than one operand in instruction, they are

separated by comma. For example:

RET – (return from sub-routine)

JZ TEMP – (if the number in the accumulator is not 0, jump to address specified as TEMP)

ADD A,R3 – (add R3 and accumulator)

CJNE A,#20,LOOP – (compare accumulator with 20. If they are not equal, jump to address

specified as LOOP)

Arithmetic instructions

These instructions perform several basic operations (addition, subtraction, division,

multiplication etc.) After execution, the result is stored in the first operand. For example:

ADD A, R1 – The result of addition (A+R1) will be stored in the accumulator.

Arithmetical Instructions

Mnemonic Description Byte NumberOscillator

Period

ADD A,Rn Add R Register to accumulator 1 1

ADD A,Rx Add directly addressed Rx Register to accumulator 2 2

43

Page 44: 4 Channel Rf Remote Control Device

ADD A,@Ri Add indirectly addressed Register to accumulator 1 1

ADD A,#X Add number X to accumulator 2 2

ADDC A,Rn Add R Register with Carry bit to accumulator 1 1

Branch Instructions

There are two kinds of these instructions:

Unconditional jump instructions:

After their execution a jump to a new location from where the program continues

execution is executed.

Conditional jump instructions:

If some condition is met – a jump is executed. Otherwise, the program normally

proceeds with the next instruction.

Branch Instruction

Mnemonic DescriptionByte

Number

Oscillator

Period

ACALL adr11Call subroutine located at address within 2 K byte

Program Memory space2 3

LCALL adr16 Call subroutine located at any address within 64 K 3 4

44

Page 45: 4 Channel Rf Remote Control Device

byte Program Memory space

RET Return from subroutine 1 4

RETI Return from interrupt routine 1 4

AJMP adr11Jump to address located within 2 K byte Program

Memory space2 3

LJMP adr16Jump to any address located within 64 K byte

Program Memory space3 4

Data Transfer Instructions

These instructions move the content of one register to another one. The register which

content is moved remains unchanged. If they have the suffix “X” (MOVX), the data is exchanged

with external memory.

Data Transfer Instruction

Mnemonic Description Byte NumberCycle

Number

MOV A,Rn Move R register to accumulator 1 1

MOV A,Rx Move directly addressed Rx register to accumulator 2 2

MOV A,@Ri Move indirectly addressed register to accumulator 1 1

MOV A,#X Move number X to accumulator 2 2

Logical Instructions

45

Page 46: 4 Channel Rf Remote Control Device

These instructions perform logical operations between corresponding bits of two

registers. After execution, the result is stored in the first operand.

Logical Instructions

Mnemonic Description Byte NumberCycle

Number

ANL A,Rn Logical AND between accumulator and R register 1 1

ANL A,RxLogical AND between accumulator and directly addressed

register Rx2 2

ANL A,@RiLogical AND between accumulator and indirectly

addressed register1 1

ANL A,#X Logical AND between accumulator and number X 2 2

Logical Operations on Bits

Similar to logical instructions, these instructions perform logical operations. The

difference is that these operations are performed on single bits.

Logical operations on bits

Mnemonic Description Byte NumberCycle

Number

CLR C Clear Carry bit 1 1

CLR bit Clear directly addressed bit 2 2

SETB C Set Carry bit 1 1

46

Page 47: 4 Channel Rf Remote Control Device

SETB bit Set directly addressed bit 2 2

CPL C Complement Carry bit 1 1

CPL bit Complement directly addressed bit 2 2

TIMERS

On-chip timing/counting facility has proved the capabilities of the microcontroller for

implementing the real time application. These includes pulse counting, frequency measurement,

pulse width measurement, baud rate generation, etc,. Having sufficient number of timer/counters

may be a need in a certain design application. The 8051 has two timers/counters. They can be

used either as timers to generate a time delay or as counters to count events happening outside the

microcontroller. Let discuss how these timers are used to generate time delays and we will also

discuss how they are been used as event counters.

PROGRAMMING 8051 TIMERS

The 8051 has timers: Timer 0 and Timer1.they can be used either as timers or as event

counters. Let us first discuss about the timers’ registers and how to program the timers to generate

time delays.

BASIC RIGISTERS OF THE TIMER

Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each

16-bit timer is accessed as two separate registers of low byte and high byte.

TIMER 0 REGISTERS

The 16-bit register of Timer 0 is accessed as low byte and high byte. The low byte

register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0

high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for

example, the instruction ”MOV TL0, #4F”moves the value 4FH into TL0,the low byte of Timer

0.These registers can also be read like any other register.

47

Page 48: 4 Channel Rf Remote Control Device

Fig 20:Timer 0(TH0 and TL0 ) registers

TIMER 1 REGISTERS

Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer 1 low

byte) and TH1 (Timer 1 high byte).these registers are accessible n the same way as the register of

Timer 0.

TMOD (timer mode) REGISTER

Both timers TIMER 0 and TIMER 1 use the same register, called TMOD, to set the

various timer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside

for Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bits are used to set the timer

mode and the upper 2 bits to specify the operation.

MODES:

M1, M0:

M0 and M1 are used to select the timer mode. There are three modes: 0, 1, 2.Mode 0 is

a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit timer. We will concentrate on

48

Page 49: 4 Channel Rf Remote Control Device

modes 1 and 2 since they are the ones used most widely. We will soon describe the characteristics

of these modes, after describing the reset of the TMOD register.

GATE: Gate control when set. The timer/counter is enabled only

While the INTx pin is high and the TRx control pin is.

Set. When cleared, the timer is enabled.

C/T Timer or counter selected cleared for timer operation

(Input from internal system clock).set for counter

Operation (input TX input pin).

M 1 Mode bit 1

M0 Mode bit 0

M1 M0 MODE Operating Mode

0 0 0 13-bit timer mode

8-bit timer/counter THx with

TLx as 5 – Bit pre-scaler.

0 1 1 16-bit timer mode

16-bit timer/counters THx with

TLx are Cascaded; there is no

prescaler

1 0 2 8-bit auto reload

8-bit auto reload

timer/counter;THx Holds a

value that is to be reloaded into

TLx each time it overflows.

1 1 3 Split timer mode.

49

Page 50: 4 Channel Rf Remote Control Device

C/T (clock/timer)

This bit in the TMOD register is used to decide whether the timer is used as a delay

generator or an event counter. If C/T=0, it is used as a timer for time delay generation. The clock

source for the time delay is the crystal frequency of the 8051.this section is concerned with this

choice. The timer’s use as an event counter is discussed in the next section

Serial Communication:

Computers can transfer data in two ways: parallel and serial. In parallel data transfers,

often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet

away. Examples of parallel data transfer are printers and hard disks; each uses cables with many

wire strips. Although in such cases a lot of data can be transferred in a short amount of time by

using many wires in parallel, the distance cannot be great. To transfer to a device located many

meters away, the serial method is used. In serial communication, the data is sent one bit at a time,

in contrast to parallel communication, in which the data is sent a byte or more at a time. Serial

communication of the 8051 is the topic of this chapter. The 8051 has serial communication

capability built into it, there by making possible fast data transfer using only a few wires.

If data is to be transferred on the telephone line, it must be converted from 0s and 1s to

audio tones, which are sinusoidal-shaped signals. A peripheral device called a modem, which

stands for “modulator/demodulator”, performs this conversion.

Serial data communication uses two methods, asynchronous and synchronous. The

synchronous method transfers a block of data at a time, while the asynchronous method transfers

a single byte at a time.

In data transmission if the data can be transmitted and received, it is a duplex

transmission. This is in contrast to simplex transmissions such as with printers, in which the

computer only sends data. Duplex transmissions can be half or full duplex, depending on

whether or not the data transfer can be simultaneous. If data is transmitted one way at a time, it is

referred to as half duplex. If the data can go both ways at the same time, it is full duplex. Of

50

Page 51: 4 Channel Rf Remote Control Device

course, full duplex requires two wire conductors for the data lines, one for transmission and one

for reception, in order to transfer and receive data simultaneously.

Asynchronous serial communication and data framing

The data coming in at the receiving end of the data line in a serial data transfer is all 0s

and 1s; it is difficult to make sense of the data unless the sender and receiver agree on a set of

rules, a protocol, on how the data is packed, how many bits constitute a character, and when the

data begins and ends.

Start and stop bits

Asynchronous serial data communication is widely used for character-oriented

transmissions, while block-oriented data transfers use the synchronous method. In the

asynchronous method, each character is placed between start and stop bits. This is called framing.

In the data framing for asynchronous communications, the data, such as ASCII characters, are

packed between a start bit and a stop bit. The start bit is always one bit, but the stop bit can be

one or two bits. The start bit is always a 0 (low) and the stop bit (s) is 1 (high).

Data transfer rate

The rate of data transfer in serial data communication is stated in bps (bits per second).

Another widely used terminology for bps is baud rate. However, the baud and bps rates are not

necessarily equal. This is due to the fact that baud rate is the modem terminology and is defined

as the number of signal changes per second. In modems a single change of signal, sometimes

transfers several bits of data. As far as the conductor wire is concerned, the baud rate and bps are

the same, and for this reason we use the bps and baud interchangeably.

The data transfer rate of given computer system depends on communication ports

incorporated into that system. For example, the early IBMPC/XT could transfer data at the rate

of 100 to 9600 bps. In recent years, however, Pentium based PCS transfer data at rates as high as

56K bps. It must be noted that in asynchronous serial data communication, the baud rate is

generally limited to 100,000bps.

RS232 Standards

To allow compatibility among data communication equipment made by various

manufacturers, an interfacing standard called RS232 was set by the Electronics Industries

51

Page 52: 4 Channel Rf Remote Control Device

Association (EIA) in 1960. In 1963 it was modified and called RS232A. RS232B AND RS232C

were issued in 1965 and 1969, respectively. Today, RS232 is the most widely used serial I/O

interfacing standard. This standard is used in PCs and numerous types of equipment. However,

since the standard was set long before the advert of the TTL logic family, its input and output

voltage levels are not TTL compatible. In RS232, a 1 is represented by -3 to -25V, while a 0 bit

is +3 to +25V, making -3 to +3 undefined. For this reason, to connect any RS232 to a

microcontroller system we must use voltage converters such as MAX232 to convert the TTL

logic levels to the RS232 voltage levels, and vice versa. MAX232 IC chips are commonly

referred to as line drivers.

RS232 pins

RS232 cable is commonly referred to as the DB-25 connector. In labeling, DB-25P

refers to the plug connector (male) and DB-25S is for the socket connector (female). Since not

all the pins are used in PC cables, IBM introduced the DB-9 Version of the serial I/O standard,

which uses 9 pins only, as shown in table.

1 2 3 4 5

6 7 8 9

(Out of computer and exposed end of cable)

Fig 21: DB-9 pin connector

Pin Functions:

Pin Description

1 Data carrier detect (DCD)

2 Received data (RXD)

3 Transmitted data (TXD)

4 Data terminal ready(DTR)

5 Signal ground (GND)

6 Data set ready (DSR)

7 Request to send (RTS)

8 Clear to send (CTS)

52

Page 53: 4 Channel Rf Remote Control Device

9 Ring indicator (RI)

Note: DCD, DSR, RTS and CTS are active low pins.

The method used by RS-232 for communication allows for a simple connection of three lines:

Tx, Rx, and Ground. The three essential signals for 2-way RS-232

Communications are these:

TXD: carries data from DTE to the DCE.

RXD: carries data from DCE to the DTE

SG: signal ground

1.8 RF transmitter section

RF transmitters are electronic devices that create continuously varying electric current,

encode sine waves, and broadcast radio waves. RF transmitters use oscillators to create sine

waves, the simplest and smoothest form of continuously varying waves, which contain

information such as audio and video. Modulators encode these sign wives and antennas broadcast

them as radio signals. There are several ways to encode or modulate this information, including

amplitude modulation (AM) and frequency modulation (FM). Radio techniques limit localized

interference and noise. With direct sequence spread spectrum, signals are spread over a large

band by multiplexing the signal with a code or signature that modulates each bit. With frequency

hopping spread spectrum, signals move through a narrow set of channels in a sequential, cyclical,

and predetermined pattern.

Selecting RF transmitters requires an understanding of modulation methods such as AM

and FM. On-off key (OOK), the simplest form of modulation, consists of turning the signal on or

off. Amplitude modulation (AM) causes the base band signal to vary the amplitude or height of

the carrier wave to create the desired information content. Frequency modulation (FM) causes the

instantaneous frequency of a sine wave carrier to depart from the center frequency by an amount

proportional to the instantaneous value of the modulating signal. Amplitude shift key (ASK)

transmits data by varying the amplitude of the transmitted signal. Frequency shift key (FSK) is a

digital modulation scheme using two or more output frequencies. Phase shift key (PSK) is a

53

Page 54: 4 Channel Rf Remote Control Device

digital modulation scheme in which the phase of the transmitted signal is varied in accordance

with the base band data signal.

Additional considerations when selecting RF transmitters include supply voltage, supply

current, RF connectors, special features, and packaging. Some RF transmitters include visual or

audible alarms or LED indicators that signal operating modes such as power on or reception.

Other devices attach to coaxial cables or include a connector or port to which an antenna can be

attached. Typically, RF transmitters that are rated for outdoor use feature a heavy-duty

waterproof design. Devices with internal calibration and a frequency range switch are also

available.

RF transmitters are used in a variety of applications and industries. Often, devices that are

used with integrated circuits (ICs) incorporate surface mount technology (SMT), through hole

technology (THT), and flat pack. In the telecommunications industry, RF transmitters are

designed to fit in a metal rack that can be installed in a cabinet. RF transmitters are also used in

radios and in electronic article surveillance systems (EAS) found in retail stores. Inventory

management systems use RF transmitters as an alternative to barcodes.

1.8.1 RF transmitter ST-TX01-ASK:

General Description:

54

Page 55: 4 Channel Rf Remote Control Device

The ST-TX01-ASK is an ASK Hybrid transmitter module. The ST-TX01-ASK is

designed by the Saw Resonator, with an effective low cost, small size, and simple-to-use for

designing.

Frequency Range: 315 / 433.92 MHZ.

Supply Voltage: 3~12V.

Output Power: 4~16dBm

Circuit Shape: Saw

Applications

Wireless security systems

Car Alarm systems

Remote controls.

Sensor reporting

Automation systems

55

Page 56: 4 Channel Rf Remote Control Device

Fig: Pin Description of the Transmitter module

Fig: Interfacing TX module to a Micro controller

1.9 RF receiver section:

56

Page 57: 4 Channel Rf Remote Control Device

RF receivers are electronic devices that separate radio signals from one another and convert

specific signals into audio, video, or data formats. RF receivers use an antenna to receive

transmitted radio signals and a tuner to separate a specific signal from all of the other signals that

the antenna receives. Detectors or demodulators then extract information that was encoded before

transmission. There are several ways to decode or modulate this information, including amplitude

modulation (AM) and frequency modulation (FM). Radio techniques limit localized interference

and noise. With direct sequence spread spectrum, signals are spread over a large band by

multiplexing the signal with a code or signature that modulates each bit. With frequency hopping

spread spectrum, signals move through a narrow set of channels in a sequential, cyclical, and

predetermined pattern.

Selecting RF receivers requires an understanding of modulation methods such as

AM and FM. On-off key (OOK), the simplest form of modulation, consists of turning the signal

on or off. Amplitude modulation (AM) causes the base band signal to vary the amplitude or

height of the carrier wave to create the desired information content. Frequency modulation (FM)

causes the instantaneous frequency of a sine wave carrier to depart from the center frequency by

an amount proportional to the instantaneous value of the modulating signal. Amplitude shift key

(ASK) transmits data by varying the amplitude of the transmitted signal. Frequency shift key

57

Page 58: 4 Channel Rf Remote Control Device

(FSK) is a digital modulation scheme using two or more output frequencies. Phase shift key

(PSK) is a digital modulation scheme in which the phase of the transmitted signal is varied in

accordance with the base band data signal.

RF receivers vary in terms of performance specifications such as sensitivity,

digital sampling rate, measurement resolution, operating frequency, and communication interface.

Sensitivity is the minimum input signal required to produce a specified output signal having a

specified signal-to-noise (S/N) ratio. Digital sampling rate is the rate at which samples can be

drawn from a digital signal in kilo samples per second. Measurement resolution is the minimum

digital resolution, while operating frequency is the range of received signals. Communication

interface is the method used to output data to computers. Parallel interfaces include general-

purpose interface bus (GPIB), which is also known as IEEE 488 and HPIB Protocol.  Serial

interfaces include universal serial bus (USB), RS232, and RS485.

Additional considerations when selecting RF receivers include supply voltage,

supply current, receiver inputs, RF connectors, special features, and packaging. Some RF

receivers include visual or audible alarms or LED indicators that signal operating modes such as

power on or reception. Other devices attach to coaxial cables or include a connector or port to

which an antenna can be attached. Typically, RF receivers that are rated for outdoor use feature a

heavy-duty waterproof design. Devices with internal calibration and a frequency range switch are

also available.

RF receiver ST-RX04-ASK:

Description:

The RX04 is a low power ASK receiver IC which is fully compatible with the

MitelKESRX01 IC and is suitable for use in a variety of low power radio applications including

remote keyless entry. The RX04 is based on a single-

Conversion, super-heterodyne receiver architecture and incorporates an entire phase-locked loop

(PLL) for precise local oscillator generation.

58

Page 59: 4 Channel Rf Remote Control Device

Applications:

Car security system

Wireless security systems

Sensor reporting

automation system

Remote Keyless entry

Features

Low power consumption.

Easy for application.

On-Chip VCO with integrated PLL using crystal oscillator reference.

Integrated IF and data filters.

Operation temperature range : ﹣10℃~+60℃

Operation voltage: 5 Volts.

Available frequency at : 315/434 MHz

Functional description:

59

Page 60: 4 Channel Rf Remote Control Device

Fig: RF receiver module.

Fig: RF receiver module.

1.10 Encoder:

Features:

Operating voltage

o 18 PIN DIP

o Operating Voltage : 2.4V ~ 12V

o Low Power and High Noise Immunity

60

Page 61: 4 Channel Rf Remote Control Device

o CMOS Technology

o Low Standby Current and Minimum Transmission Word

o Built-in Oscillator needs only 5% Resistor

o Easy Interface with and RF or an Infrared transmission medium

o Minimal External Components

General Description:

The 212 encoders are a series of CMOS LSIs for remote control system applications. They are capable of

encoding information which consists of N address bits and 12ĘN data bits. Each ad-dress/data input can be

set to one of the two logic states. The programmed addresses/data are transmitted together with the header

bits

The HT12E Encoder ICs are series of CMOS LSIs for Remote Control system applications. They are

capable of Encoding 12 bit of information which consists of N address bits and 12-N data bits. Each

address/data input is externally ternary programmable if bonded out.

This has single channel for data transfer, thus serial data communication is used

61

Page 62: 4 Channel Rf Remote Control Device

Application Circuits:

62

Page 63: 4 Channel Rf Remote Control Device

Fig 22: Application circuit of HT12E

Flow Chart:

Fig 23: Flow chat for data transmission in HT12E

1.10 Decoder:

63

Page 64: 4 Channel Rf Remote Control Device

Features -   Decoder

o 18 PIN DIP

o Operating Voltage : 2.4V ~ 12.0V

o Low Power and High Noise Immunity

o CMOS Technology

o Low Stand by Current

o Ternary address setting

o Capable of Decoding 12 bits of Information

o 8 ~ 12 Address Pins and 0 ~ 4 Data Pins

o Received Data are checked 2 times, Built in Oscillator needs only 5% resistor

o VT goes high during a valid transmission

o Easy Interface with an RF of IR transmission medium

o Minimal External Components

Applications

_ Burglar alarm system

_ Smoke and fire alarm system

64

Page 65: 4 Channel Rf Remote Control Device

_ Garage door controllers

_ Car door controllers

_ Car alarm system

_ Security system

_ Cordless telephones

_ Other remote control systems

General Description

The 212 decoders are a series of CMOS LSIs for remote control system applications. They are

paired with Holteks 212 series of encoders (refer to the encoder/decoder cross reference table).

For proper operation, a pair of encoder/decoder with the same number of addresses and data

format should be chosen. The decoders receive serial addresses and data from a programmed 212

series of encoders that are transmitted by a carrier using an RF or an IR transmission medium.

They compare the serial input data three times continuously with their local addresses. If no error

or unmatched codes are found, the input data codes are decoded and then transferred to the output

pins. The VT pin also goes high to indicate a valid transmission. The 212 series of decoders are

capable of decoding informations that consist of N bits of address and 12_N bits of data. Of this

series, the HT12D is arranged to provide 8 address bits and 4 data bits, and HT12F is used to

decode 12 bits of address information.

Notes: Data type: L stands for latch type data output.

VT can be used as a momentary data output.

65

Page 66: 4 Channel Rf Remote Control Device

Fig 25: Block Diagram of HT 12D Decoder

Functional Description

Operation: The 212 series of decoders provides various combinations of addresses and data pins

in different packages so as to pair with the 212 series of encoders. The decoders receive data that

are transmitted by an encoder and interpret the first N bits of code period as addresses and the last

12_N bits as data, where N is the address code number. A signal on the DIN pin activates the

oscillator, which in turn decodes the incoming address and data. The decoders will then check the

received address three times continuously. If the received address codes all match the contents of

the decoders local address, the 12_N bits of data are decoded to activate the output pins and the

VT pin is set high to indicate a valid transmission. This will last unless the address code is

incorrect or no signal is received. The output of the VT pin is high only when the transmission is

valid. Otherwise it is always low.

Output type

Of the 212 series of decoders, the HT12F has no data output pin but its VT pin can be used as a

momentary data output. The HT12D, on the other hand, provides 4 latch type data pins whose

data remain unchanged until new data are received.

66

Page 67: 4 Channel Rf Remote Control Device

Fig : Timing Diagram of Decoder HT12D

Fig: Application circuit of HT12D

1.12 Relays:

A relay is an electrically operated switch. Many relays use an electromagnet to operate a

switching mechanism mechanically, but other operating principles are also used. Relays are used

67

Page 68: 4 Channel Rf Remote Control Device

where it is necessary to control a circuit by a low-power signal (with complete electrical isolation

between control and controlled circuits), or where several circuits must be controlled by one

signal. The first relays were used in long distance telegraph circuits, repeating the signal coming

in from one circuit and re-transmitting it to another. Relays were used extensively in telephone

exchanges and early computers to perform logical operations.

A type of relay that can handle the high power required to directly control an electric motor or

other loads is called a contactor. Solid-state relays control power circuits with no moving parts,

instead using a semiconductor device to perform switching. Relays with calibrated operating

characteristics and sometimes multiple operating coils are used to protect electrical circuits from

overload or faults; in modern electric power systems these functions are performed by digital

instruments still called "protective relays".

1.12.1 Design and operation:

A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core, an iron

yoke which provides a low reluctance path for magnetic flux, a movable iron armature, and one

or more sets of contacts (there are two in the relay pictured). The armature is hinged to the yoke

and mechanically linked to one or more sets of moving contacts. It is held in place by a spring so

that when the relay is de-energized there is an air gap in the magnetic circuit. In this condition,

one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other

relays may have more or fewer sets of contacts depending on their function. The relay in the

picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit

between the moving contacts on the armature, and the circuit track on the printed circuit

board (PCB) via the yoke, which is soldered to the PCB.

When an electric current is passed through the coil it generates a magnetic field that activates the

armature and the consequent movement of the movable contact either makes or breaks

(depending upon construction) a connection with a fixed contact. If the set of contacts was closed

when the relay was de-energized, then the movement opens the contacts and breaks the

connection, and vice versa if the contacts were open. When the current to the coil is switched off,

the armature is returned by a force, approximately half as strong as the magnetic force, to its

relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in

industrial motor starters. Most relays are manufactured to operate quickly. In a low-voltage

application this reduces noise; in a high voltage or current application it reduces arcing.

68

Page 69: 4 Channel Rf Remote Control Device

When the coil is energized with direct current, a diode is often placed across the coil to dissipate

the energy from the collapsing magnetic field at deactivation, which would otherwise generate

a voltage spike dangerous to semiconductor circuit components. Some automotive relays include

a diode inside the relay case. Alternatively, a contact protection network consisting of a capacitor

and resistor in series (snubbed circuit) may absorb the surge. If the coil is designed to be

energized with alternating (AC), a small copper "shading ring" can be crimped to the end of the

solenoid, creating a small out-of-phase current which increases the minimum pull on the armature

during the AC cycle.[1]

A solid-state relay uses a thruster or other solid-state switching device, activated by the control

signal, to switch the controlled load, instead of a solenoid. Anoptocoupler (a light-emitting

diode (LED) coupled with a photo transistor) can be used to isolate control and controlled

circuits.

Fig: Relay switches

Relay internal circuit:

69

Page 70: 4 Channel Rf Remote Control Device

Fig: Normally closed Fig: Normally open

NORMALLY CLOSED RELAYS:

The operation of a Normally Closed relay is the same to that of a Normally Open relay,

Except backwards. In other words, when the relay control coil is NOT energized, the relay

Switch contacts are closed, completing the circuit through pins 2 and 4. When the control

Coil is energized, the relay switch contacts opens, which breaks the circuit open and no

Continuity exists between pins 2 and 4.

DE - ENERGIZED (OFF) ENERGIZED (ON)

70

Page 71: 4 Channel Rf Remote Control Device

1.13 Linear keypad:

This section basically consists of a Linear Keypad. Basically a Keypad can be classified into 2

categories. One is Linear Keypad and the other is Matrix keypad.

Matrix Keypad: This Keypad got keys arranged in the form of Rows and Columns. That is why the name

Matrix Keypad. According to this keypad, In order to find the key being pressed the keypad need to be

scanned by making rows as i/p and columns as output or vice versa.This Keypad is used in places where

one needs to connect more no. Of keys with less no. Of data lines.

Linear Keypad: This Keypad got ‘n’ no. Of keys connected to ‘n’ data lines.This Keypad is used in places

where one needs to connect less number Of keys

1.14 LED(Lighting Emitting Diodes):

It is a semiconductor diode having radioactive recombination. It requires a definite amount

of energy to generate an electron-hole pair.

The same energy is released when an electron recombines with a hole. This released energy

may result in the emission of photon and such a recombination. Hear the amount of energy

released when the electro reverts from the conduction band to the valence band appears in the

form of radiation. Alternatively the released energy may result in a series of phonons causing

lattice vibration. Finally the released energy may be transferred to another electron. The

recombination radiation may be lie in the infra-red and visible light spectrum. In forward is

peaked around the band gap energy and the phenomenon is called injection luminescence. I n a

junction biased in the avalanche break down region , there results a spectrum of photons carrying

much higher energies . Almost White light then gets emitted from micro-plasma breakdown

region in silicon junction. Diodes having radioactive recombination are termed as Light

Emitting Diode, abbreviated as LEDs.

71

Page 72: 4 Channel Rf Remote Control Device

In gallium arsenide diode, recombination is predominantly a radiation recombination and

the probability of this radio active recombination far exceeds that in either germanium or silicon .

Hence Ga As LED has much higher efficiency in terms of

Photons emitted per carrier. The internal efficiency of Ga As LED may be very close to 100% but

because of high index of refraction, only a small fraction of the internal radiation can usually

come out of the device surface. In spite of this low efficiency of actually radiated light , these

LEDs are efficiency used as light emitters in visual display units and in optically coupled circuits,

The efficiency of light generation increases with the increase of injected current and with

decreases in temperature. The light so generated is concentrated near the junction since most of

the charge carriers are obtained within one diffusion length of the diode junction.

The following are the merits of LEDs over conventional incandescent and other types of lamps

1. Low working voltages and currents

2. Less power consumption

3. Very fast action

4. Emission of monochromatic light

5. small size and weight

6. No effect of mechanical vibrations

7. Extremely long life

Typical LED uses a forward voltage of about 2V and current of 5 to 10mA.

GaAs LED produces infra-red light while red, green and orange lights are produced by

gallium arsenide phosphide (GaAs) and gallium phosphide(Gap) .

Light Emitting Diodes (LEDs)

Example:        Circuit symbol:   

Function

72

Page 73: 4 Channel Rf Remote Control Device

LEDs emit light when an electric current passes through them.

5. Circuit Description:

RF Modules are used wireless transfer data. This makes them most suitable for remote control

applications, as in where you need to control some machines or robots without getting in touch

with them (may be due to various reasons like safety, etc). Now depending upon the type of

application, the RF module is chosen. For short range wireless control applications, an ASK RF

Transmitter-Receiver Module of frequency 315 MHz or 433 MHz is most suitable. The main

objective of this project is to control the traffic, whenever any time any VIP is coming in that way

by using RF TRANSMITTER section send the message to that RF RECEIVER. RF RECEIVER

will receive that information given to the micro controller, in that particular way green light will

73

Page 74: 4 Channel Rf Remote Control Device

be ON for clearing the traffic and remaining ways stopped by indicating red light. Whenever

VIPs entering in that particular way then entered the keys for exiting in that way then also they

can enter the keys. The same procedure will be followed by four sides of the road. The signaling

from the four sides will be taken into consideration.

SOFTWARE COMPONENTS

ABOUT SOFTWARE

Software used is:

*Keil software for C programming

*Express PCB for lay out design

*Express SCH for schematic design

74

Page 75: 4 Channel Rf Remote Control Device

KEIL µVision3

What's New in µVision3?

µVision3 adds many new features to the Editor like Text Templates, Quick Function Navigation,

and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and

debugger setup. µVision3 is fully compatible to µVision2 and can be used in parallel with

µVision2.

What is µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile, and

debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

Editor.

A powerful debugger.

Express PCB

Express PCB is a Circuit Design Software and PCB manufacturing service. One

can learn almost everything you need to know about Express PCB from the help topics included

with the programs given.

Details:

Express PCB, Version 5.6.0

Express SCH

The Express SCH schematic design program is very easy to use. This software

enables the user to draw the Schematics with drag and drop options.

A Quick Start Guide is provided by which the user can learn how to use it.

Details:

75

Page 76: 4 Channel Rf Remote Control Device

Express SCH, Version 5.6.0

EMBEDDED C:

The programming Language used here in this project is an Embedded C

Language. This Embedded C Language is different from the generic C language in few things

like

a) Data types

b) Access over the architecture addresses.

The Embedded C Programming Language forms the user friendly language with access over Port

addresses, SFR Register addresses etc.

Embedded C Data types:

Data Types Size in Bits Data Range/Usage

unsigned char 8-bit 0-255

signed char 8-bit -128 to +127

unsigned int 16-bit 0 to 65535

signed int 16-bit -32,768 to +32,767

sbit 1-bit SFR bit addressable only

bit 1-bit RAM bit addressable only

sfr 8-bit RAM addresses 80-FFH

only

Signed char:

o Used to represent the – or + values.

76

Page 77: 4 Channel Rf Remote Control Device

o As a result, we have only 7 bits for the magnitude of the signed number, giving us values

from -128 to +127.

6. SOFTWARE

µVision3

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile, and

debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

77

Page 78: 4 Channel Rf Remote Control Device

Editor.

A powerful debugger.

To help you get started, several example programs (located in the \C51\Examples, \C251\

Examples, \C166\Examples, and \ARM\...\Examples) are provided.

HELLO is a simple program that prints the string "Hello World" using the Serial

Interface.

Building an Application in µVision2

To build (compile, assemble, and link) an application in µVision2, you must:

1. Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV2).

2. Select Project - Rebuild all target files or Build target.

µVision2 compiles, assembles, and links the files in your project.

1.17 Creating Your Own Application in µVision2

To create a new project in µVision2, you must:

1. Select Project - New Project.

2. Select a directory and enter the name of the project file.

3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the

Device Database™.

4. Create source files to add to the project.

5. Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and add the

source files to the project.

6. Select Project - Options and set the tool options. Note when you select the target device

from the Device Database™ all special options are set automatically. You typically only

need to configure the memory map of your target hardware. Default memory model

settings are optimal for most applications.

7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.

78

Page 79: 4 Channel Rf Remote Control Device

2. Use the Step toolbar buttons to single-step through your program. You may enter G,

main in the Output Window to execute to the main C function.

3. Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

Starting µVision2 and creating a Project

µVision2 is a standard Windows application and started by clicking on the program icon. To

create a new project file select from the µVision2 menu

Project – New Project…. This opens a standard Windows dialog that asks you for the new

project file name.

We suggest that you use a separate folder for each project. You can simply use the icon Create

New Folder in this dialog to get a new empty folder. Then select this folder and enter the file

name for the new project, i.e. Project1.

µVision2 creates a new project file with the name PROJECT1.UV2 which contains a default

target and file group name. You can see these names in the Project

Window – Files.

Now use from the menu Project – Select Device for Target and select a CPU for your project. The

Select Device dialog box shows the µVision2 device database. Just select the microcontroller you

use. We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary

tool options for the 80C51RD+ device and simplifies in this way the tool Configuration.

Building Projects and Creating a HEX Files

Typical, the tool settings under Options – Target are all you need to start a new

application. You may translate all source files and line the application with a click on the Build

Target toolbar icon. When you build an application with syntax errors, µVision2 will display

errors and warning messages in the Output

Window – Build page. A double click on a message line opens the source file on the correct

location in a µVision2 editor window.

Once you have successfully generated your application you can start debugging.

79

Page 80: 4 Channel Rf Remote Control Device

After you have tested your application, it is required to create an Intel HEX file to

download the software into an EPROM programmer or simulator. µVision2 creates HEX files

with each build process when Create HEX files under Options for Target – Output is enabled.

You may start your PROM programming utility after the make process when you specify the

program under the option Run User Program #1.

CPU Simulation

µVision2 simulates up to 16 Mbytes of memory from which areas can be mapped for read, write,

or code execution access. The µVision2 simulator traps and reports illegal memory accesses

being done.

In addition to memory mapping, the simulator also provides support for the integrated peripherals

of the various 8051 derivatives. The on-chip peripherals of the CPU you have selected are

configured from the Device

Database selection

You have made when you create your project target. Refer to page 58 for more Information about

selecting a device. You may select and display the on-chip peripheral components using the

Debug menu. You can also change the aspects of each peripheral using the controls in the dialog

boxes.

Start Debugging

You start the debug mode of µVision2 with the Debug – Start/Stop Debug Session command.

Depending on the Options for Target – Debug Configuration, µVision2 will load the application

program and run the startup code µVision2 saves the editor screen layout and restores the screen

layout of the last debug session. If the program execution stops, µVision2 opens an editor

window with the source text or shows CPU instructions in the disassembly window. The next

executable statement is marked with a yellow arrow. During debugging, most editor features are

still available.

80

Page 81: 4 Channel Rf Remote Control Device

For example, you can use the find command or correct program errors. Program source

text of your application is shown in the same windows. The µVision2 debug mode differs from

the edit mode in the following aspects:

_ The “Debug Menu and Debug Commands” described on page 28 are Available. The additional

debug windows are discussed in the following.

_ The project structure or tool parameters cannot be modified. All build Commands are disabled.

Disassembly Window

The Disassembly window shows your target program as mixed source and assembly

program or just assembly code. A trace history of previously executed instructions may be

displayed with Debug – View Trace Records. To enable the trace history, set Debug –

Enable/Disable Trace Recording.

If you select the Disassembly Window as the active window all program step commands

work on CPU instruction level rather than program source lines. You can select a text line and set

or modify code breakpoints using toolbar buttons or the context menu commands.

You may use the dialog Debug – Inline Assembly… to modify the CPU instructions.

That allows you to correct mistakes or to make temporary changes to the target program you are

debugging.

1.18 Embedded ‘C’ :

What is an embedded system?

An embedded system is an application that contains at least one programmable computer

and which is used by individuals who are, in the main, unaware that the system is computer-

based.

Which programming language should you use?

Having decided to use an 8051 processor as the basis of your embedded system, the next key

decision that needs to be made is the choice of programming language. In order to identify a

suitable language for embedded systems, we might begin by making the following observations:

81

Page 82: 4 Channel Rf Remote Control Device

Computers (such as microcontroller, microprocessor or DSP chips) only accept

instructions in ‘machine code’ (‘object codes’). Machine code is, by definition, in the

language of the computer, rather than that of the programmer. Interpretation of the code

by the programmer is difficult and error prone.

All software, whether in assembly, C, C++, Java or Ada must ultimately be translated

into machine code in order to be executed by the computer.

Embedded processors – like the 8051 – have limited processor power and very limited

memory available: the language used must be efficient.

The language chosen should be in common use.

8. Program

1.19 For Transmitter section:

1. #include <avr/io.h>

2. #include <util/delay.h>

3. #include "usart.h"

4. // initialize adc

5. void adc_init()

82

Page 83: 4 Channel Rf Remote Control Device

6. {

7.     // AREF = AVcc

8.     ADMUX = (1&lt;&lt;REFS0);

9.  

10.     // ADC Enable and prescaler of 128

11.     // 16000000/128 = 125000

12.     ADCSRA = (1&lt;&lt;ADEN)|(1&lt;&lt;ADPS2)|(1&lt;&lt;ADPS1)|(1&lt;&lt;ADPS0);

13. }

14. // read adc value

15. uint16_t adc_read(uint8_t ch)

16. {

17.     // select the corresponding channel 0~7

18.     // ANDing with &#039;7&#039; will always keep the value

19.     // of &#039;ch&#039; between 0 and 7

20.     ch &amp;= 0b00000111;  // AND operation with 7

21.     ADMUX = (ADMUX &amp; 0xF8)|ch;     // clears the bottom 3 bits before ORing

22.   // start single conversion

23.     // write &#039;1&#039; to ADSC

24.     ADCSRA |= (1&lt;&lt;ADSC);

25.  // wait for conversion to complete

26.     // ADSC becomes &#039;0&#039; again

27.     // till then, run loop continuously

28.     while(ADCSRA &amp; (1&lt;&lt;ADSC));

29.   return (ADC);

30. }

31.  void main()

32. {

33.  char data,int_buffer[10];

34.  USARTInit(416);

35.  uint8_t data;

36.  uint16_t adc_result;

37. adc_init();

38.  while(1)

39. {

83

Page 84: 4 Channel Rf Remote Control Device

40.  adc_result=ReadADC(0);

41.  data=adc

42. UWriteData(&#039;J&#039;);

43.  UWriteData(&#039;A&#039;);

44.  UWriteData(data);

45.  UWriteData(~data);

46.  UWriteData(&#039;Z&#039;);

47.  _delay_loop_2(0);

48.       _delay_loop_2(0);

49.       _delay_loop_2(0);

50.       _delay_loop_2(0);

51.    }

52. }

1.20 For Receiver section:

1. #include <avr/io.h>

2. #include "usart.h"

3.  #include

4.  void Wait()

5. {

6.    uint8_t i;

7.    for(i=0;i&lt;50;i++)

8.    {

9.       _delay_loop_2(0);

10.       _delay_loop_2(0);

11.       _delay_loop_2(0);

12.    }

13. }

14.  void main()

15. {

16.  uint8_t i;

17.  uint8_t packet[5],data=0;

84

Page 85: 4 Channel Rf Remote Control Device

18.  DDRC|=0xFF;

19.  USARTInit(416);

20.  while(1)

21.    {

22.   while(!UDataAvailable());

23.   if(UReadData()!=&#039;A&#039;) continue;

24.   while(!UDataAvailable());

25.   if(UReadData()!=&#039;A&#039;) continue;

26.  

27.    while(UDataAvailable()!=3);

28.   //Get the packet

29.   for(i=2;i&lt;5;i++)

30.       {

31.          packet[i]=UReadData();

32.       }

33.   //Is it ok?

34.       if(packet[2]!=((uint8_t)~packet[3])) continue;

35.  if(packet[4]!=&#039;Z&#039;) continue;

36.  //The packet is ok

37.   data=packet[2];

38.     PORTC=data;

39.    TCCR1A|=(1&lt;&lt;COM1A1)|(1&lt;&lt;COM1B1)|(1&lt;&lt;WGM11);        

40.    TCCR1B|=(1&lt;&lt;WGM13)|(1&lt;&lt;WGM12)|(1&lt;&lt;CS11)|(1&lt;&lt;CS10);

41.   ICR1=4999;

42.   DDRD|=(1&lt;&lt;PD4)|(1&lt;&lt;PD5);

43.  while(1)

44.    {

45.       if(0&lt;=data&lt;=96) OCR1A=0;

46. if(97&lt;=data&lt;=135) OCR1A=97;  //0 degree

47.     if(316&lt;=data&lt;=424) OCR1A=316;  //90 degree

48. if(425&lt;=data534)       OCR1A=535;  //180 dgree

49.    }

50. }

51. }

85

Page 86: 4 Channel Rf Remote Control Device

9. Conclusion

This project is based on mainly on the home appliances by which we can control all of them at a

time so that the there would be a lot of time saving and easily handled at a time.

Integrating features of all the hardware components used have developed it. Presence of every module has

been reasoned out and placed carefully thus contributing to the best working of the unit.

Firstly, the equipment is suggested clearly and the saperate texture for them is implemented and

tested and worked out successfully

86

Page 87: 4 Channel Rf Remote Control Device

Secondly, using highly advanced IC’s and with the help of growing technology the project has been

successfully implemented.

10. Applications

1. These are mainly used in house hold appliances

2. At a time any four house hold appliances can be controlled such as fan, light, etc…

This project can be used in house hold appliances. With this project we can monitor the different

appliances in house. Thus this project makes the idea form any anotherised vehicles in the

industry.

87

Page 88: 4 Channel Rf Remote Control Device

10. References

http://maxembedded.com

http://www.lpc-uk.com

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

http://www.autoshop101.com/forms/hweb2.pdf

http://www.atmel.com/products/wireless/default.aspx

http://www.futurlec.com/Atmel/ATMEGA8.shtml

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

88

Page 89: 4 Channel Rf Remote Control Device

www.franklin.com

www.keil.com

www.8051projects.com

www.microsoftsearch.com

www.geocities.com

www.alldatasheet.com

www.bioenable.com

8051-MICROCONTROLLER AND EMBEDDED SYSTEMS.

Mohd. Mazidi.

The 8051 Micro controller Architecture, Programming & Applications

-Kenneth J.Ayala

Fundamentals Of Micro processors and Micro computers

-B.Ram

Micro processor Architecture, Programming & Applications

-Ramesh S. Gaonkar

89