Beruflich Dokumente
Kultur Dokumente
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
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.
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
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.
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
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
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
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
- data received through photo diode -apropriate signals are sensed
16
-passed through push pull amplifier -Gain is adjusted through rheostat -Given to speaker
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
atmega32
as mcu
MCU
7 segme nt display
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
19
20
start
Data
Data or voice
Voice
Electret
mic
Preampli fier than power amplifier (push pull amp)
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
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.
Components Microcontroller ATMEGA32 Laser Diode Photo Diode Opamp IC 741 7-segment LED Resistance(ohm)
Quantity 2 1 1 1 1
1 1 7 1 4 7
7.
Capacitances
4 4 2 2 2
23
8.
9.
10.
2 1 6 9
11.
12. 13.
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.
24
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.
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
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.
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.
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.
31
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
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.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.
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.
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
39
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
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.
sometimes anodes) are joined to form a common connection. Current limiting resistors are required (e.g. 270 ohms), preferably one per segment.
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
47
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.
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.
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).
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,
PA6
PA5
PA4
PA3
PA2
PA1
PA0
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).
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).
#include<delay.h>;
delay_ms(X); Where X is the time delay you wish to introduce at that particular step in milliseconds.
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.
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.
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.
In the different addressing modes these address registers have functions as fixed displacement, automatic increment, and automatic decrement
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.
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
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.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
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.
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.
70
71
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
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
else if(PINA==20)
81
putchar(5);
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
{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
} }
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
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.
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.
92
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
95