Sie sind auf Seite 1von 95

LASER COMMUNICATION SYSTEM

by Kuldeep Gangwar (0701431037) Tuhina Oli (0701431084) Nitin Bhardwaj(0701431055) Mukesh Kumar(2801431005)

Department of Electronics & Communication Shri Ram Murti Smrak College of Engineering & Technology Shri Ram Murti Puram Bareilly-243202 April,2011

LASER COMMUNICATION SYSTEM


by Kuldeep Gangwar (0701431037) Tuhina Oli (0701431084) Nitin Bhardwaj(0701431055) Mukesh Kumar(2801431005)

Submitted to Department of Electronics & Communication Engineering in partial fulfillment of the requirements for the degree of Bachelor of Technology in Electronics & Communication Engineering

Shri Ram Murti Smarak College of Engineering & Technology U.P. Technical University April 2011
2

TABLE OF CONTENTS

DECLARATION...i CERTIFICATE..ii ACKNOWLEDGEMENTiii ABSTRACT..iv LIST OF TABLES.v LIST OF FIGURES..vi LIST OF SYMBOL.vii LIST OF ABBREVIATIONviii

CHAPTER 1- INTRODUCTION.. 1.1 INTRODUCTION 1.2 OPERATING PRINCIPELS CHAPTER 2-IMPLEMENTATION OF PROJECT........................................ 2.1 BLOCK DAIGRAM OF SYSTEM 2.2 CIRCUIT DAIGRAM CHAPTER 3-COMPONENTS 1.1 COMPONENTS USED CHAPTER 4-SOFTWARE ................................................................................. 1.1 CVAVR 1.2 EXPRESS PCB CHAPTER 5-DISCRIPTION OF HARDWARE 2.1 MICROCONTROLLER 2.2 LASER DIODE 2.3 PHOTO DIODE 2.4 SEVEN SEGMENT LED 2.5 ELECTRT MIC 2.6 SPEAKER CHAPTER 3- COMPONENTS USED. 3.1 COMPONENT LIST.. 3.1.1 POWER SUPPLY.. 3.1.2 DIODE.. 3.1.3 CAPACITOR. 3.1.4 VOLTAGE REGULATOR.
4

3.1.5 RESISTOR. 3.1.6 TRANSISTOR 3.1.7 CRYSTAL OSCILLATOR 3.2 MATERIAL USED AND PROCEDURE. 3.2.1 PRECAUTIONS AND USES. CHAPTER 4- GENERAL DESCRIPTION 4.1 FEATURES. 4.2 APPLICATION CHAPTER 6- CONCLUSSION 6.1 CONCLUSSION. 6.2 ADVANTAGE.. APPENDIX A. APPENDIX B.. REFERENCES..

DECLARATION

I hereby declare that this submission is our own work and that, to the best of our knowledge and belief , it contains no material previously published or written by another person nor material which to a substantial extent has been accepted for the award of any other degree or diploma of the university or other institute of higher learning, except where due acknowledge has been made in the text.

Signature: Name -Kuldeep Gangwar Roll No.:0701431037 Date:

Signature: Name: Tuhina Oli Roll No.:0701431084 Date:

Signature: Name:Nitin Bharadwaj Roll No.:0701431055 Date:

Signature: Name: Mukesh Kumar Roll No.:2801431005 Date:

CERTIFICATE

This is to certify that Project Report entitled LASER COMMUNICATION SYSTEM which is submitted by Kuldeep Gangwar, Tuhina Oli ,Nitin Bhardwaj & Mukesh Kumar in partial fulfillment of requirement for the award of degree B.Tech in Department of Electronics & Communication of U.P. Technical University is a record of the candidates owes work carried out by them under my supervision. The matter embodied in this thesis is original and has been submitted for the award of any other degree.

Date:

SUPERVISOR

Mr. ALOK KUMAR SENGAR

ACKNOWLEDGEMENT

It gives us a great sense of pleasure to present the report of B.Tech Project undertaken during B.Tech Final Year. We owe special debt of gratitude to Mr. Alok Kr Sengar, Department of Electronics & Communication, Shri Ram Murti Smarak College of Engineering & Technology, Bareilly for his constant support and guidance throughout the course of our work. His sincerity, thoroughness and perseverance have been a constant source of inspiration for us. It is only his cognizant efforts that our endeavors have seen light of the day. We also take the opportunity to acknowledge the contribution of Mr B.R Dutta, Head Department of Electronic & Communication, Shri Ram Murti Smarak College of Engineering & Technology, Bareilly for his full support and assistance during the development of the project. We also do not miss the opportunity to acknowledge the contribution of all faculty member of the department for their kind assistance and cooperation during the development of our project. Last but not the least, we acknowledge our friends for their contribution in the completion of the project.

Signature: Name -Kuldeep Gangwar Roll No.:0701431037

Signature: Name: Tuhina Oli Roll No.:0701431084

Signature: Name:Nitin Bharadwaj Roll No.:0701431055 DATE-:

Signature: Name: Mukesh Kumar Roll No.:2801431005

ABSTRACT

In this project we have shown the communication system using a controller of family of ATMEGA i.e ATMEGA32 . We have shown the concept for transmitting the voice and data through laser light. In this project we have displayed that how we will modulate the data either voice or text in the optical format and to transmit it with the help of a laser diode at transmitter end and to decode it at receiver end. The project is meant for line of sight application i.e. transmitter & receiver are present at line of sight distance. Here no physical media is required for transmission and the data is far more secure and noise free compare to the data travelling in wires or links .Moreover minimum overheads are required for transmission of data through optical means. The system is simplex consisting of single transmitter and receiver and air between them

LIST OF TABLE

TABLE
Table 3.1 Color coding resistor Table 3.2 Capacitor marking

PAGE

10

LIST OF FIGURE
FIGURE
Figure 1.1 Block Diagram Figure 2.1 Internal architecture of ATMEGA32 Figure 2.2 Pin diagram Figure 2.3 Microcontroller versus microprocessor Figure 2.4 Input/output port Figure 2.5 Central processing unit Figure 3.1 Power supply Figure 3.2 Internal block diagram Figure 3.3 Connection of RS32 With microcontroller Figure 3.4 Complete Setup Figure 4.1 Circuit Diagram of Ttransmitter (voice) Figure 4.2 Circuit Diagram of Receiver (voice) Figure 4.3 Circuit Diagram of Transmitter (data) Figure 4.4 Circuit Diagram of Receiver (data) Figure 4.5 Circuit Diagram Figure A Structure and symbol of P-N-P transistor
11

PAGE

Figure B (a)P-N-P transistor biasing (b) N-P-N transistor biasing

LIST OF SYMBOLE

Voltage Current Micro farad Ohm Hertz Not equal Equal Divide Watt Mega Kilo

V I F Hz = W M K

12

LIST OF ABBREVIATIONS

1. LED

Light emitting diode Complementary metal oxide semiconductor Semiconductor material devices Erasable programmable read only memory Light emitting diode Input/Output Port Analog to digital convertor Charged coupled device Perry equipment and engineering company Vibratory feeder corporation Programmable and erasable read only memory Random access memory Arithmetic and logical unit One time programmable read only memory Electrical erasable read only memory

2. CMOS 3. SMD 4. EPROM


5. LED 6. I/O Port 7. A/D Convertor

8. CCD 9. PEECO 10. VFC 11. PEROM 12. RAM 13. ALU 14. OTPROM 15. EEROM

13

CHAPTER 1 INTRODUCTION

14

CHAPTER 1 INTRODUCTION
In this chapter we have introduced our project and its basic working , the thoughts and ideas regarding project are mentioned here . The project is basically a media free communication system that uses laser light for carrying the information . 1.1 INTRODUCTION Laser Communication may prove as a efficient way of communication in near future.the most advantageous feature of laser communication is minimum amount of overheads it dealt with. It involves transmission of data in a smart and efficient way. As it do not require any of the physical media so the burden in system is low but besides other system that are media free but involves lot of loss & distortion due to scattering interference & multipath it is far more secure and error free transmission method. Since there exits some of the shortcomings of every system and this one too is not an exception.The limitation of the system is that it is valid only for LOS (line of sight distance) i.e. the transmitter and receiver should be visible to each other only then transmission and reception will prove fruitful. Advantageous feature are Security Correctness Less over heads

15

1.2 OPERATING PRINCIPLE


The system comprising of :

DIP switch that decides weather we are transmitting data or voice

VOICE

DATA

TRANSMITTER -MIC
is used

TRANSMITTER
-Data provided by pushing switches -values are received in MCU

-Amplified through IC 741 (pre-amplification) -Send to push pull amplifier (power amplification) -Rheostat for varying gain -Transmission through laser diode

- values are stored in transmitting buffer -optical signals are transmitted laser diode

RECEIVER -Reception through photo diode


-passed through IC 741

RECEIVER
- data received through photo diode -apropriate signals are sensed
16

-passed through push pull amplifier -Gain is adjusted through rheostat -Given to speaker

-respective signals displayed in LED

CHAPTER 2 IMPLEMENTING PROJECT

In this chapter we will discuss about how we have implemented the basic ideas which we have described in introduction of our project. This chapter deals with block diagram representation and circuit diagram of project.

2.1 BLOCK DAIGRAM The block diagram consist Transmitter part , Receiver part and LASER LIGHT system. They have separate circuitry. The Transmitter and Receiver communicate with each other through AIR interface . In data transmission where we make use of ATMEGA32, is interfaced with our laser diode . While in voice communication we have used a push pull amplifier system for transmission part. At receiver side in case of data we have interfaced a 7-segment LED with our microcontroller and a photo diode. In voice transmission again a push pull amplifier is being used.

17

BLOCK DIAGRAM DIGITAL DATA TRANSMITTER


keypad as digital data source laser diode as transmitt erer

DIGITAL DATA RECEIVER


Photodiode as receiv er
Atmega3 2 as

atmega32

as mcu

MCU

7 segme nt display

voltage regulator IC7805

Power supply 12V

AUDIO TRANSMITTER
Pre -amplifie r opm741

Electrets mic

Push-pull amplifier

Laser diode

Tx
laser beam

Rx
speaker Push-pull amplifier RECEIVER Pre -amplifie r opm741 Photodiode

AUDIO

18

2.2 CIRCUIT DAIGRAM


2.2.1 AUDIO TRANSMITTER PART:

2.2.1 AUDIO RECEIVER PART:

19

2.2.2 DATA TRANSMITTER PART

2.2.2 DATA RECEIVER PART

20

FLOW DIAGRAM: 10 push switches


connect ed to PORTA

start

Data

Data or voice

Voice

Electret

mic
Preampli fier than power amplifier (push pull amp)

Atmega32 PORTA & C are input port.TXD PIN 15 as transmitte r

o/p from PIN15 to laser diode

o/p from push pull is given to laser diode

laser beam
Photodiode as detector at PIN14 of MCU ATMEGA32 PORTB as o/p port. PIN14 receives laser beam data o/p from PORTB.0 PORTB.6 to 7 segmen t

laser beam
Photodio de as detector

Preamplifie d voice is than power amplified

o/p from pushpull is given to speaker

7 segment LED display

21

CHAPTER 3 COMPONENETS

CHAPTER 3 COMPONENT
22

This chapter deals with different components used for implementing the circuitry . this mainly comprises of resisters, capcitors, transisters, 7-segment display and ICs. This chapter is most important in regard with project because this chapter specifies the correct value of different component and their description.

3.1 COMPONENTS USED


Sr. no.
1. 2. 3. 4. 5. 6.

Components Microcontroller ATMEGA32 Laser Diode Photo Diode Opamp IC 741 7-segment LED Resistance(ohm)

Quantity 2 1 1 1 1

100 470 560 1K 4K 10 K

1 1 7 1 4 7

7.

Capacitances

0.1uF 33pF 220uF

4 4 2 2 2
23

8.

Potentiometer (1M) 7805 Voltage Regulator

9.

10.

Crystal 4 Mhz LED Diode IN4007 Push Switches

2 1 6 9

11.
12. 13.

3.1 LASER DIODE:

Laser, the wonder beam of this century apart from fuelling science fictions stories, is increasingly becoming a real force in our lives. The term laser is an acronym for Light Amplification by Stimulated Emission of Radiation or a light amplifier. These days laser beam has made its diversified characteristic potentialities in different fringes of Science and Technology. The laser originally got its finding by Einstein was further developed in 1960's. The magic behind the laser is its 'coherence'. This term means that the light from a laser is highly directional and rather than emerging from the source as the characteristic cone of the flashlight, appears as a sharp straight beam, a sort of clothesline to eternity. Multifaced application of laser in the development of science and technology made this wonder beam equally prolific for men and machine. In the developed countries it provided ease, but in developing countries, still in a process of gaining new dimensions to its applicability. In India it has been widely in practice in industries, defence, medicine, surgery and scientific research.

3.1.1 RED LASER DIODE (DL-3149-057)


3.1.1.1 Features Short wavelength : 670 nm (Typ.) Low threshold current : Ith = 25 mA (Typ.) High operating temperature : 5 mW at 60C Small package : 5.6 mm

24

3.1.1.2 Applications Laser beam printer Bar-code scanner

3.1.2 HOW ARE LASER BEAM PRODUCED?


A device that employs the principle of amplification of electromagnetic waves by stimulated emission of radiation and operates in the infrared, visible, or ultraviolet, region. Just as an electronic amplifier can be made into an oscillator by feeding appropriately phased out back into output, so the laser light amplifier can be made into a laser oscillator, which is really a light source. The stimulated emission can be interpreted well, when atoms, ions, or molecules absorb energy, they can emit light spontaneously (as in an incandescent lamp) or they can be stimulated to emit by a light wave. This stimulated emission is the opposite of absorption., where unexcited matter is stimulated into an excited state by a light wave. If the accumulated atoms are pumped which are in excited or unexcited state, then an incident light wave will stimulate more emission than absorption, and there is net amplification of the incident light beam. This is the way of the laser amplifier functions. Laser amplifier can be made into the laser oscillator by adjusting suitable mirrors on either end of the amplifier. These are called resonators. Thus the essential parts of a laser oscillator are an amplifying medium, a source of pump power, and resonator. Radiation that is directed straight along the axis bounces back and forth between the mirrors and can remain in the resonator long enough to build up a strong oscillation. Wave oriented in other directions soon pass off the edge of the mirrors and are lost-before they are much amplified. The produced radiation can be coupled out by making one mirror partially transparent, so that part of the amplified light can emerge through it. The produced wave, like most of the waves being amplified between the mirrors, travels along the axis and is thus very nearly a plane wave.

3.1.3 ORIGIN OF LASER BEAM

25

The idea of laser beam emerged in the late 1950s and began developing the device the early 1960s. The Laser research grew out of earlier studies of microwave amplifying devices called masers. As a result, early lasers were also called masers. The term MASER stands for Microwave Amplification by Stimulated Emission of Radiation. A maser is a microwave amplifier which produces highly directional and coherent microwaves with just one frequency. Two United States physicists, Arthur L.Schawlow and O.H. Towns, first proposed the idea of laser in 1958. Originally laser proposed by Einstein developed in the 60s. In 1961, Ali Javan, another US physicist, operated the first gas laser. The semiconductor lasers were initially operated in 1962 by the separate teams of US scientists. The first liquid laser was operated in 1966 by Peter Sorking of United States. The application of laser mirror was first used in 1969 by the Astronauts on the Apollo II mission on Moon. It was called laser reflector. Scientists used this device to measure precisely the distance between the earth and the moon. It was called laser reflector. Scientists used this device to measure precisely the distance between the earth and the moon. They did so by measuring the time required by a laser beam to travel to the reflector and back. Laser applications increases steadily during the 1970s and early 1980's. These days much laser research involves the development of new kinds of lasers.

3.1.4

LASER

COMPARISON

WITH

CONVENTIONAL

LIGHT

SOURCES
In the contrast to lasers, all conventional light sources are basically hot bodies which radiate by spontaneous emission. The electrons in the tungsten filament of an incadescent lamp are agitated by and acquire excitation from the high temperature of the filament. Once excited, they emit light in all directions and revert to a lower energy state, and they soon give up this excitation energy by radiating it as light. In all the above, spontaneous emission from each excited electron or atom takes place independently of emission from the others. Thus the overall wave produced by a conventional light source is a jumble of waves from numerous individual atoms. The phase of wave emitted by one atom has no relation to the phase emitted by any other atom. So that the total phase of the light fluctuates randomly from moment to moment and place to place.

26

The hot bodies emit more or less equally in all directions radiation whose wavelength distribution is dictated by the Planack black body radiation curve. For example, the surface of the sun radiates like a black body at a temperature of about 6000 K, and emits a total of 7 KW/cm2, spread out over all wavelengths and directions. Light from gas lamps can be more monochromatic but radiation still occurs in all directions. In contrast to this an ideal plane wave would be highly predictable (coherent). The output of the parallel plate laser described above is very nearly such plane wave and is, therefore, highly directional. There are varieties of lasers and their various applicabilities are classified according to their pumping or (excitation) method. The function of pumping method is to maintain more atoms in the upper than in the lower state, thereby assuring that (stimulated) absorption (loss transition). This is called inversion ensure

net gain.

3.1.5 TYPES OF LASERS


The various types of lasers and their applications are discussed below, and it is classified according to their pumping (or excitation) methods. The important lasers which are in practice in these days are:-

1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

Optically pumped lasers Gas discharged lasers Pulsed gas lasers Chemical lasers Photo dissociation lasers Nuclear lasers Gas-dynamic lasers Semiconductor lasers Free-electron lasers High-power lasers
27

3.1.5.1 OPTICALLY PUMPED LASER


Simple method to achieve population inversion is by concentrating light (for example, from a flash lamp or the sun) onto the amplifying medium. Alternatively lasers may be used to optically pump other lasers. Molecular lasers, like deuterium cyanide (DCN) are used to lease powerfully in to fat infrared, operating out to several hundred micrometers wavelength. The pumping method can be made applicable to pump gas at high pressure to obtain tunability where other excitation methods would be difficult if not impossible to implement. Three-and Four-Level Lasers: Many lasers are three-level lasers in which is ground state atoms are excited by absorption of light to a broad upper energy state, from which they quickly relax to the emitting state, laser action occurs as they are stimulated to emit radiation and so return to original ground state. The most suitable thing found for the ground state is crystalline glass, liquid and gaseous systems, but many possible materials are remained to be explored. Solid three-level lasers usually make use of ions of a rare-earth element, such as neodymium, or of a transitional metal, such as a chromium, dispersed in a transition metal such as chromium dispersed in a transparent crystal or glass. Majority of rare-earth ion lasers use a fourth level above the ground state. This level serves as a terminal level for the laser transition, and it is kept empty by rapid non-radioactive relaxation to the ground state. This means that, relative to three-level systems, a population inversion is easier to maintain, and therefore such materials require relatively low pumping light intensity for laser action. Structure of Pumped lasers: The structure of optically pumped solid-state could be as simple as a rod of the light-amplifying material with parallel end polished and coated to produce reflection. The produced radiation can penetrate either through the transparent sides or the ends. Other structures can be used. The mirrors end can be spherical rather than plane, with common focal point of the two mirrors lying half way between them.

28

Structure of Liquid Lasers: The structure of liquid lasers are generally like those of optically pumped solid-state lasers, except that the liquid is generally contained in a transparent cell. Some liquid lasers make use of organic dye solutions. The dyes can lase over a wide range of wavelengths, depending upon the composition and concentration of the dye solvent. Thus tunability is obtained throughout the visible and up to a wavelength of about 0.9 micrometers.

3.1.5.2 GAS-DISCHARGED LASERS


Gas-discharged laser is another wide-range of lasers which make use of nonequilibrium process in a gas discharge. At moderately low pressure (of the order of torr or 10 2 pascals) and fairly high current, the population of energy levels is far from an equilibrium distribution. Some levels are populated especially rapidly by the fast electrons in the discharge. Other levels empty particularly slowly and so accumulate large numbers of excited atoms. Thus laser action can occur at any wavelength in any of a large number of gases under suitable circumstances. For some gases, a continuous discharge, with the use of either direct or radio-frequency current, gives continuous laser action. Output powers of continuous gas lasers range from less than 1 microwatt up to about 100 W in the visible region. Wavelengths generated span the ultraviolet spectrum and vision regions and extend beyond 700 micro m with infrared. They thus provide the first intense sources of radiation in much of the far infrared region of the

3.1.5.3 PULSED GAS LASERS


Pulsed gas discharges permit a further departure from equilibrium. Thus pulsed laser action can be obtained in some additional gases which could not be made to the lase continuously. In some of them the length of the laser state is filled by stimulated transition from the upper level, and so introduces absorption at the laser wavelength. Nitrogen Lasers: It is a self-determining laser, which gives pulses of several nanoseconds duration with peak powers from tens of kilowatts up to a few megawatts at a wavelength of 337 nm in the ultraviolet region. There are easy to produce and are such used for pumping tunable dyne lasers throughout the wavelength range from about 350 to 1000mm.
29

Hydrogen Lasers: Very powerful laser radiation in the vacuum ultraviolet region between 100 to 200 nm can be obtained from short pulse discharges in hydrogen, and in rare gases such as xenon at high pressure, (High pressure leads to higher power). When the gas pressure is too high to permit an electric discharge, excitation may be provided by an intense burst of fast electrons from a small accelerator the so called E beam. Gases like carbon dioxide, which provide continuous laser action, also can be used to generate intense pulses of microsecond duration. For this purpose, gas pressure of about 1 atm(105 Pa) are used and the electrical discharge takes place across the diameter of the laser column, hence the name transverse-electrical-atmosphere (TEA) laser.

3.1.5.4 CHEMICAL LASERS


Chemical lasers can be produced by the energy released in some fast chemical reactions. Atoms or molecules produced during the reaction are often may be enough atoms or molecules excited to some particular state for amplification to occur by stimulated emission. Usually the reacting gases are mixed and then ignited by ultraviolet light or fast-electrons. Both continuous infrared output and pulses up to several thousand joules of energy have been obtained in reactions which produce excited hydrogen fluorides molecules.

3.1.5.5 PHOTO DISSOCIATION LASERS


The intense pulses of ultraviolet light can dissociate molecules in such a way as to have constituent in an excited state capable of sustaining laser action. Iodine compounds are notably having peak 1.3 micro m pulse powers above 109 W from the excited iodide atoms.

3.1.5.6 NUCLEAR LASERS


In the process of nuclear fusion where the fast moving ions are in excited state are also produced nuclear lasers. These fusion products excite and ionise the gas atom, and make it possible to convert directly from nuclear to optical energy.

3.1.5.7 SEMICONDUCTOR LASERS


The excitation produced by using semiconducting materials are known as semiconductors lasers. The process activates when the free electrons movement begins in the conduction band stimulated to recombine with holes in the valence band. In recombining the electrons give up
30

energy corresponding nearly to the band gap. This energy is radiated as a light quantum. Gallium arsenide is the best suited material to be used. The main features of the suitable materials producing semiconductor lasers are direct-gap semi conductors. In this kind of material recombination occurs directly without the emission or absorption of a quantum of lattice vibrations. A flat junction between p-type and n-type material may be used. When the current is passed through this junction in the forward direction a large number of holes and electrons are brought together. This is called recombination and is accompanied by emission of radiation. A light wave passing along the plane of the junction can be amplified by stimulating such recombination of electrons and holes. The ends of the semiconducting crystal provide the mirrors to complete the structure. Semiconductor lasers can be very small less than 1mm in any direction. They can have efficiencies higher than 50% (electricity to light). Power densities are high, but the thinness of the active layer tends to limit the total output power. Even so, maximum continuous power are comparable with those of other moderate-size lasers.

3.1.5.8 FREE-ELECTRON LASERS


It is laser of its own kind, which converts the kinetic energy in an electron beam to electromagnetic radiation. Since it is relatively simple to generate electron because with peak powers of 1010 W, the free-electron laser has the potential for providing high optical power, and since there are non prescribed energy levels, as in the conventional laser, the free electrons loses can be operate over a wide frequency range.

3.1.5.9 HIGH POWER, SHORT PULSE LASERS


This kind of laser can be generated by mode-locking techniques. A typical laser without mode locking normally oscillates simultaneously and independently at several closely spaced wavelengths. These modes of oscillation can be synchronised so that the peaks of their waves occur simultaneously at some instant. The result is very short, intense, pulse which quickly ends as the waves of different frequencies get out of step.

31

3.1.4 APPLICATIONS OF LASERS


The variety of technological uses for lasers have increased steadily since their finding was advocated in the 1960s. Among the noticeable applications are those that utilise high-speed controllability of the tiny focal spot of a laser beam. For example, high speed automatic scanners identify library cards, skipasses, and supermarket purchases and perform a variety of functions known as optical processing. Further applications involving high power include weaponry, laser welding laser surgery, laser fusion and material processing. Optical communication utilise the laser's high frequency which makes possible high information capacity. Except for space applications, laser light communications is primarily done through glass fibres. Fiber optic laser telephone systems are presently in operation in many cities around the world. IN COMMUNICATIONS: Laser's noticeable applications are those which utilise high-speed controllability of the tiny focal spot which is the wonder of laser beam. In recent days application of lasers in communication technologies marked tremendous successes. Laser can transmit voice messages and television signals. It has great advantages over ordinary electronic transmitters, such as those used to produce radio and television signals. For example, a laser operates at a much higher frequency than do electronic transmitters. The high frequency of laser light enables a laser beam to carry much more information than radio waves can. Therefore, one of these beams can transmit many telephone calls and television programmes at the same time. The specific character of laser is that, it can transmit information with little inference because it produces a highly directional beam. A laser beam can be directed to fall solely on the desired laser-receiving equipment because the equipment receives only three beams aimed at it, so most interference is eliminated. It also has a highly, directional beam which enables it to

32

serve as an efficient long-distance transmitter. Laser beams, unlike radio waves, spread only slightly as they travel. It has been well accepted by the scientists that further advancement of laser beam may provide excellent communication link with space craft and submerged submarines. Recently the concept of "Information Highway" to make easy the communication have came into existence by the utilisation of optical fibre. The two sort of things lasers and optical fibre made possible to send laser beam carrying communications signals from one relay station to another through the glass fibre and can travel great distances with little loss of energy or clarity. Lasers applications are also equally advantageous in other communication devices including high speed photocopiers and printers compact disk players and some video players.

3.2 RESISTANCE
Resistance is the opposition of a material to the current. It is measured in Ohms ( ). All conductors represent a certain amount of resistance, since no conductor is 100% efficient. To control the electron flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is fixed & cannot be varied. In variable resistors, the resistance value can be varied by an adjuster knob. It can be divided into (a) Carbon composition (b) Wire wound (c) Special type. The most common type of resistors used in our projects is carbon type. The resistance value is normally indicated by colour bands. Each resistance has four colours, one of the band on either side will be gold or silver, this is called fourth band and indicates the tolerance, others three band will give the value of resistance (see table). For example if a resistor has the following marking on it say red, violet, gold. Comparing these coloured rings with the colour code, its value is 27000 ohms or 27 kilo ohms and its tolerance is 5%. Resistor comes in various sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its body tells us the value of resistor value as given below.

33

COLOURS

CODE

Black-----------------------------------------------------0 Brown----------------------------------------------------1 Red-------------------------------------------------------2 Orange---------------------------------------------------3 Yellow---------------------------------------------------4 Green-----------------------------------------------------5 Blue-------------------------------------------------------6 Violet-----------------------------------------------------7 Grey------------------------------------------------------8 White-----------------------------------------------------9

3.1.1 DIFFERENT TYPES OF RESISTANCES

The first rings give the first digit. The second ring gives the second digit. The third ring indicates the number of zeroes to be placed after the digits. The fourth ring gives tolerance (gold 5%, silver 10%, No colour 20%). In variable resistors, we have the dial
34

type of resistance boxes. There is a knob with a metal pointer. This presses over brass pieces placed along a circle with some space b/w each of them. Resistance coils of different values are connected b/w the gaps. When the knob is rotated, the pointer also moves over the brass pieces. If a gap is skipped over, its resistance is included in the circuit. If two gaps are skipped over, the resistances of both together are included in the circuit and so on. A dial type of resistance box contains many dials depending upon the range, which it has to cover. If a resistance box has to read upto 10,000 , it will have three dials each having ten gaps i.e. ten resistance coils each of resistance 10 . The third dial will have ten resistances each of 100 . The dial type of resistance boxes is better because the contact resistance in this case is small & constant.

3.2 CRYSTAL OSCILLATOR


XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be configured for use as an On-chip Oscillator, as shown in Figure 12. Either a quartz crystal or a ceramic resonator may be used. The CKOPT Fuse selects between two different Oscillator amplifier modes. When CKOPT is programmed, the Oscillator output will oscillate will a full rail-to-rail swing on the output. This mode is suitable when operating in a very noisy environment or when the output from XTAL2 drives a second clock buffer. This mode has a wide frequency range. When CKOPT is unprogrammed, the Oscillator has a smaller output swing. This reduces power consumption considerably. This mode has a limited frequency range and it can not be used to drive other clock buffers.

Figure . Crystal Oscillator Connections


35

3.3 MICROPHONE
Microphones, speakers and headphones are components commonly used as the input and output devices of many circuits. A microphone converts sound waves into electrical signals that closely follow the waveform of the sound being received. This signal is then amplified by the circuit and transformed into a sound by a speaker or headphone. The symbols for these components are shown in figure.

3.4 LIGHT EMITTING DIODE


Light emitting diode (LED) is basically a P-N junction semiconductor diode particularly designed to emit visible light. There are infrared emitting LEDs which emit invisible light. The LEDs are now available in many colours red, green and yellow. A normal LED emits at 2.4V and consumes MA of current. The LEDs are made in the form of flat tiny P-N junction enclosed in a semi-spherical dome made up of clear coloured epoxy resin. The dome of a LED acts as a lens and diffuser of light. The diameter of the base is less than a quarter of an inch. The actual diameter varies somewhat with different makes. The common circuit symbols for the LED are shown in Fig. It is similar to the conventional rectifier diode symbol with two arrows pointing out. There are two leads- one for anode and the other for cathode. LEDs often have leads of dissimilar length and the shorter one is the cathode. All manufacturers do not strictly adhere this to. Sometimes the cathode side has a flat base. If there is doubt, the polarity of the diode should be identified. A simple bench method is to use the ohmmeter incorporating 3-volt cells for ohmmeter function. When connected with the ohmmeter: one way there will be no deflection and when connected the other way round there will be a large deflection of a pointer. When this occurs the anode lead is connected to the negative of test lead and cathode to the positive test lead of the ohmmeter.

36

If low range (Rxl) of the ohmmeter is used the LED would light up in most cases because the low range of ohmmeter can pass sufficient current to light up the LED. Another safe method is to connect the test circuit shown in Fig. 2. Use any two dry cells in series with a current limiting resistor of 68 to 100 ohms. The resistor limits the forward diode current of the LED under test to a safe value. When the LED under test is connected to the test terminals in any way: if it does not light up, reverse the test leads. The LED will now light up. The anode of the LED is that which is connected to the A terminal (positive pole of the battery). This method is safe, as reverse voltage can never exceed 3 volts in this test.

3.4.1 ELECTRICAL CHARATERISTIC OF LED


Electrically, a LED is similar to the conventional diode in that it has relatively low forward voltage threshold. Once this is exceeded the junction has a low slope resistance and conducts current readily. An external resistor must limit this current. Forward voltage drew across red LED is nominally 1.6 V but spread with commercial diodes, it may be as high as 2 volts or so, while the Green LED drops 2.4V. This difference accounts for use of lower limiting resistor used with the Green LED. Another important parameter of the LED is its maximum reverse voltage rating. For typical Red device it is of the order of 3 volts. But for Green LED it is somewhat higher- 5 to 10 volts. The LED produces light only when a d.c. current is passed in the forward direction and the amount of light emitted by a LED is proportional to the forward current over a broad range. It means that light intensity increases in an approximately linear manner with increasing current.

3.5 POWER SUPPLY


37

3.6 VOLTAGE REGULATOR

38

3.6.1 Features Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection

3.6.2 Description The LM78XX series of three terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents. 3.6.3 Internal Block Diagram

3.6.4 ABSOLUTE MAXIMUM RATINGS

39

3.6.5 ELECTRICAL CHARACTERISTICS (LM7805)

3.6.6 TYPICAL APPLICATIONS

PHOTODIODE

40

A photodiode is a type of photodetector capable of converting light into either current or voltage, depending upon the mode of operation. The common, traditional solar cell used to generate electric solar power is a large area photodiode. Photodiodes are similar to regular semiconductor diodes except that they may be either exposed (to detect vacuum UV or X-rays) or packaged with a window or optical fiber connection to allow light to reach the sensitive part of the device. Many diodes designed for use specifically as a photodiode will also use a PIN junction rather than the typical PN junction.

PRINCIPLE OF OPERATION
A photodiode is a PN junction or PIN structure. When a photon of sufficient energy strikes the diode, it excites an electron, thereby creating a free electron and a (positively charged electron hole). This mechanism is also known as the photoelectric effect. If the absorption occurs in the junction's depletion region, or one diffusion length away from it, these carriers are swept from the junction by the built-in field of the depletion region. Thus holes move toward the anode, and electrons toward the cathode, and a photocurrent is produced. This photocurrent is the sum of both the dark current (without light) and the light current, so the dark current must be minimised to enhance the sensitivity of the device.

Materials
The material used to make a photodiode is critical to defining its properties, because only photons with sufficient energy to excite electrons across the material's bandgap will produce significant photocurrents. Materials commonly used to produce photodiodes include: Electromagnetic spectrum wavelength range (nm)
41

Material

Silicon Germanium Indium gallium arsenide Lead(II) sulfide

190 1100 400 1700 800 2600 <1000 3500

Because of their greater bandgap, silicon-based photodiodes generate less noise than germanium-based photodiodes, but germanium photodiodes must be used for wavelengths longer than approximately 1 m.

OPERATIONAL AMPLIFIER
An op amp is a high-gain, direct-coupled differential linear amplifier whose response characteristics are externally controlled by negative feedback from the output to the input. OP amps, widely used in computers, can perform mathematical operations such as summing, integration, and differentiation. OP amps are also used as video and audio amplifiers, oscillators, etc. in the communication electronics. Because of their versatility op amps are widely used in all branches of electronics both in digital and linear circuits. OP amps lend themselves readily to IC manufacturing techniques. Improved IC manufacturing techniques, the op amp's adaptability, and extensive use in the design of new equipment have brought the price of IC ops amps from very high to very reasonable levels. These facts ensure a very substantial role for the IC op amp in electronics. Fig shows the symbol for an op amp. Note that the operational amplifier has two inputs marked (-) and (+). The minus input is the inverting input. A signal applied to the minus terminal will be shifted in phase 180 at the output. The plus input is the non-inverting input. A signal applied to the plus terminal will appear in the same phase at the output as at the input. Because of the complexity of the internal circuitry of an op amp, the op amp symbol is used exclusively in circuit diagrams.

IC-741

An operational amplifier often referred to as op Amp, is a very high gain high performance amplifier designed to amplify ac and dc signal voltages. Modern integrated circuit technology
42

and large-scale production techniques have brought down the prices of such amplifiers within reach of all amateurs, experimenters and hobbyists. The Op Amp is now used as a basic gain element, like an elegant transistor, in electronic circuits.

A symbol used to represent an operational amplifier in schematics is shown in fig. The operational amplifier has two inputs and only one output. One input is called the inverting input and is denoted by a minus sign. A signal applied to this input appears as an amplified but phase inverted the signal output. The second input is called a non-inverting input and is denoted by a plus sign. A signal applied to this input appears at the output as an amplified signal, which has the same phase as that of the input signal.

The availability of two input terminals simplifies feedback circuitry and makes the operational amplifier a highly versatile device. If a feedback is applied from the output to the inverting input terminal, the result is a negative feedback, which gives a stable amplifier with precisely controlled gain characteristics. On the other hand, if the feedback is applied to the non-inverting input, the result is positive feedback, which gives oscillators and multivibrator. Special effects are obtained by combination of both types of feedback.

NEGATIVE FEEDBACK CONTROL

SEVEN SEGMENT DISPLAY


A popular type consists of seven small, bar-shaped LED segment arranged so that depending on which combinations are energized, the numbers 0 to 9 light up. All the LED cathodes (or
43

sometimes anodes) are joined to form a common connection. Current limiting resistors are required (e.g. 270 ohms), preferably one per segment.

Common cathode method of connecting an array of display elements. ANODE

The main requirements for a suitable LED material are:44

1) 2) 3)

It must have on energy gap of appropriate width. Both P and N types must exist, preferably with low resistivities. Efficient radioactive pathways must be present. Generally, energy gaps greater than or equal to about 2 are required.

Commercial LED materials:: Gallium arsenide (Ga As) doped with Si Gallium Phosphide (GaP) doped with N & Bi Gallium arsenide Phosphide (Ga As1-x Px) Gallium aluminium arsenide (Gax Al1-x As)

CHAPTER 4 MICROCONTROLLER

45

CHAPTER 4

4.1 FEATURES
1. High-performance, Low-power AVR 8-bit Microcontroller

2. Advanced RISC Architecture a. 131 Powerful Instructions Most Single-clock Cycle Execution b. 32 x 8 General Purpose Working Registers c. Fully Static Operation d. Up to 16 MIPS Throughput at 16 MHz 3. Nonvolatile Program and Data Memories a. 32K Bytes of In-System Self-Programmable Flash 4. In-System Programming by On-chip Boot Program 5. True Read-While-Write Operation a. 1024 Bytes EEPROM b. 2K Byte Internal SRAM 6. Peripheral Features
46

a. Two 8-bit Timer/Counters b. One 16-bit Timer/Counter c. Real Time Counter with Separate Oscillator d. Four PWM Channels e. 8-channel, 10-bit ADC 7. 8 Single-ended Channels a. Byte-oriented Two-wire Serial Interface b. Programmable Serial USART c. Master/Slave SPI Serial Interface d. Programmable Watchdog Timer with Separate On-chip Oscillator e. On-chip Analog Comparator 8. Special Microcontroller Features a. External and Internal Interrupt Sources
b. Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down,

Standby and Extended Standby. 9. I/O and Packages a. 32 Programmable I/O Lines b. 40-pin PDIP 10. Operating Voltages a. 2.7 - 5.5V for ATmega32L b. 4.5 - 5.5V for ATmega32 11. Speed Grades a. 0 - 8 MHz for ATmega32L b. 0 - 16 MHz for ATmega32
12. Power Consumption at 1 MHz, 3V, 25C for ATmega32L

a. Active: 1.1 mA b. Idle Mode: 0.35 mA c. Power-down Mode: < 1 A

4.2 PIN CONFIGURATIONS

47

4.3 BLOCK DIAGRAM

48

4.4 OVERVIEW
49

The ATmega32 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega32 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed. The 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 ATmega32 provides the following features: 32K bytes of In-System Programmable Flash Program memory with Read-While-Write capabilities, 1024 bytes EEPROM, 2K byte SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundary-scan, On-chip Debugging support and programming, three flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit ADC with optional differential input stage with programmable gain (TQFP package only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and six software selectable power saving modes. The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter, 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 External 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. In Extended Standby mode, both the main Oscillator and the Asynchronous Timer continue to run.
50

The device is manufactured using Atmels high density nonvolatile memory technology. The On-chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core. By combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip, the Atmel ATmega32 is a powerful microcontroller that provides a highly-flexible and cost-effective solution to many embedded control applications. 4.5 PIN DESCRIPTIONS VCC GND PORT A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bidirectional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. PORT B (PB7..PB0) 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. Port B also serves the functions of various special features of the ATmega32. PORT C (PC7..PC0) Digital supply voltage. Ground.

51

Port C is an 8-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. PORT D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up 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. Port D also serves the functions of various special features of the ATmega32. 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. XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting Oscillator amplifier. AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. AREF
AREF is the analog reference pin for the A/D Converter.

4.5.1 Digital Input Output Port


52

So lets start with understanding the functioning of AVR. We will first discuss about I/O Ports. Again I remind you that I will be using and writing about Atmega-32. Lets first have a look at the Pin configuration of Atmega-32. You can see it has 32 I/O (Input/Output) pins grouped as A, B, C & D with 8 pins in each group. This group is called as PORT. PA0 - PA7 (PORTA) PB0 - PB7 (PORTB) PC0 - PC7 (PORTC) PD0 - PD7 (PORTD) Notice that all these pins have some function written in bracket. These are additional function that pin can perform other than I/O. Some of them are. ADC (ADC0 - ADC7 on PORTA) UART (Rx,Tx on PORTD) TIMERS (OC0 - OC2) SPI (MISO, MOSI, SCK on PORTB) External Interrupts (INT0 - INT2)

4.5.2 Registers
All the configurations in microcontroller is set through 8 bit (1 byte) locations in RAM (RAM is a bank of memory bytes) of the microcontroller called as Registers. All the functions are mapped to its locations in RAM and the value we set at that location that is at that Register configures the functioning of microcontroller. There are total 32 x 8bit registers in Atmega-16. As Register size of this microcontroller is 8 bit, it called as 8 bit microcontroller.

4.5.3 I/O Ports:


Input Output functions are set by Three Registers for each PORT. DDRX ----> Sets whether a pin is Input or Output of PORTX. PORTX ---> Sets the Output Value of PORTX. PINX -----> Reads the Value of PORTX.

4.5.4 DDRX (Data Direction Register)


53

First of all we need to set whether we want a pin to act as output or input. DDRX register sets this. Every bit corresponds to one pin of PORTX. Lets have a look on DDRA register. Bit PIN 7 PA7 6 PA6 5 PA5 4 PA4 3 PA3 2 PA2 1 PA1 0 PA0

Now to make a pin act as I/O we set its corresponding bit in its DDR register. To make Input set bit 0 To make Output set bit 1 If I write DDRA = 0xFF (0x for Hexadecimal number system) that is setting all the bits of DDRA to be 1, will make all the pins of PORTA as Output. Similarly by writing DDRD = 0x00 that is setting all the bits of DDRD to be 0, will make all the pins of PORTD as Input. Now lets take another example. Consider I want to set the pins of PORTB as shown in table, PORT-B PB7 Function Output DDRB 1 PB6 Output 1 PB5 Input 0 PB4 Output 1 PB3 Input 0 PB2 Input 0 PB1 Input 0 PB0 Output 1

For this configuration we have to set DDRB as 11010001 which in hexadecimal isD1. So we will write DDRB=0xD1

Summary
DDRX -----> to set PORTX as input/output with a byte. DDRX.y ---> to set yth pin of PORTX as input/output with a bit (works only with CVAVR).

4.5.5 PORTX (PORTX Data Register)


This register sets the value to the corresponding PORT. Now a pin can be Output or Input. So lets discuss both the cases.

Output Pin

54

If a pin is set to be output, then by setting bit 1 we make output High that is +5V and by setting bit 0 we make output Low that is 0V. Lets take an example. Consider I have set DDRA=0xFF, that is all the pins to be Output. Now I want to set Outputs as shown in table,

PORT-A PA7 Value

PA6

PA5

PA4

PA3

PA2

PA1

PA0

High(+5V High(+5V High(+5V High(+5V Low(0V) Low(0V) Low(0V) Low(0V) ) ) ) ) 1 0 0 0 1 1 0

PORTA 1

For this configuration we have to set PORTA as 11000110 which in hexadecimal isC6. So we will write PORTA=0xC6; Input Pin If a pin is set to be input, then by setting its corresponding bit in PORTX register will make it as follows, Set bit 0 ---> Tri-Stated Set bit 1 ---> Pull Up Tristated means the input will hang (no specific value) if no input voltage is specified on that pin. Pull Up means input will go to +5V if no input voltage is given on that pin. It is basically connecting PIN to +5V through a 10K Ohm resistance. Summary PORTX ----> to set value of PORTX with a byte. PORTX.y --> to set value of yth pin of PORTX with a bit (works only with CVAVR).

4.5.6 PINX (Data Read Register)

55

This register is used to read the value of a PORT. If a pin is set as input then corresponding bit on PIN register is, 0 for Low Input that is V < 2.5V 1 for High Input that is V > 2.5V (Ideally, but actually 0.8 V - 2.8 V is error zone !) For an example consider I have connected a sensor on PC4 and configured it as an input pin through DDR register. Now I want to read the value of PC4 whether it is Low or High. So I will just check 4th bit of PINC register. We can only read bits of the PINX register; can never write on that as it is meant for reading the value of PORT. Summary PINX ----> Read complete value of PORTX as a byte. PINX.y --> Read yth pin of PORTX as a bit (works only with CVAVR).

4.5.7 A SMALL NOTE ABOUT DELAY


C has inbuilt libraries which contain many pre-built functions. One such function is Delay, which introduces a time delay at a particular step. To invoke it in your program, you need to add the following line at the beginning of your code:

#include<delay.h>;

Thereafter, it can be used in the program by adding the following line:

delay_ms(X); Where X is the time delay you wish to introduce at that particular step in milliseconds.

4.6 ARCHITECTURAL OVERVIEW

56

In order to maximize performance and parallelism, the AVR uses a Harvard architecture with separate memories and buses for program and data. Instructions in the program memory are executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the program memory. This concept enables instructions to be executed in every clock cycle. The program memory is InSystem Reprogrammable Flash memory. The fast-access Register File contains 32 x 8-bit general purpose working registers with a single clock cycle access time. This allows single-cycle Arithmetic Logic Unit (ALU) operation. In a typical ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File in one clock cycle. Six of the 32 registers can be used as three 16-bit indirect address register pointers for Data Space addressing enabling efficient address calculations. One of the these address pointers can also be used as an address pointer for look up tables in Flash Program
57

memory. These added function registers are the 16-bit X-, Y-, and Z-register, described later in this section. The ALU supports arithmetic and logic operations between registers or between a constant and a register. Single register operations can also be executed in the ALU. Afteran arithmetic operation, the Status Register is updated to reflect information about the result of the operation. Program flow is provided by conditional and unconditional jump and call instructions, able to directly address the whole address space. Most AVR instructions have a single 16-bit word format. Every program memory address contains a 16- or 32-bit instruction. Program Flash memory space is divided in two sections, the Boot program section and the Application Program section. Both sections have dedicated Lock bits for write and read/write protection. The SPM instruction that writes into the Application Flash memory section must reside in the Boot Program section. During interrupts and subroutine calls, the return address Program Counter (PC) is stored on the Stack. The Stack is effectively allocated in the general data SRAM, and consequently the Stack size is only limited by the total SRAM size and the usage of the SRAM. All user programs must initialize the SP in the reset routine (before subroutines or interrupts are executed). The Stack Pointer SP is read/write accessible in the I/O space. The data SRAM can easily be accessed through the five different addressing modes supported in the AVR architecture. The memory spaces in the AVR architecture are all linear and regular memory maps. A flexible interrupt module has its control registers in the I/O space with an additional global interrupt enable bit in the Status Register. All interrupts have a separate interrupt vector in the interrupt vector table. The interrupts have priority in accordance with their interrupt vector position. The lower the interrupt vector address, the higher the priority. The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers, SPI, and other I/O functions. The I/O Memory can be accessed directly, or as the Data Space locations following those of the Register File, $20 - $5F.

4.7 ALU Arithmetic Logic Unit


The high-performance AVR ALU operates in direct connection with all the 32 general
58

purpose working registers. Within a single clock cycle, arithmetic operations between general purpose registers or between a register and an immediate are executed. The ALU operations are divided into three main categories arithmetic, logical, and bitfunctions. Some implementations of the architecture also provide a powerful multiplier supporting both signed/unsigned multiplication and fractional format. See the Instruction Set section for a detailed description.

4.8 GENERAL PURPOSE REGISTER FILE


The Register File is optimized for the AVR Enhanced RISC instruction set. In order to achieve the required performance and flexibility, the following input/output schemes are supported by the Register File: One 8-bit output operand and one 8-bit result input Two 8-bit output operands and one 8-bit result input Two 8-bit output operands and one 16-bit result input One 16-bit output operand and one 16-bit result input

4.9 STATUS REGISTER


The Status Register contains information about the result of the most recently executed
59

arithmetic instruction. This information can be used for altering program flow in order to perform conditional operations. Note that the Status Register is updated after all ALU operations, as specified in the Instruction Set Reference. This will in many cases remove the need for using the dedicated compare instructions, resulting in faster and more compact code. The Status Register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt. This must be handled by software. The AVR Status Register SREG is defined as:

Bit 7 I: Global Interrupt Enable The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual interrupt enable control is then performed in separate control registers. If the Global Interrupt Enable Register is cleared, none of the interrupts are enabled independent of the individual interrupt enable settings. The I-bit is cleared by hardware after an interrupt has occurred, and is set by the RETI instruction to enable subsequent interrupts. The Ibit can also be set and cleared by the application with the SEI and CLI instructions, as described in the instruction set reference. Bit 6 T: Bit Copy Storage The Bit Copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T-bit as source or destination for the operated bit. A bit from a register in the Register File can be copied into T by the BST instruction, and a bit in T can be copied into a bit in a register in the Register File by the BLD instruction. Bit 5 H: Half Carry Flag The Half Carry Flag H indicates a half carry in some arithmetic operations. Half Carry is useful in BCD arithmetic. See the Instruction Set Description for detailed information.
60

Bit 4 S: Sign Bit, S = N V The S-bit is always an exclusive or between the Negative Flag N and the Twos Complement Overflow Flag V. See the Instruction Set Description for detailed information. Bit 3 V: Twos Complement Overflow Flag The Twos Complement Overflow Flag V supports twos complement arithmetics. See the Instruction Set Description for detailed information. Bit 2 N: Negative Flag The Negative Flag N indicates a negative result in an arithmetic or logic operation. See the Instruction Set Description for detailed information. Bit 1 Z: Zero Flag The Zero Flag Z indicates a zero result in an arithmetic or logic operation.

4.10 THE X-REGISTER, Y-REGISTER AND Z-REGISTER


The registers R26..R31 have some added functions to their general purpose usage. These registers are 16-bit address pointers for indirect addressing of the Data Space. The three indirect address registers X, Y, and Z are defined as described in Figure.

In the different addressing modes these address registers have functions as fixed displacement, automatic increment, and automatic decrement

4.11 STACK POINTER


61

The Stack is mainly used for storing temporary data, for storing local variables and for storing return addresses after interrupts and subroutine calls. The Stack Pointer Register always points to the top of the Stack. Note that the Stack is implemented as growing from higher memory locations to lower memory locations. This implies that a Stack PUSH command decreases the Stack Pointer. The Stack Pointer points to the data SRAM Stack area where the Subroutine and Interrupt Stacks are located. This Stack space in the data SRAM must be defined by the program before any subroutine calls are executed or interrupts are enabled. The Stack Pointer must be set to point above $60. The Stack Pointer is decremented by one when data is pushed onto the Stack with the PUSH instruction, and it is decremented by two when the return address is pushed onto the Stack with subroutine call or interrupt. The Stack Pointer is incremented by one when data is popped from the Stack with the POP instruction, and it is incremented by two when data is popped from the Stack with return from subroutine RET or return from interrupt RETI. The AVR Stack Pointer is implemented as two 8-bit registers in the I/O space. The number of bits actually used is implementation dependent. Note that the data space in some implementations of the AVR architecture is so small that only SPL is needed. In this case, the SPH Register will not be present.

4.12 INSTRUCTION EXECUTION TIMING


This section describes the general access timing concepts for instruction execution. The AVR CPU is driven by the CPU clock clkCPU, directly generated from the selected clock source for the chip. No internal clock division is used.
62

Figure shows the parallel instruction fetches and instruction executions enabled by the Harvard architecture and the fast-access Register File concept. This is the basic pipelining concept to obtain up to 1 MIPS per MHz with the corresponding unique results for functions per cost, functions per clocks, and functions per power-unit. Figure The Parallel Instruction Fetches and Instruction Executions

Figure shows the internal timing concept for the Register File. In a single clock cycle an ALU operation using two register operands is executed, and the result is stored back to the destination register. Figure Single Cycle ALU Operation

4.13 RESET AND INTERRUPT


Handling The AVR provides several different interrupt sources. These interrupts and the separate reset vector each have a separate program vector in the program memory space. All
63

interrupts are assigned individual enable bits which must be written logic one together with the Global Interrupt Enable bit in the Status Register in order to enable the interrupt. Depending on the Program Counter value, interrupts may be automatically disabled when Boot Lock bits BLB02 or BLB12 are programmed. This feature improves software security. See the section Memory Programming on page 254 for details. The lowest addresses in the program memory space are by default defined as the Reset and Interrupt Vectors. The complete list of vectors is shown in Interrupts on page 42. The list also determines the priority levels of the different interrupts. The lower the address the higher is the priority level. RESET has the highest priority, and next is INT0 the External Interrupt Request 0. The Interrupt Vectors can be moved to the start of the Boot Flash section by setting the IVSEL bit in the General Interrupt Control Register (GICR). Refer to Interrupts on page 42 for more information. The Reset Vector can also be moved to the start of the boot Flash section by programming the BOOTRST fuse, see Boot Loader Support Read-While-Write Self-Programming on page 242. When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a Return from Interrupt instruction RETI is executed. There are basically two types of interrupts. The first type is triggered by an event that sets the Interrupt Flag. For these interrupts, the Program Counter is vectored to the actual Interrupt Vector in order to execute the interrupt handling routine, and hardware clears the corresponding Interrupt Flag. Interrupt Flags can also be cleared by writing a logic one to the flag bit position(s) to be cleared. If an interrupt condition occurs while the corresponding interrupt enable bit is cleared, the Interrupt Flag will be set and remembered until the interrupt is enabled, or the flag is cleared by software. Similarly, if one or more interrupt conditions occur while the Global Interrupt Enable bit is cleared, the corresponding Interrupt Flag(s) will be set and remembered until the global interrupt enable bit is set, and will then be executed by order of priority. The second type of interrupts will trigger as long as the interrupt condition is present. These interrupts do not necessarily have Interrupt Flags. If the interrupt condition disappears before the interrupt is enabled, the interrupt will not be triggered.
64

When the AVR exits from an interrupt, it will always return to the main program and execute one more instruction before any pending interrupt is served. Note that the Status Register is not automatically stored when entering an interrupt routine, nor restored when returning from an interrupt routine. This must be handled by software. When using the CLI instruction to disable interrupts, the interrupts will be immediately disabled. No interrupt will be executed after the CLI instruction, even if it occurs simultaneously with the CLI instruction.

4.14 AVR ATMEGA32 MEMORIES


This section describes the different memories in the ATmega32. The AVR architecture has two main memory spaces, the Data Memory and the Program Memory space. In addition, the ATmega32 features an EEPROM Memory for data storage. All three memory spaces are linear and regular.

4.14.1 IN-SYSTEM REPROGRAMMABLE FLASH PROGRAM MEMORY The ATmega32 contains 32K bytes On-chip In-System Reprogrammable Flash memory for program storage. Since all AVR instructions are 16 or 32 bits wide, the Flash is organized as 16K x 16. For software security, the Flash Program memory space is divided into two sections, Boot Program section and Application Program section. The Flash memory has an endurance of at least 10,000 write/erase cycles. The ATmega32 Program Counter (PC) is 14 bits wide, thus addressing the 16K program memory locations. The operation of Boot Program section and associated Boot Lock bits for software protection are described in detail in Boot Loader Support ReadWhile-Write Self-Programming on page 242. Memory Programming on page 254 containsa detailed description on Flash Programming in SPI, JTAG, or Parallell Programming mode. Constant tables can be allocated within the entire program memory address space (see the LPM Load Program Memory Instruction Description). Timing diagrams for instruction fetch and execution are presented in Instruction Execution Timing on page 11.
65

4.14.2 SRAM DATA MEMORY


Figure 9 shows how the ATmega32 SRAM Memory is organized. The lower 2144 Data Memory locations address the Register File, the I/O Memory, and the internal data SRAM. The first 96 locations address the Register File and I/O Memory, and the next 2048 locations address the internal data SRAM. The five different addressing modes for the data memory cover: Direct, Indirect with Displacement,Indirect, Indirect with Pre-decrement, and Indirect with Post-increment. In the Register File, registers R26 to R31 feature the indirect Addressing Pointer Registers.The direct addressing reaches the entire data space. The Indirect with Displacement mode reaches 63 address locations from the base address given by the Y- or Z-register. When using register indirect addressing modes with automatic pre-decrement and postincrement,the address registers X, Y, and Z are decremented or incremented. The 32 general purpose working registers, 64 I/O Registers, and the 2048 bytes of internal data SRAM in the ATmega32 are all accessible through all these addressing modes. The Register File is described in General Purpose Register File on page 9.
66

4.15 POWER MANAGEMENT AND SLEEP MODES


Sleep modes enable the application to shut down unused modules in the MCU, thereby saving power. The AVR provides various sleep modes allowing the user to tailor the power consumption to the applications requirements. To enter any of the six sleep modes, the SE bit in MCUCR must be written to logic one and a SLEEP instruction must be executed. The SM2, SM1, and SM0 bits in the MCUCR Register select which sleep mode (Idle, ADC Noise Reduction, Power-down, Power-save, Standby, or Extended Standby) will be activated by the SLEEP instruction. If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU is then halted for four cycles in addition to the start-up time, it executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the Register File and SRAM are unaltered when the device wakes up from sleep. If a Reset occurs during sleep mode, the MCU wakes up and executes from the Reset Vector.

4.15.1 IDLE MODE


When the SM2..0 bits are written to 000, the SLEEP instruction makes the MCU enter
67

Idle mode, stopping the CPU but allowing SPI, USART, Analog Comparator, ADC, Twowire Serial Interface, Timer/Counters, Watchdog, and the interrupt system to continue operating. This sleep mode basically halts clkCPU and clkFLASH, while allowing the other clocks to run. Idle mode enables the MCU to wake up from external triggered interrupts as well as internal ones like the Timer Overflow and USART Transmit Complete interrupts. If wake-up from the Analog Comparator interrupt is not required, the Analog Comparator can be powered down by setting the ACD bit in the Analog Comparator Control and Status Register ACSR. This will reduce power consumption in Idle mode. If the ADC is enabled, a conversion starts automatically when this mode is entered.

4.15.2 ADC NOISE REDUCTION MODE


When the SM2..0 bits are written to 001, the SLEEP instruction makes the MCU enter ADC Noise Reduction mode, stopping the CPU but allowing the ADC, the External Interrupts, the Two-wire Serial Interface address watch, Timer/Counter2 and the Watchdog to continue operating (if enabled). This sleep mode basically halts clkI/O, clkCPU, and clkFLASH, while allowing the other clocks to run. This improves the noise environment for the ADC, enabling higher resolution measurements. If the ADC is enabled, a conversion starts automatically when this mode is entered. Apart form the ADC Conversion Complete interrupt, only an External Reset, a Watchdog Reset, a Brown-out Reset, a Two-wire Serial Interface Address Match Interrupt, a Timer/Counter2 interrupt, an SPM/EEPROM ready interrupt, an External level interrupt on INT0 or INT1, or an external interrupt on INT2 can wake up the MCU from ADC Noise Reduction mode.

4.15.3 POWER-DOWN MODE


When the SM2..0 bits are written to 010, the SLEEP instruction makes the MCU enter Power-down mode. In this mode, the External Oscillator is stopped, while the External interrupts, the Two-wire Serial Interface address watch, and the Watchdog continue operating (if enabled). Only an External Reset, a Watchdog Reset, a Brown-out Reset, a
68

Two-wire Serial Interface address match interrupt, an External level interrupt on INT0 or INT1, or an External interrupt on INT2 can wake up the MCU. This sleep mode basically halts all generated clocks, allowing operation of asynchronous modules only. Note that if a level triggered interrupt is used for wake-up from Power-down mode, the changed level must be held for some time to wake up the MCU. When waking up from Power-down mode, there is a delay from the wake-up condition occurs until the wake-up becomes effective. This allows the clock to restart and become stable after having been stopped. The wake-up period is defined by the same CKSEL fuses that define the reset time-out period.

4.15.4 POWER-SAVE MODE


When the SM2..0 bits are written to 011, the SLEEP instruction makes the MCU enter Power-save mode. This mode is identical to Power-down, with one exception: If Timer/Counter2 is clocked asynchronously, i.e., the AS2 bit in ASSR is set, Timer/Counter2 will run during sleep. The device can wake up from either Timer Overflow or Output Compare event from Timer/Counter2 if the corresponding Timer/Counter2 interrupt enable bits are set in TIMSK, and the Global Interrupt Enable bit in SREG is set. If the Asynchronous Timer is NOT clocked asynchronously, Power-down mode is recommended instead of Power-save mode because the contents of the registers in the Asynchronous Timer should be considered undefined after wake-up in Power-save mode if AS2 is 0. This sleep mode basically halts all clocks except clkASY, allowing operation only of asynchronous modules, including Timer/Counter2 if clocked asynchronously.

4.15.5 STANDBY MODE


When the SM2..0 bits are 110 and an external crystal/resonator clock option is selected, the SLEEP instruction makes the MCU enter Standby mode. This mode is identical to Power-down with the exception that the Oscillator is kept running. From Standby mode,
69

the device wakes up in six clock cycles.

4.15.6 EXTENDED STANDBY MODE


When the SM2..0 bits are 111 and an external crystal/resonator clock option is selected, the SLEEP instruction makes the MCU enter Extended Standby mode. This mode is identical to Power-save mode with the exception that the Oscillator is kept running. From Extended Standby mode, the device wakes up in six clock cycles.

4.16 WATCHDOG TIMER


If the Watchdog Timer is not needed in the application, this module should be turned off. If the Watchdog Timer is enabled, it will be enabled in all sleep modes, and hence, always consume power. In the deeper sleep modes, this will contribute significantly to the total current consumption.

70

CHAPTER 5 SOFTWARE USED

5.1 EXPRESS PCB


This software is use to design the PCB . The circuit daigarm obtain in our project is shown below.

71

5.2 Code Vision AVR (CVAVR)


An IDE has following functions:

Preprocessing Compilation Assembly Linking Object Translation Text Editor

If we just use compiler and linker independently we still need to get a text editor. So combining everything will actually mess things up. So the best way is to get Software which has it all. Thats called an Integrated Development Environment, in short IDE. I consider Code-Vision-AVR to be the best IDE for getting started with AVR programming on Windows XP, Vista. It has a very good Code Wizard which generate codes automatically ! You need not mess with the assembly words. So in all my tutorials I will be using CVAVR. You can download evaluation version for free which has code size limitation but good enough for our purpose. For all my examples I will be using Atmega-32 as default microcontroller because it very easily available and is powerful enough with sufficient number of pins and peripherals we use. You can have a look on the datasheet of Atmega-32 in the datasheet section. Lets take a look on the software. The main window looks like following,
72

Now click on File ---> New --->Project A pop up window will come asking whether you want to use Code Wizard AVR, obviously select yes because that is the reason we are using CVAVR ! Now have a look on this Wizard. It has many tabs where we can configure PORTS, TIMERS, LCD, ADC etc. I am explaining some of them

CHIP:

73

Select the chip for which you are going to write the program. Then select the frequency at which Chip is running. By default all chips are set on Internal Oscillator of 1 MHz so select 1 MHz if that is the case. If you want to change the running clock frequency of the chip then you have to change its fuse bits (I will talk more about this in fuse bits section).

PORT:
PORT is usually a collection of 8 pins. From this tab you can select which pin you want to configure as output and which as input. It basically writes the DDR and PORT register through this setting. Registers are basically RAM locations which configure various peripherals of microcontroller and by changing value of these registers we can change the function it is performing. I will talk more about registers later. All the details are provided in the datasheet. So you can configure any pin as output or input by clicking the box. For Atmega-32 which has 4 Ports we can see 4 tabs each corresponding to one Port. You can also set initial value of the Pins you want to assign. or if you are using a pin as input then
74

whether you want to make it as pull-up or tristated, again I will talk in details about these functions later. Similarly using this code wizard you can very easily configure all the peripherals on the Atmega. Now for generating code just go to File ---->Generate, Save and Exit (of the code wizard) Now it will ask you name and location for saving three files. Two being project files and one being the .C file which is your program. try to keep same names of all three files to avoid confusion. By default these files are generated in C:\CVAVR\bin The generated program will open in the text editor. Have a look it has some declarations like PORT, DDR, TCCR0 and many more. These are all registers which configures various functions of Atmega and by changing these value we make different functions. All the details about the registers are commented just below them. Now go down and find following infinite while loop there. We can start writing our part of program just before the while loop. And as for most of the applications we want microcontroller to perform the same task forever we put our part of code in the infinite while loop provided by the code wizard ! while { // Place your code here }; } See how friendly this code wizard is, all the work (configuring registers) automatically done and we dont even need to understand and go to the details about registers too ! Now we want to generate the hex file, so first compile the program. Either press F9 or go to Project--->Compile. It will show compilation errors if any. If program is error free we can proceed to making of hex file. So either press Shift+F9 or go to Project---->Make. A pop up window will come with information about code size and flash usage etc. So the machine file is ready now ! It is in the same folder where we saved those 3 files. (1)

75

CHAPTER 6 CODING

76

TRANSMITTER PROGRAMMING IN ATMEGA32


Chip type Program type : ATmega32 : Application

AVR Core Clock frequency: 4.000000 MHz Memory model External RAM size Data Stack size : Small :0 : 512

*****************************************************/ #include <mega32.h> // Standard Input/Output functions #include <stdio.h> // Declare your global variables here void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
77

// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock
78

// Clock value: Timer1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped
79

// Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=0x00; MCUCSR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud Rate: 9600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86;
80

UBRRH=0x00; UBRRL=0x19; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; DDRA=0x00; //portA is made as input port DDRC=0x00; //portC is made as input port

while (1) { if(PINA==01H) putchar(0); //zero is stored in transmitter buffer register

else if(PINA==02) putchar(1); //one is stored in transmitter buffer register

else if(PINA==04) putchar(2); //two is stored in transmitter buffer register

else if(PINA==08) putchar(3); //thre is stored in transmitter buffer register

else if(PINA==10) putchar(4); //four is stored in transmitter buffer register

else if(PINA==20)
81

putchar(5);

//five is stored in transmitter buffer register

else if(PINA==40) putchar(6); //six is stored in transmitter buffer register

else if(PINA==80) putchar(7); //seven is stored in transmitter buffer register

else if(PINC==01) putchar(8); //eight is stored in transmitter buffer register

else if(PINC==02) putchar(9); } } //nine is stored in transmitter buffer register

RECEIVER PROGRAMMING OF ATMEGA32


#include <mega32.h> // Standard Input/Output functions #include <stdio.h> // Declare your global variables here void main(void) { int i; // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00;
82

DDRA=0x00; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00;

// Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x00;
83

TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00;
84

OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=0x00; MCUCSR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous
85

// USART Baud Rate: 9600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86; UBRRH=0x00; UBRRL=0x19; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; DDRB=0xFF; // port B is mabe as o/p port PORTB=0x00; while (1) { i=getchar(); if(i==0) {PORTB=0x3F; } // CODE OF ZERO FOR 7 SEGMENT DISPLAY // RECEIVE THE DATA IN RECEIVER BUFFER

else if(i==1) {PORTB=0x06; } else if(i==2)


86

// CODE OF ONE FOR 7 SEGMENT DISPLAY

{PORTB=0x5B; } else if(i==3)

// CODE OF TWO FOR 7 SEGMENT DISPLAY

{PORTB=0x4F; // CODE OF THREE FOR 7 SEGMENT DISPLAY } else if(i==4) {PORTB=0x66; } else if(i==5) {PORTB=0x6D; } else if(i==6) {PORTB=0x7D; } else if(i==7) {PORTB=0x07; } else if(i==8) {PORTB=0x7F; // CODE OF EIGHT FOR 7 SEGMENT DISPLAY } else if(i==9) {PORTB=0x67; }
87

// CODE OF FOUR FOR 7 SEGMENT DISPLAY

// CODE OF FIVE FOR 7 SEGMENT DISPLAY

// CODE OF SIX FOR 7 SEGMENT DISPLAY

// CODE OF SEVEN FOR 7 SEGMENT DISPLAY

// CODE OF NINE FOR 7 SEGMENT DISPLAY

} }

CHAPTER 7 CONCLUSION

88

4.1 CONCLUSION

The conclusion is thatWith the help of laser a new means of communication LASER COMMUNICATION can be developed apart from conventional methods. Moreover the system is far more reliable ,compatible with new technologies & easy to handle The only limitation it have is LOS (Line Of Sight) is required between transmitter & receiver and this limitation would be shortly overcome in near future with the development of powerful & strong lasers.

89

90

APPENDIX A THE TRANSISTOR

A transistor is semi conductor device consisting of three regions separated by two P-N junctions. The three regions are Base, Emitter & Collector. The base may be of N- type or Ptype. The emitter and collector have same impurities but different from that of base. Thus if base is of N- type then emitter and collector are of P- type then transistor is called P-N-P transistor and vice versa transistor is called N-P-N transistor. The base is made thin and number density of majority carriers is always less than emitter and collector. The base provides junction for proper interaction between emitter and collector. Electrons are majority charge carriers in N- region and in P-region, holes are the majority charge carriers. Thus two types of charge carriers are involved in current flow through N-P-N or P-N-P transistor. SYMBOLS FOR TRANSISTORS: In schematic symbols, the emitter is always represented by an arrow indicating the direction of conventional current in the device. In case of N-P-N transistor arrow points away from base and in case of P-N-P transistor it points towards base. When transistor is used in circuit, emitter - base junction is always forward biased while base - collector junction is always reverse biased.

Figure a Structure and symbol of P-N-P transistor

91

BIASING OF TRANSISTOR :

The two junctions can be biased in four different ways: Both junctions may be forward biased. It causes large current to flow across junctions. Transistor is to be operated in SATURATION REGION. Both junctions may be reversed biased. It causes very small current to flow across junctions. Transistor is to be operated in CUT OFF REGION. E-B junction is forward biased and C-B junction is reverse biased. The transistor is said to be operated in ACTIVE REGION. Most of the transistors work in this region. E-B junction is reversed biased and C-B junction is forward biased. The transistor is said to be operated in INVERTED MODE.

Figure b (a) P-N-P transistor biasing (b) N-P-N transistor biasing

92

APPENDIX B THE LED


A light-emitting diode (LED) is a semiconductor light source. The LED is based on the semiconductor diode. When a diode is forward biased (switched on), electrons are able to recombine with holes within the device, releasing energy in the form of photons. This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. An LED is usually small in area (less than 1 mm2), and integrated optical components are used to shape its radiation pattern and assist in reflection. LEDs present many advantages over the incandescent light sources including lower energy consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater durability and reliability. However, they are relatively expensive and require more precise current and heat management than traditional light sources. Current LED products for general lighting are more expensive to buy than fluorescent lamp sources of comparable output.

Figure. Current conduction


93

Like a normal diode, the LED consists of a chip of semiconducting material doped with impurities to create a p-n junction. As in other diodes, current flows easily from the p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge-carrierselectrons and holesflow into the junction from electrodes with different voltages. When an electron meets a hole, it falls into a lower energy level, and releases energy in the form of a photon. The wavelength of the light emitted, and therefore its color, depends on the band gap energy of the materials forming the p-n junction. In silicon or germanium diodes, the electrons and holes recombine by a non-radiative transition which produces no optical emission, because these are indirect band gap materials. The materials used for the LED have a direct band gap with energies corresponding to near-infrared, visible or near-ultraviolet light. LED development began with infrared and red devices made with gallium arsenide. Advances in materials science have made possible the production of devices with evershorter wavelengths, producing light in a variety of colors. LEDs are usually built on an n-type substrate, with an electrode attached to the p-type layer deposited on its surface. P-type substrates, while less common, occur as well. Many commercial LEDs, especially GaN/InGaN, also use sapphire substrate. Most materials used for LED production have very high refractive indices. This means that much light will be reflected back into the material at the material/air surface interface. Therefore Light extraction in LEDs is an important aspect of LED production, subject to much research and development. Infrared wavelength is greater than about 760 nm.

REFERENCES

http://en.wikipedia.org
94

http://en.extremeelectronics.co.in http://www.avrtutor.com/tutorial.html http://www.cmosexod.com/micro_uart.html http://www.best-microcontroller-projects.com/hardware-interrupt.html

95

Das könnte Ihnen auch gefallen