Sie sind auf Seite 1von 48

CHAPTER -1 INTRODUCTION

1.1 STATEMENT OF PROBLEM


In a country like India, where the economy is mainly based on agriculture and the climatic conditions are isotropic, still we are not able to make full use of agricultural resources due to lack of rains. The continuous extraction of water from earth is reducing the water level due to which lot of land is coming slowly in the zones of un-irrigated land. Another reason is due to unplanned use of water due to which a significant amount of water goes waste. At the present era, the farmers have been using irrigation technique in India through the manual control. This process sometimes consumes more water or sometimes the water reaches late due to which the crops get dried. Water deficiency can be detrimental to plants before visible wilting occurs. Slowed growth rate, lighter weight fruit follows slight water deficiency. Also, in the conventional irrigation system, the farmer has to keep watch on irrigation timetable, which is different for different crops. All the above problems can be perfectly rectified if we use automatic microcontroller based plant irrigation system. In this fast paced world, human beings require everything to be automated. Our lifestyle demands everything to be remote controlled. Apart from few things man has made his life automated. In this world of advance electronics, life of human beings should be simpler. Hence, to make life simpler and Convenient, we have made Automatic Plant Irrigator a model of controlling irrigation facilities to help millions of people. The main scope of this project is to make the irrigation automated. With the use of low cost sensors and the simple circuitry makes this project a low cost product, which can be bought even by a poor farmer. This project is best suited for places where water is scares and has to be used in limited quantity. Irrigation is the key to a successful garden. The Project presented here waters your plants regularly when you are out for vocation. The development of this system requires microcontroller architecture, opamp, LCD, motor, and de debugging of the application program. This automatic plant irrigation system is used to water roof gardens, lawns, agricultural lands, home gardens, etc.,. The advantage of this system is it is highly sensitive, works according to the soil condition, low cost and reliable circuit, and complete elimination of manpower.

1.2 ORGANIZATION OF REPORT We have started our report with certificate, acknowledgement and abstract thereby numbered as i, ii and iii. The abstract represents a 1-page summary of our project highlighting its salient features. We have made sure that every item in the report has a page number to it. Chapter 1 is introduction. It states the primary requirement of our circuit and how we achieved it. Chapter 2 is literature survey. In this section, we have seen the different aspects in which our project could have been made, i.e., by using BC 7805 as voltage regulator, sensor(lm741), by using 89c51 as the master microcontroller. Chapter 3 is our work emphasizing our contribution. In this chapter we have shown the problems we faced while designing and making the circuit and how we have overcome them. For example, how we check the network, soldering in motors, cutting and drilling. Chapter 4 is implementation and results. This chapter constitutes the circuit diagram, its working description, the various components and measuring instruments used in this project and the result we finally obtained. Chapter 5 is conclusion and future work. In this section we discuss the scope of our project. Chapter 6 is bibliography and appendix in which we have given the references from where we acquired all the suitable data for this report.

CHAPTER -2 LITERATURE SURVEY


It involves the details of the set of design specifications. The hardware design consists of, the selection of system components as per the requirement, the details of subsystems that are required for the complete implementation of the system. Design of the circuit and its testing has been carried out. It involves the component selection, component description and hardware details of the system designed. Automatic plant irrigation system includes the following components: (a) (b) (c) (d) (e) 2.1 Microcontroller 2.1.1 What are microcontrollers? Like all good things, this powerful component is basically very simple. It is made by mixing tested and high- quality "ingredients" (components) as per following receipt: (1) The simplest computer processor is used as the "brain" of the future system. Microcontroller (AT89C2051) Power supply unit Sensor Motor Motor drive (Relay drive)

(2) Depending on the taste of the manufacturer, a bit of memory, a few A/D converters, timers, input/output lines etc. are added (3) All that is placed in some of the standard packages. (4) Simple software able to control it all and which everyone can easily learn about has been developed. On the basis of these rules, numerous types of microcontrollers were designed and they quickly became man's invisible companion. Their incredible simplicity and flexibility conquered us a long time ago and if you try to invent something about them, you should know that you are probably late; someone before you has either done it or at least has tried to do it. The following things have had a crucial influence on development and success of the microcontrollers: (1)Powerful and carefully chosen electronics embedded in the microcontrollers can independently or via input/output devices (switches, push
3

buttons, sensors, LCD displays, relays etc.), control various processes and devices such as industrial automation, electric current, temperature, engine performance etc. (2)Very low prices enable them to be embedded in such devices in which, until recent time it was not worthwhile to embed anything. Thanks to that, the world is overwhelmed today with cheap automatic devices and various smart appliances. 2.1.2 Criteria for choosing a microcontroller 1.) The first and foremost criterion for choosing a microcontroller is that it must meet the task at hand efficiently and cost effectively. In analyzing the needs of a microcontroller-based project, it is seen whether an 8-bit, 16-bit or 32bit microcontroller can best handle the computing needs of the task most effectively. Among the other considerations in this category are: Speed What is the highest speed that the microcontroller supports?

Packaging Does it come in 40-pin DIP (dual inline package) or a QFP

(quad flat package), or some other packaging format? This is important in terms of space, assembling, and prototyping the end product. Power consumption This is especially critical for battery-powered products. The number of I/O pins and the timer on the chip. How easy it is to upgrade to higher performance or lower consumption versions. Cost per unit this is important in terms of the final cost of the product in

which a microcontroller is used. 2.) The second criterion in choosing a microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, a code efficient compiler, technical support. 3.) The third criterion in choosing a microcontroller is its ready availability in needed quantities both now and in the future.

2.1.3 A Brief History of 8051 In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. This microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial port, and four ports all on a single chip. At the time it was also referred as A SYSTEM ON A CHIP The 8051 is an 8-bit processor meaning that the CPU can work only on 8 bits data at a time. Data larger than 8 bits has to be broken into 8 bits pieces to be processed by the CPU. The 8051 has a total of four I\O ports each 8 bit wide. There are many versions of 8051 with different speeds and amount of on-chip ROM and they are all compatible with the original 8051. The 8051 is an original member of the 8051 family. There are two other members in the 8051 family of microcontrollers. They are 8052 and 8031. All the three microcontrollers will have the same internal architecture, but they differ in the following aspects.

Microcontroller 8031 89S52 89S52

ROM

RAM 128bytes

Timers 2 3 3

Interrupts 6 6 8

4KB 8KB

I28bytes 256bytes

Thus the microcontroller AT89C52 satisfying this entire criterion is chosen for this work. 2.1.4 Description of AT89C2051 The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with 2K bytes of Flash programmable and erasable read-only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a power- ful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89C2051 provides the following standard features: 2K bytes of Flash, 128 bytes of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level
5

interrupt architecture, a full duplex serial port, a precision analog comparator, onchip oscillator and clock circuitry. In addition, the AT89C2051 is designed with static logic for opera- tion down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The power-down mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. Features of AT89C2051 (1)Compatible with MCS-51 Products (2)2Kbytes of In-System Reprogrammable Flash Memory (3)Endurance: 1,000 Write/Erase Cycles (4)Fully Static Operation: 0 Hz to 24 MHz (5)Two-Level Program Memory Lock (6)128x 8-Bit Internal RAM (7)15 Programmable I/O Lines (8)Two16-Bit Timer/Counters (9)On-chip Analog Comparator (10)Green(Pb/Halide-free)Packaging option (11)Low Power Idle and Power Down Modes (12)Six interrupt sources (13)Programmable serial UART channel (14)Direct LED Drive Outputs (15)Six Interrupt Sources In addition, the AT89C2051 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. Central processing unit is a unit which monitors and controls all processes within the microcontroller and the user cannot affect its work. It consists of several smaller subunits. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
6

Instruction decoder is a part of the electronics which recognizes program instructions and runs other circuits on the basis of that. The abilities of this circuit are expressed in the "instruction set" which is different for each microcontroller family. Arithmetical Logical Unit (ALU) performs all mathematical and logical operations upon data. Accumulator is an SFR closely related to the operation of ALU. It is a kind of working desk used for storing all data upon which some operations should be executed (addition, shift etc.). It also stores the results ready for use in further processing. One of the SFRs, called the Status Register, is closely related to the accumulator, showing at any given time the "status" of a number stored in the accumulator. 2.1.5 Pin diagram & its description

Fig 2.2: Pin diagram of AT89c2051

VCC Supply voltage-5V

GND Ground

Port 1

The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal pull-ups. P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the positive input (AIN0) and the negative input (AIN1), respectively, of the on-chip precision analog comparator. The Port 1 out- put buffers can sink 20 mA and can drive LED displays directly. When 1s are written to Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7 are used as inputs and are externally pulled low, they will source current (IIL) because of the internal pull-ups. Port 1 also receives code data during Flash programming and verification. Port 3
7

Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups. P3.6 is hard-wired as an input to the output of the on-chip comparator and is not accessible as a gen- eral-purpose I/O pin. The Port 3 output buffers can sink 20 mA. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C2051 as listed below:
Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 Alternate Functions RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input)

Port 3 also receives some control signals for flash programming and verification RST

Reset input. All I/O pins are reset to 1s as soon as RST goes high. Holding the RST pin high for two machine cycles while the oscillator is running resets the device. Each machine cycle takes 12 oscillator or clock cycles XATL1

Input to the inveting oscillator amplifier and input to the internal clock operating circuit XATL2 Output from the inverting oscillator amplifier. 2.1.6 Oscillator Characteristics The XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 2.3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2.4. There are no require- ments on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.
8

Figure2.3Oscillator Connections

Note: C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators

Figure2-4. External Clock Drive Configuration

2.1.7 Special Function Registers A map of the on-chip memory area called the Special Function Register (SFR) space is shown in the table below. Note that not all of the addresses are occupied, and unoccupied addresses may not be imple- mented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0.

2.1.8 Restrictions on Certain Instructions The AT89C2051 and is an economical and cost-effective member of Atmels growing family of microcontrollers. It contains 2K bytes of Flash program memory. It is fully compatible with the MCS-51 architecture, and can be programmed using the MCS-51 instruction set. However, there are a few considerations one must keep in mind when utilizing certain instructions to pro- gram this device. All the instructions related to jumping or branching should be restricted such that the destination address falls within the physical program memory space of the device, which is 2K for the AT89C2051. This should be the responsibility of the software programmer. For example, LJMP 7E0H would be a valid instruction for the AT89C2051 (with 2K of memory), whereas LJMP 900H would not.

(1)Branching Instruction
LCALL, LJMP, ACALL, AJMP, SJMP, JMP @A+ DPT R These unconditional branching instructions will execute correctly as long as the programmer keeps in mind that the destination branching address must fall within the physical boundaries of the program memory size (loca- tions 00H to 7FFH for the 89C2051). Violating the physical space limits may cause unknown program behavior. CJNE [...], DJNZ [...], JB, JNB, JC, JNC, JBC, JZ, JNZ With these conditional branching instructions the same rule above applies. Again, violating the memory boundaries may cause erratic execution. For applications involving interrupts the normal interrupt service routine address locations of the 80C51 family architecture have been preserved. (2)MOVX-related Instructions, Data Memory The AT89C2051 contains 128 bytes of internal data memory. Thus, in the AT89C2051 the stack depth is limited to 128 bytes, the amount of available RAM. External DATA memory access is not supported in this device, nor is external PROGRAM memory execution. Therefore, no MOVX [...] instructions should be included in the program. A typical 80C51 assembler will still assemble instructions, even if they are written in violation of the restrictions mentioned above. It is the responsibility of the controller user to know the physi- cal features and limitations of the device being used and adjust the instructions used correspondingly. 2.1.9 Program Memory Lock Bits On the chip are two lock bits which can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the Table 2-1.

10

Lock Bit Protection Modes

Program Lock Bits LB1 1 2 3 U P P LB2 U U P Protection Type No program lock features Further programming of the Flash is disabled Same as mode 2, also verify is disabled

2.1.10 Idle Mode In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the onchip RAM and all the special functions regis- ters remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. The P1.0 and P1.1 should be set to 0 if no external pull-ups are used, or set to 1 if external pull-ups are used It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory 2.1.11 Power-down Mode In the power-down mode the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize . T

11

2.1.12 Programming The Flash The AT89C2051 is shipped with the 2K bytes of on-chip PEROM code memory array in the erased state (i.e., contents = FFH) and ready to be programmed. The code memory array is pro- grammed one byte at a time. Once the array is programmed, to re-program any non-blank byte, the entire memory array needs to be erased electrically. Internal Address Counter: The AT89C2051 contains an internal PEROM address counter which is always reset to 000H on the rising edge of RST and is advanced by applying a positive going pulse to pin XTAL1. P r og r a mm in g Al go r i th m: T o p r ogr am the AT 89C205 1, the fo l l ow ing s e quence is recommended. 1. Power-up sequence: Apply power between VCC and GND pins Set RST and XTAL1 to GND 2. Set pin RST to H Set pin P3.2 to H 3. Apply the appropriate combination of H or L logic levels to pins P3.3, P3.4, P3.5, P3.7 to select one of the programming operations shown in the PEROM Programming Modes table. To Program and Verify the Array: 4. Apply data for Code byte at location 000H to P1.0 to P1.7. 5. Raise RST to 12V to enable programming. 6. Pulse P3.2 once to program a byte in the PEROM array or the lock bits. The byte-write cycle is self-timed and typically takes 1.2 ms. 7. To verify the programmed data, lower RST from 12V to logic H level and set pins P3.3 to P3.7 to the appropriate levels. Output data can be read at the port P1 pins. 8. To program a byte at the next address location, pulse XTAL1 pin once to advance the internal address counter. Apply new data to the port P1 pins. 9. Repeat steps 6 through 8, changing data and advancing the address counter for the entire 2K bytes array or until the end of the object file is reached. 10. Power-off sequence: set XTAL1 to L set RST to L Turn VCC power off

Data Polling: The AT89C2051 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the writ- ten data on P1.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

Ready/Busy: The Progress of byte programming can also be monitored by the RDY/BSY output signal. Pin P3.1 is pulled low after P3.2 goes High during programming to indicate BUSY. P3.1 is pulled High again when programming is done to indicate READY.

Program Verify: If lock bits LB1 and LB2 have not been programmed code data can be read back via the data lines for verificatio

1. Reset the internal address counter to 000H by bringing RST from L to H. 2. Apply the appropriate control signals for Read Code data and read the output data at the port P1 pins. 3. Pulse pin XTAL1 once to advance the internal address counter. 4. Read the next code data byte at the port P1 pins. 5. Repeat steps 3 and 4 until the entire array is read. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled. Chip Erase: The entire PEROM array (2K bytes) and the two Lock Bits are erased electrically by using the proper combination of control signals and by holding P3.2 low for 10 ms. The code array is written with all 1s in the Chip Erase operation and must be executed before any non- blank memory byte can be re-programmed. Reading the Signature Bytes: The signature bytes are read by the same procedure as a nor- mal verification of locations 000H, 001H, and 002H, except that P3.5 and P3.7 must be pulled to a logic low. The values returned are as follows. (000H) = 1EH indicates manufactured by Atmel (001H) = 21H indicates 89C2051

2.2 LM741 General Description The LM741 series are general purpose operational amplifiers. It is intended for a wide range of analog applications. The high gain and wide range of operating voltage provide superior performance in integrator , summing amplifier, and general feedback applications. The amplifiers offer many features which make their application nearly foolproof: overload protection on the input and output, no latch-up when the common mode range is exceeded, as well as freedom from oscillations.

2.2.1

LM 741 Features:

Short circuit protection Excellent temperature stability Internal frequency compensation High Input voltage range Null of offset The 741 chip has been around for many years. Many newer op amps still have this same pinout. Power supply +12 Volts and -12 Volts is typical. A power supply of +5 Volts and -5 Volts is about the lowest useable supply. Higher voltages can be used for driving power amplifier output MOSFETS. The maximum output voltage can never be greater than the power supply voltage. The maximum output voltage from an Ideal Op' Amp' would be equal to the power supply voltage. The maximum output voltage from a typical Op' Amp' would be two to three volts less than the power supply voltage. Saturation: This occurs when the Op' Amp' is attempting to generate an output greater than the power supply voltage. When it fails to do this, the output saturates and the distortion results. This is called clipping or limiting

741 connection diagram:

2.3 Assembly language Programming of 8051:-

(A) 8051 instruction sets:MOV instruction It is used to load a register with some value like:

MOV MOV MOV

A,#51H R1,#0FFH R2,#3BH

; load A= 51 hex ; load R1= FF hex ; load R2= 3B hex

1. This instruction can be used to load any register with a hex value. 2. # signifies that it is a number (and not a byte address). 3. H symbolizes that it is hexadecimal number. Similarly if we write a binary number it should end with B like 1111B & a decimal number can be written as it is or followed by D, 17 or 17D. 4. In the second line of the above code we used 0FFH. The 0 symbolizes that F is a hex number and not letter. This is always necessary if we are writing any hexadecimal number. It should always start with a 0 like 0ABH or 0CFH 5. All the register should be assumed to be of 1 byte. Unless otherwise mentioned. So if we load A= FFFH > 255D (a byte can hold), it is illegal. ADD instruction ADD A, source; add the value in A & source register

This instruion is used to add two numbers When you do an operation between two registers then the first one is called the destination and second is the source. The result of an operation is always stored in destination. The operation ADD should always have registers A as its destination. SUBB instruction SUBB A, source; A= A- source-CY

This instruction is used for subtracting two numbers. Here also the destination is always register A. The result is stored in the register A. (B) RAM Memory Allocation and Addressing Modes:We can access RAM locations (both bytes and bits) in two ways: By address: directly designating through the address of a byte or bit (just like we say house number : 232)

By name: Mode designation through name of a register like A , R1 , R2 (just like we say home of Mr. Donald )

(C) REGISTER BANKS Memory Location: 00- 20 Hex This part of RAM is divided into four register banks. The four register banks are divided into 8 registers R0-R7. In all the programs we have discussed so far we didnt mention which register bank we are using when referring to these R0-R7 registers. The default register bank is zero but we can also choose the other register banks. The register bank one is not used (generally) as it also serves purpose of stack. This part of RAM can be accessed by name as well as the address. By name: Switching to other register banks:-

Register Banks of 8051 Figure-2.12 Now suppose we want to write in the registers of bank 2, then we can set these bits PSW.3 & PSW.4 accordingly to switch to them. ORG 0H SETB PSW.4 ; select bank 2 MOV R1, # 25H ; register 1 of bank2 MOV R2, # 30H ; register 2 of bank 2 END In this case we are loading values in register bank 2.

By address:

{Caution: # means a number and without that it is an address} Below is an example showing the above program (which was earlier written in indirect mode) in direct addressing mode:ORG 0H MOV 10H, # 25H MOV 11H, # 30H ; register 1 of bank2 ; register 2 of bank 2

(D) RAM Memory Allocation:

RAM Memory Allocation Figure-2.13

(E) BIT ADDRESSABLE RAM Memory Locations: 20- 30 hex This part of RAM is bit addressable means we can use the bits address for directly using them. A bit can be set with SETB & cleared with CLR. We can only access this directly by address. There are no special names for this part of RAM. The address of a bit is independent of the byte address.

BIT Addressable RAM Figure-2.14

For e.g.: SETB 5EH ; 5E hex is the address of the bit

; This is direct addressing Operations we can perform on a bit are shown below in the table.

(F) SCRATCH PAD RAM Memory Address: 30 -7F hex This part of RAM doesnt have any specific function and is known as general purpose RAM. We can use it in whatever way we like. This can be accessed only by its address and dont have any special names. Lets write a program to toggle port1 continuously (after a delay).

MOV P1, # 55H ; P1= 55 hex MOV 45H, #100; load counter with 100 (indirect addressing mode) ; Caution- # means a number & without that it is an address

TOG:

CPL

P1

; toggle P1 ; call delay subroutine

ACALL DELAY

DJNZ 45H, TOG; repeat 100 times

(G) SPECIAL FUNCTION REGISTERS (SFRs) Memory Location: 7F- FF hex We have discussed the special registers A, B and PSW. The other will be discussed whenever appropriate. All the ports are also designated as special function registers Some of the SFRs are bit addressable (as shown in figure) Note that I have marked cross at many places in the table and have not mentioned any name for these registers. These registers are reserved for further research and you should not use them. The SFRs can be accessed through names as well as address. The bit address is independent of the byte address.

SFRs Figure-2.15 Indirect Addressing Mode: Till now we have covered the direct accesing modes i.e. MOV A, # 20 H MOV E0H, # 20H ; by name ; by address

(H) Pointers in Assembly Language: When register are used as pointers it is known as Register Indirect Accessing. Only register R0 & R1 can be used as pointers. For using register as a pointer we have to use a sign @ before the registers (R0 & R1). The indirect accessing mode (as pointers) makes data accessing dynamic rather than static as in case of direct addressing mode (by name & address) MOV A, @R0 ; move contents of RAM location whose address is stored is held by R0 ; Into A

MOV @R1, B ; move contents of B into RAM location whose address is held by R1

Let us see an example to copy 30hex in RAM memory locations 50H to 55H: Case1: Direct Accessing Mode MOV MOV MOV MOV MOV MOV MOV A, # 30H 50H, A 51H, A 52H, A 53H, A 54H, A 55H, A ; load A with 30 hex ; copy contents of A into RAM location 50H ; copy contents of A into RAM location 51H ; copy contents of A into RAM location 52H ; copy contents of A into RAM location 53H ; copy contents of A into RAM location 54H ; copy contents of A into RAM location 55H

Case2: Indirect Addressing Mode (without a loop) MOV MOV MOV INC R0 MOV INC R0 MOV INC R0 MOV INC R0 MOV INC R0 MOV @R0, A @R0, A @R0, A @R0, A @R0, A A, # 30H R0, # 50H @R0, A ; load A with 30hex ; load the pointer. R0 = 50H ; copy A to RAM location R0 points to ; Increment the pointer R0, now R0= 51H ; copy A to RAM location R0 points to ; Increment the pointer R0, now R0= 52H ; copy A to RAM location R0 points to ; Increment the pointer R0, now R0= 53H ; copy A to RAM location R0 points to ; Increment the pointer R0, now R0= 54H ; copy A to RAM location R0 points to ; Increment the pointer R0, now R0= 55H ; copy A to RAM location R0 points to

Case3: Indirect Addressing Mode (with a loop) MOV A, # 30H MOV R2, #06H AGAIN: MOV @R0, A INC R0 ; A= 30hex ; load counter, R2= 6 ; copy contents of A into RAM location R0 points to ; increment pointer R0

MOV R0, # 50H ; load pointer. R0, RAM address

DJNZ, AGAIN

; loop until counter = zero

(I)Jump, Loop and Call Instructions:


After we have understood the tutorial on introduction to assembly language which includes simple instruction sets like input/output operations, now its time to learn how to create loops, function calls and jumps while writing a code in assembly language. Let us first discuss an important concept that relates RAM & ROM. You can skip this section if you wish but it is an important to understand registers which helps in building up understanding of architecture of microcontrollers. How a program which is burned in ROM gets executed in RAM? The program you write is burned in ROM and this program is executed in RAM. The data burned is in the form of logics or binary digits (0 & 1) also called an Opcode or machine code. The program written in assembly language is converted to Opcode by assembler. Each line of the assembly code is assigned a unique Opcode by the assembler as shown below. These opcodes are then stored in ROM one after another. There is a register called Program Counter (PC) which always points to the current Opcode being executed. When the power is switched on it sets itself to zero and it keeps on incrementing itself as opcodes are executed one after another. This information is used by RAM to extract correct opcode from ROM which is then executed. This process goes on line by line till the whole program is executed.

Lets take an example:PC 0000 0000 0002 0004 0006 0007 0008 0009 000B 000D 000E NEXT: AGAIN: ORG MOV MOV JZ INC INC INC ADD JNC CLR MOV A A, #77H OVER A R0, A Mnemonic, Operand 0H R0, #0 A, #55H NEXT R0 A 7800 7455 6003 08 04 04 2477 5005 E4 F8 Opcode (Machine code)

000F 0010 0011 0012 0013 0015 0017 HERE: OVER:

MOV MOV MOV ADD, JNC SJMP END

R1, A R2, A R3, A R3 AGAIN HERE

F9 FA FB 2B 50F2 80FE

We can clearly see that the PC increases with execution of program. The PC starts with zero when ORG 00H line is executed and then in subsequent lines PC keeps on incrementing as machine codes are executed one after another. Program Counter is a 2 byte or 16 bit register. Therefore we cannot have internal ROM of more than the number this register can hold (i.e. not exceeding the FFFF hex value).

(J) Loop and Jump Instructions: Let us start with a simple example that will help you to learn how to create loops in assembly. In the following code the instruction DJNZ is used to reduce the counter and is repeated till the counter becomes zero.

Eg-1: ORG MOV MOV DJNZ MOV END In this code R1 acts as a counter. The counter value is initialized i.e. 10 HEX is loaded to R1. In each iteration, the instruction DJNZ decrements R1 by one until it becomes zero. This loop adds 5 HEX to A every time it runs. After ten iterations R1 becomes zero and the instructions below it are executed. 0H A, #0 R1, #10 ADD R1, AGAIN R3, A ; clear A ; load counter R1 =10 A, # 05 ; add five to register A ; repeat until R1=0 (10 times) ; save A in R3

AGAIN:

Note: - Some Jump statements can only be performed on some special register A (or bit CY) as mentioned in the table below.

Nested loops: ORG 0H MOV MOV NEXT: AGAIN: MOV CPL DJNZ DJNZ END SJMP refers to short jump and LJMP refers to long jump. All the conditional jumps are short jumps. SJMP: This instruction is of two bytes in which first one is opcode & second is the address. The relative address of the instruction called should be in between -127 to 127 bytes from the current program counter (PC). LJMP: This instruction is of three bytes in which the first is the opcode and the second & third are for address. The relative address of the instruction can be anywhere on the ROM. So it is clear from the above examples that we can use different jump instructions with a condition or counter called conditional loop. And when we create loop inside an existing loop it is called nested loop. (K) Call Instructions: Example: A, #55H R1, #100 R2, # 20 A, # 05 R2, AGAIN R1, NEXT ; A= 55 hex ; the outer counter R1 =100 ; the inner counter ; add five to register A ; repeat until R1=0 (100 times) ; repeat till 20 times (outer loop)

LCALL (long call) ORG BACK: MOV MOV 0H A, #55H P1, A ; load A= 55 hex value ; issue value of register A to port1 ; to call DELAY function created below ; load AAH hex value to A ; issue value of register A to port 1 ; to call DELAY function as created below ; keep doing this; ________ this is the delay subroutine

LCALL DELAY MOV A, #0AAH MOV P1, A LCALL DELAY SJMP DELAY: MOV AGAIN: DJNZ RET END BACK

R5, #0FFH R5, AGAIN

; R5= 255 hex, the counter ; stay here until R5 becomes zero ; return to caller

In this code we keep on toggling the value of the register of port 1 with two different hex values and a DELAY subroutine is used to control how fast the value is changing. Here in DELAY subroutine the program is kept busy by running an idle loop and counting 256 counts. After the DELAY subroutine is executed once the value of port 1 is toggled and this process goes on infinitely. By using DELAY we can create PWM (Pulse Width Modulation) to control motors or LED blinking for further details view our tutorial on Input/ output instructions in Assembly Language[coming soon]. We can also use ACALL i.e. absolute call for calling a subroutine that is within 2K byte of PC. By using DELAY we can create PWM (Pulse Width Modulation) to control motors or LED blinking for further details view our tutorial on Input/ output instructions in Assembly Language[coming soon]. We can also use ACALL i.e. absolute call for calling a subroutine that is within 2K byte of PC. 2.3.1 Programming used for automatic plant irrigation Microcontroller Chip type : AT89c2051 Program type : Application Clock frequency : 12.000000 MHz

Memory model : Small External SRAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega16.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 // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTC=0x00; DDRC=0xFF; // 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 // Clock value: Timer 1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer 1 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: Timer 2 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; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80;

SFIOR=0x00; while (1) { if (PORTB.0 || PORTB.1 || PORTB.2 || PORTB.3 == 1) { PORTC = 0x09; } else { PORTC = 0x06; } }; }

END
2.4 Power supply unit: 2.4.1 Power supply There are many types of power supply. Most are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronic circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. For example a 5V regulated supply can be shown as below Similarly, 12v regulated supply can also be produced by suitable selection of the individual elements. Each of the blocks is described in detail below and the power supplies made from these blocks are described below with a circuit diagram and a graph of their output.

2.4.2

Transformer A transformer steps down high voltage AC mains to low voltage AC. Here we are using a centertap transformer whose output will be sinusoidal with 36volts peak to peak value.

Fig: 3.9 Output Waveform of transformer

The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for electronic circuits unless they include a rectifier and a smoothing capacitor. The transformer output is given to the rectifier circuit.

2.4.3

Rectifier A rectifier converts AC to DC, but the DC output is varying. There are several types of rectifiers; here we use a bridge rectifier. The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite ends of the bridge. The load resistance is connected between the other two ends of the bridge. For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance RL and hence the load current flows through RL. For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load resistance RL and hence the current flows through RL in the same direction as in the previous half cycle. Thus a bi-directional wave is converted into unidirectional.

Fig 3.10 Rectifier

Fig 3.11: Output waveform of rectifier

The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for electronic circuits unless they include a smoothing capacitor

2.4.4

Smoothing The smoothing block smoothes the DC from varying greatly to a small ripple. The ripple voltage is defined as the deviation of the load voltage from its DC value. Smoothing is also named as filtering. Filtering is frequently effected by shunting the load with a capacitor. The action of this system depends on the fact that the capacitor stores energy during the conduction period and delivers this energy to the loads during the no conducting period. In this way, the time during which the current passes through the load is prolongated, and the ripple is considerably decreased. The action of the capacitor is shown with the help of waveform.

2.4.5 Voltage regulator: IC7805 is a three terminal 1A positive voltage regulator which is used for regulation. It is available in TO-220/D-PAK package useful in wide range of applications. If adequate heat sink is provided, they will deliver over 1A output current. Although it is designed primarily as fixed voltage regulators these devices can be used with external components to obtain adjustable voltages and currents. Features: output current up to 1A, output voltages of 5, 6, 8, 9, 10, 15, 18, 24V, thermal overload protection, short circuit protection, output transistor safe operating area protection.

Fig 3.14: IC7805 PIN 2.5 Relays A relay is an electrically controllable switch widely used in industrial controls, automobiles and appliances. The relay allows the isolation of two separate sections of a system with two different voltage sources i.e., a small amount of voltage/current on one side can handle a large amount of voltage/current on the other side but there is no chance that these two voltages mix up.

Fig 3.17 Relay symbol 2.5.1 Operation

Fig 3.18: operation and use of protection diode

When a current flow through the coil, a magnetic field is created around the coil i.e., the coil is energized. This causes the armature to be attracted to the coil. The armatures contact acts like a switch and closes or opens the circuit. When the coil is not energized, a spring pulls the armature to its normal state of open or closed. There are all types of relays for all kinds of applications. Transistors and ICs must be protected from the brief high voltage 'spike' produced when the relay coil is switched off. The above diagram shows how a signal diode (e.g. 1N4148) is connected across the relay coil to provide this protection. The diode is connected 'backwards' so that it will normally not conduct. Conduction occurs only when the relay coil is switched off, at this moment the current tries to flow continuously through the coil and it is safely diverted through the diode. Without the diode no current could flow and the coil would produce a damaging high voltage 'spike' in its attempt to keep the current flowing. In choosing a relay, the following characteristics need to be considered: The contacts can be normally open (NO) or normally closed (NC). In the NC type, the contacts are closed when the coil is not energized. In the NO type, the contacts are closed when the coil is energized. There can be one or more contacts. i.e., different types like SPST (single pole single throw), SPDT (single pole double throw) and DPDT (double pole double throw) relay. The voltage and current required to energize the coil. The voltage can vary from a few volts to 50 volts, while the current can be from a few milliamps to 20milliamps. The relay has a minimum voltage, below which the coil will not be energized. This minimum voltage is called the pull-in voltage. The minimum DC/AC voltage and current that can be handled by the contacts. This is in the range of a few volts to hundreds of volts, while the current can be from a few amps to 40A or more, depending on the relay.

2.5.2 Driving a relay An SPDT relay consists of five pins, two for the magnetic coil, one as the common terminal and the last pins as normally connected pin and normally closed pin. When the current flows through this coil, the coil gets energized. Initially when the coil is not energized, there will be a connection between the common terminal and normally closed pin. But when the coil is energized, this connection breaks and a new connection between the common terminal and normally open pin will be established. Thus when there is an input from the microcontroller to the relay, the relay will be switched on. Thus when the relay is on, it can drive the loads connected between the common terminals and normally open pin.

Therefore, the relay takes 5V from the microcontroller and drives the loads which consume high currents. Thus the relay acts as an isolation device. 2.6 DC Motor The DC motors are configured in many types and sizes, including brushless, servo, and gear motor types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is maintained using either permanent or electromagnetic windings. Dc motors are mostly commonly used in variable speed and torque. Motors are the devices that provide the actual speed and torque in a drive system. This family includes AC motor types (single and multiphase motors, universal, servo motor, induction, synchronous and gear motor) and DC motors (brush less, servo motor and gear motor) as well as linear, stepper and air motors, and motor contactors and stators. In any electric motor, operation is based on simple electromagnetism. A current-carrying conductor generates a magnetic field; when this is then placed in an external magnetic field, it will experience a force proportional to the current in the conductor, and to the strength of the external magnetic field. The internal configuration of a DC motor is designed to harness the magnetic interaction between a current-carrying conductor and an external magnetic field to generate rotational motion. Every DC motor has six basic parts --- axel, rotor, stator, commutator, field magnet, and brushes. In most common DC motors, external magnetic field is produced by high-strength permanent magnets. The stator is the stationary part of the motor this includes the motor casing, as well as two or more permanent magnet pole pieces 2.7 Light-Emitting Diode (LED) A light-emitting diode, usually called an LED, is a semiconductor diode that emits incoherent narrow-spectrum light when electrically biased in the forward direction of the p-n junction, as in the common LED circuit. This effect is a form of electroluminescence. A LED is usually a small area light source, often with extra optics added to the chip that shapes its radiation pattern. LEDs are often used as small indicator lights on electronic devices and increasingly in higher power applications such as flashlights and area lighting. The color of the emitted light depends on the composition and condition of the semi conducting material used, and can be infrared, visible, or ultraviolet. LEDs can also be used as a regular household light source. Besides lighting, interesting applications include sterilization of water and disinfection of devices.

2.7.1 Physical function of LED Like a normal diode, the LED consists of a chip of semi conducting material Impregnated, or 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. Chargecarriers electrons and holes flow 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 ever-shorter 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. Substrates that are transparent to the emitted wavelength, and backed by a reflective layer, increase the LED efficiency. The refractive index of the package material should match the index of the semiconductor, otherwise the produced light gets partially reflected back into the semiconductor, where it may be absorbed and turned into additional heat, thus lowering the efficiency. This type of reflection also occurs at the surface of the package if the LED is coupled to a medium with a different refractive index such as a glass fiber or air. The refractive index of most LED semiconductors is quite high, so in almost all cases the LED is coupled into a much lower-index medium. The large index difference makes the reflection quite substantial (per the Fresnel coefficients), and this is usually one of the dominant causes of LED inefficiency. Often more than half of the emitted light is reflected back at the LED-package and package-air interfaces. The reflection is most commonly reduced by using a dome-shaped (half-sphere) package with the diode in the center so that the outgoing light rays strike the surface perpendicularly, at which angle the reflection is minimized. An anti-reflection coating may be added as well. The package may be cheap plastic, which may be colored, but this is only for cosmetic reasons or to improve the contrast ratio; the color of the packaging does not substantially affect the color of the light emitted. Other strategies for reducing the

impact of the interface reflections include designing the LED to reabsorb and reemit the reflected light (called photon recycling) and manipulating the microscopic structure of the surface to reduce the reflectance, either by introducing random roughness or by creating programmed moth eye surface patterns. Conventional LEDs are made from a variety of inorganic semiconductor materials, producing the following colors:

Fig 3.19: LED

Aluminum gallium arsenide (AlGaAs) red and infrared Aluminum gallium phosphide (AlGaP) green Aluminum gallium indium phosphide (AlGaInP) high-brightness orange-red, orange, yellow, and green Gallium arsenide phosphide (GaAsP) red, orange-red, orange, and yellow Gallium phosphide (GaP) red, yellow and green (GaN) green, pure green (or emerald green), and blue also white (if it has an AlGaN Quantum Barrier) Indium gallium nitride (InGaN) 450 nm - 470 nm near ultraviolet, bluish-green and blue Silicon carbide (SiC) as substrate blue Silicon (Si) as substrate blue (under development) Sapphire (Al2O3) as substrate blue Zinc selenide (ZnSe) blue Diamond (C) ultraviolet

Aluminium nitride (AlN), aluminum gallium nitride (AlGaN), aluminum gallium indium nitride (AlGaInN) near to far ultraviolet (down to 210 nm) With this wide variety of colors, arrays of multicolor LEDs can be designed to produce unconventional color patterns.

2.7.2

Efficiency and operational parameters Most typical LEDs are designed to operate with no more than 3060 mill watts of electrical power. Around 1999, Philips Lumileds introduced power LEDs capable of continuous use at one watt. These LEDs used much larger semiconductor die sizes to handle the large power inputs. Also, the semiconductor dies were mounted onto metal slugs to allow for heat removal from the LED die. One of the key advantages of LED-based lighting is its high efficiency, as measured by its light output per unit power input. White LEDs quickly matched and overtook the efficiency of standard incandescent lighting systems. In 2002, Lumileds made five-watt LEDs available with a luminous efficacy of 1822 lumens per watt (lm/W). For comparison, a conventional 60100 watt incandescent light bulb produces around 15 lm/W, and standard fluorescent lights produce up to 100 lm/W. (The luminous efficacy article discusses these comparisons in more detail.) In September 2003, a new type of blue LED was demonstrated by the company Cree, Inc. to provide 24 mW at 20 mA. This produced a commercially packaged white light give 65 lumens per watt at 20 mA, becoming the brightest white LED commercially available at the time, and more than four times as efficient as standard incandescent. In 2006 they demonstrated a prototype with a record white LED luminous efficacy of 131 lm/W at 20 mA. Also, Seoul Semiconductor has plans for 135 lm/W by 2007 and 145 lm/W by 2008, which would be approaching an order of magnitude improvement over standard incandescent and better even than standard fluorescents. Nichia Corporation has developed a white light LED with luminous efficacy of 150 lm/W at a forward current of 20 mA. It should be noted that high-power ( 1 watt) LEDs are necessary for practical general lighting applications. Typical operating currents for these devices begin at 350 mA. The highest efficiency high-power white LED is claimed by Philips Lumileds Lighting Co. with a luminous efficacy of 115 lm/W (350 mA).

2.7.3

Considerations in use: Unlike incandescent light bulbs, which light up regardless of the electrical polarity, LEDs will only light with correct electrical polarity. When the voltage across the p-n junction is in the correct direction, a significant current flows and the device is said to be forward-biased. If the voltage is of the wrong polarity, the device is said to be reverse biased, very little current flows, and no light is emitted. Some LEDs can be operated on an alternating current voltage, but they will only light with positive voltage, causing the LED to turn on and off at the frequency of the AC supply.

2.7.3.1 Advantages of using LEDs

LEDs produce more light per watt than incandescent bulbs; this is useful in battery powered or energysaving devices.

LEDs can emit light of an intended color without the use of color filters that traditional lighting methods require. This is more efficient and can lower initial costs.

The solid package of the LED can be designed to focus its light. Incandescent and fluorescent sources often require an external reflector to collect light and direct it in a usable manner.

When used in applications where dimming is required, LEDs do not change their color tint as the current passing through them is lowered, unlike incandescent lamps, which turn yellow.

LEDs are ideal for use in applications that are subject to frequent on-off cycling, unlike fluorescent lamps that burn out more quickly when cycled frequently, or HID lamps that require a long time before restarting.

LEDs, being solid state components, are difficult to damage with external shock. Fluorescent and incandescent bulbs are easily broken if dropped on the ground.

LEDs can have a relatively long useful life. One report estimates 35,000 to 50,000 hours of useful life, though time to complete failure may be longer. Fluorescent tubes typically are rated at about 30,000 hours, and incandescent light bulbs at 1,0002,000 hours LEDs mostly fail by dimming over time, rather than the abrupt burn-out of incandescent bulbs.

LEDs light up very quickly. A typical red indicator LED will achieve full brightness in microseconds; Philips Lumileds technical datasheet DS23 for the Luxeon Star states "less than 100ns." LEDs used in communications devices can have even faster response times.

LEDs can be very small and are easily populated onto printed circuit boards. LEDs do not contain mercury, unlike compact fluorescent lamps.

2.7.3.2 Disadvantages of using LEDs:

LEDs are currently more expensive, price per lumen, on an initial capital cost basis, than more conventional lighting technologies. The additional expense partially stems from the relatively low lumen output and the drive circuitry and power supplies needed. However, when considering the total cost of ownership (including energy and maintenance costs), LEDs far surpass incandescent or halogen sources and begin to threaten compact fluorescent lamps. In December 2007, scientists at Glasgow University claimed to have found a way to make Light Emitting Diodes brighter and use less power than energy efficient light bulbs currently on the market by imprinting

Holes into billions of LEDs in a new and cost effective method using a process known as nano imprint lithography.

LED performance largely depends on the ambient temperature of the operating environment. Over-driving the LED in high ambient temperatures may result in overheating of the LED package, eventually leading to device failure. Adequate heat-sinking is required to maintain long life. This is especially important when considering automotive, medical, and military applications where the device must operate over a large range of temperatures, and is required to have a low failure rate.

LEDs must be supplied with the correct current. This can involve series resistors or regulated power supplies.

The spectrum of some white LEDs differs significantly from a black body radiator, such as the sun or an incandescent light. The spike at 460 nm and dip at 500 nm can cause the color of objects to be perceived differently under LED illumination than sunlight or incandescent sources, due to metamerism. Color rendering properties of common fluorescent lamps are often inferior to what is now available in state-of-art white LEDs.

LEDs do not approximate a "point source" of light, so cannot be used in applications needing a highly collimated beam. LEDs are not capable of providing divergence below a few degrees. This is contrasted with commercial ruby lasers with divergences of 0.2 degrees or less. This can be corrected by using lenses and other optical devices.

There is increasing concern that blue LEDs and white LEDs are now capable of exceeding safe limits of the so-called blue-light hazard as defined in eye safety specifications such as ANSI/IESNA RP-27.1-05: Recommended Practice for Photo biological Safety for Lamp and Lamp Systems.

2.7.4

LED applications: Some of these applications are further elaborated upon in the following text.

Remote controls, such as for TVs and VCRs, often use infrared LEDs Glow lights, as a more expensive but longer lasting and reusable alternative to Glow sticks.

Movement sensors, for example in optical computer mice The Nintendo Wii's sensor bar uses infrared LEDs. In optical fiber and Free Space Optics communications. Toys and recreational sporting goods, such as the Flash flight Lumalive, a photonic textile In pulse oximeters for measuring oxygen saturation LED phototherapy for acne using blue or red LEDs has been proven to significantly reduce acne over a 3 month period. Some flatbed scanners use an array of red, green, and blue LEDs rather than the typical cold-cathode fluorescent lamp as the light source. Having independent control of three illuminated colors allows the scanner to calibrate itself for more accurate color balance, and there is no need for warm-up.

Computers, for hard drive activity and power on. Some custom computers feature LED accent lighting to draw attention to a given component. Many computer manufacturers use LEDs to tell the user its current state. One example would be the Mac, which tells its user when it is asleep by fading the LED activity lights in and out, in and out.

Sterilization of water and other substances using UV light.

2.15.5 LED schematic symbol:

Fig 3.20: LED symbol

CHAPTER3 IMPLEMENTATION AND RESULTS


3.1.1 SOFTWARE USED 1. A Cross compiler for compiling and linking the code written for AT89C51. 2. Serial communication software for downloading code to AT89C51. 3. Operating system: Windows 2000.

3.1.2 Instruments 1.Power Supply 3.2WORKING OF CIRCUIT Irrigation is the key to a successful garden. Long gone are the days of manual watering or relying on a friend to water when you are on vacation or away on business. The Project presented here waters your plants regularly when you are out for vocation. The circuit comprises sensor parts built using op-amp IC LM324. Op-amp is configured here as a comparator. Two stiff copper wires are inserted in the soil to sense the whether the Soil is wet or dry. The comparator monitors the sensors and when sensors sense the dry condition then the project will switch on the motor and it will switch off the motor when the sensors are in wet. The comparator does the above job it receives the signals from the sensors. A transistor is used to drive the relay during the soil wet condition. 5V double pole double through relay is used to control the water pump. LED indication is provided for visual identification of the relay / load status. A switching diode is connected across the relay to neutralize the reverse EMF. This project works with 5V regulated power supply. Power on LED is connected for visual identification of power status. This project uses regulated 5V, 750mA power supply. 7805 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac out put of secondary of 230/18V step down transformer.

For the design and development of the system, the methodology used involves the software and hardware implementation. The actual implementation of the system involves the following steps: System Definition: Broad definition of system hardware including

microcontroller and its interface with LCD, motor, sensor, relay. Circuit Design: Selection of AT85C52 microcontroller and other devices, as per system definition. Design of hardware circuit and its testing on laboratory kits with some simple microcontroller software routines. PCB Design and Fabrication: Generation of schematic diagrams and the production of circuit board layout data for the procurement of the circuit board. Hardware Modifications: Making any hardware changes found necessary after the initial hardware tests, to produce a revised circuit board schematic diagram and layout. Software Design: Developing algorithm for the system, allocating memory blocks as per functionality, coding and testing. Integration and Final Testing: Integrating the entire hardware and software modules and its final testing. Thus the complete design is divided into two parts: 1.) Hardware Implementation. 2.) Software Implementation.

Figure 4.1 shows the schematic for the implementation of the hardware for this purpose

Fig. 4.1 circuit diagram

3.2.1 Connections of Power supply unit 1. It consists of 230 volts 12 volts step down transformer it serves as a basic input power. 2. As soon as power flows into the circuit, it passes through the bridge rectifier which consists of four diodes. 3. These four diodes are used to rectify the AC current and covert into pulsating DC 4. To remove the unwanted frequencies, we use a 1000 micro farads / 25 V capacitor which help in smoothening of the DC. 5. Output of this capacitor stage is given to the voltage regulator 7805 which consists of 3 pins input, ground and output. 6. The voltage regulator gives the output of +5V for any values of input ranging from 8V to 35V. 7. The voltage regulator is followed by a 2.2K resistor and the other end of resistor is connected to LED. 8. The 2.2K resistor is used for protection of the LED. 9. Also we use a 0.1 micro farad capacitor to stop AC if necessary.
10. This 5V of power supply flows across all the components of the circuit.

3.2.2 Connections of Relay and 12V DC Motor 1. It consists of a transistor 222 whose emitter is connected to 10K resistor in parallel with 1K resistor. 2. The circuit is connected in common base configuration. 3. The anode of PN junction diode 1N 4007 is connected to the collector of the transistor which in turn is connected to relay switch. 4. The relay switch has 3 input terminals, out of which 1st terminal is connected to the diode 3rd terminal is connected to ground and 2nd terminal can be used to switch on and switch off the relay.

5. The 3 output terminals of relay are connected such that 1 st terminal is connected to the input pin of voltage regulator IC 7805, 2nd to the positive end of 12V DC motor and the 3rd terminal to the ground pin of IC 7805. 6. The relay switch is on when the sensor senses dry condition which is indicated on the LCD. 7. The relay switch is off when the sensor senses wet condition which is also indicated on the LCD. 8. 12V DC Motor has basically two terminals in the output, positive end of which is connected to second terminal of the relay circuit and negative end is connected to the ground pin which is taken from the power supply unit.

3.2.3 Flow Chart for working process of AUTOMATIC PLANT IRRIGATION

3.3 Result: All the hardware is implemented according to procedure mentioned in this chapter. Power supply to the microcontroller unit is always kept ON such that as soon as the plants dry condition is sensed by the sensor, immediately the motor switches ON and water flows in to the field. Later when the field becomes wet, the sensor senses the wet condition and the motor switches OFF automatically. The plants dry condition and plants wet condition is displayed on the LCD accordingly. Hence the result.

CHAPTER 4 CONCLUSION AND FUTURE SCOPE

4.1Conclusion The Microcontroller based automatic plant irrigation system proves to be a real time feedback control system which monitors and controls all the activities of irrigation system efficiently. The present proposal is a model to modernize the agriculture industries at a mass scale with optimum expenditure. This automatic plant irrigation system can also employed by poor farmer. Using this system, one can save manpower, water to improve production and ultimately profit.

4.2 future work The main scope of this project is to make the irrigation automated. With the use of low cost sensors and the simple circuitry makes this project a low cost product, which can be bought even by a poor farmer. This project is best suited for places where water is scares and has to be used in limited quantity. Irrigation is the key to a successful garden. The Project presented here waters your plants regularly when you are out for vocation. The development of this system requires microcontroller architecture, opamp, LCD, motor, and de debugging of the application program. This automatic plant irrigation system is used to water roof gardens, lawns, agricultural lands, home gardens, etc.,. The advantage of this system is it is highly sensitive, works according to the soil condition, low cost and reliable circuit, and complete elimination of manpower

CHAPTER 5 BIBLIOGRAPHY

5.1References 1. http://docs.google.com/viewer? a=v&q=cache:ZU5ZL0HuIPoJ:www.seminarprojects.com/attachment.php%3Faid %3D8963+automatic+plant+irrigation&hl=en&pid=bl&srcid=ADGEESj7qlcQC Vjp4-eYL0

2. http://www.scribd.com/doc/42621055/New-Report 3. www.atmel.com 4. Microcontrollers- MAZIDI 5. www.PLCIE.com 6. Fundamentals of Micro processors and Micro computers by B.Ram
7. Microprocessor Architecture, Programming & Applications by Ramesh

S.Gaonkar 8. Electronic Components by D.V.Prasad 9. http://www.8051projects.net/keil-c-programming-tutorial/introduction.php 10. http://www.tec-shop.de/ 11. www.microsoftsearch.com 12. www.geocities.com 13. www.national.com 14. http://www.atmel.com/dyn/resources/prod_documents/doc1919.pdf 15. http://www.kpsec.freeuk.com/components/relay.htm http://www.zntu.edu.ua/base/lection/rpf/lib/zhzh03/8051_tutorial.pdf

Das könnte Ihnen auch gefallen