You are on page 1of 104

GREENHOUSE MONITORING USING ZIGBEE

ABSTRACT
Monitoring and control of greenhouse environment play an important role in
greenhouse production and management. To monitor the greenhouse environment
parameters effectively, it is necessary to design a measurement and control system.
The aim of this project is to monitor the conditions in green house by using sensor
nodes which collect the signals from the humidity sensor, soil moisture sensor and
control the actuators, and transmit the data through the wireless RF transceiver; the
master node receives the data through the RF transceiver.
All the parameters can be measured by using ATMEL 89s52 microcontroller
transmitted to far distance by using wireless communication system called Zigbee. .
Result shows that the system is practical and reliable, and has wide application in the
future

Page
1
DEPATMENT OF EIE

INTRODUCTION
We live in a world where everything can be controlled and operated
automatically, but there are still a few important sectors in our country where
automation has not been adopted or not been put to a full-fledged use, perhaps
because of several reasons one such reason is cost. One such field is that of
agriculture. Agriculture has been one of the primary occupations of man since early
civilizations and even today manual interventions in farming are inevitable.
Greenhouses form an important part of the agriculture and horticulture sectors in our
country as they can be used to grow plants under controlled climatic conditions for
optimum produce. Automating a greenhouse envisages monitoring and controlling
of the climatic parameters which directly or indirectly govern the plant growth and
hence their produce. Automation is process control of industrial machinery and
processes, thereby replacing human operators.
CURRENT SCENARIO:
Greenhouses in India are being deployed in the high-altitude regions where the
sub- zero temperature up to -40 C makes any kind of plantation almost impossible
and in arid regions where conditions for plant growth are hostile. The existing set-ups
primarily are:
MANUAL SET-UP:
Page
2
DEPATMENT OF EIE

This set-up involves visual inspection of the plant growth, manual irrigation of
plants, turning ON and OFF the temperature controllers, manual spraying of the
fertilizers and pesticides. It is time consuming, vulnerable to human error and
hence less accurate and unreliable.

PARTIALLY AUTOMATED SET-UP:

This set-up is a combination of manual supervision and partial automation


and is similar to manual set-up in most respects but it reduces the labor
involved in terms of
irrigating the set-up.
FULLY- AUTOMATED:
This is a sophisticated set-up which is well equipped to react to most of the climatic
changes occurring inside the greenhouse. It works on a feedback system which helps it
to respond to the external stimuli efficiently. Although this set-up overcomes the
problems caused due to human errors it is not completely automated and expensive.

3.BLOCK DIAGRAM OF THE PROJECT

Page
3
DEPATMENT OF EIE

Page
4
DEPATMENT OF EIE

Fig 3.1-BLOCK DIAGRAM


4.Power Supply
Block Diagram:
There are many types of power supply. Most are designed to convert high voltage AC
mains electricity to a suitable low voltage supply for electronics 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:
Page
5
DEPATMENT OF EIE

FIG 4.1

Each of the blocks is described in more detail below:


Transformer - steps down high voltage AC mains to low voltage AC.
Rectifier - converts AC to DC, but the DC output is varying.
Smoothing - smoothes the DC from varying greatly to a small ripple.
Regulator - eliminates ripple by setting DC output to a fixed voltage.
Power supplies made from these blocks are described below with a circuit diagram and a
graph of their output:
Transformer only
Transformer + Rectifier
Transformer + Rectifier + Smoothing

Transformer + Rectifier + Smoothing + Regulator

Dual Supplies:

Page
6
DEPATMENT OF EIE

Some electronic circuits require a power supply with positive and negative outputs as
well as zero volts (0V). This is called a 'dual supply' because it is like two ordinary
supplies connected together as shown in the diagram.
Dual supplies have three outputs, for example a 9V supply has +9V, 0V and -9V
outputs.

Transformer only:

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.
Transformer + Rectifier:

Page
7
DEPATMENT OF EIE

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.
Transformer + Rectifier + Smoothing:

The smooth DC output has a small ripple. It is suitable for most electronic circuits.

Transformer + Rectifier + Smoothing + Regulator:

Page
8
DEPATMENT OF EIE

The

regulated DC output is very smooth with no ripple. It is suitable for all electronic

circuits.

Transformer:

Transformer circuit symbol

Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC.
Step-up transformers increase voltage, step-down transformers reduce voltage. Most
power supplies use a step-down transformer to reduce the dangerously high mains
voltage (230V in UK) to a safer low voltage.
Page
9
DEPATMENT OF EIE

The input coil is called the primary and the output coil is called the secondary. There is
no electrical connection between the two coils, instead they are linked by an alternating
magnetic field created in the soft-iron core of the transformer. The two lines in the

middle of the circuit symbol represent the core.


Transformers waste very little power so the power out is (almost) equal to the power in.
Note that as voltage is stepped down current is stepped up.
The ratio of the number of turns on each coil, called the turns ratio, determines the ratio
of the voltages. A step-down transformer has a large number of turns on its primary
(input) coil which is connected to the high voltage mains supply, and a small number of
turns on its secondary (output) coil to give a low output voltage.

Rectifier:
There are several ways of connecting diodes to make a rectifier to convert AC to DC.
The bridge rectifier is the most important and it produces full-wave
varying DC. A full-wave rectifier can also be made from just two diodes if a centre-tap
transformer is used, but this method is rarely used now that diodes are cheaper. A
single diode can be used as a rectifier but it only uses the positive (+) parts of the AC
wave to produce half-wave varying DC.

Bridge rectifier:

Page
10
DEPATMENT OF EIE

A bridge rectifier can be made using four individual diodes, but it is also available in
special packages containing the four diodes required. It is called a full-wave rectifier
because it uses the entire AC wave (both positive and negative sections). 1.4V is used up
in the bridge rectifier because each diode uses 0.7V when conducting and there are
always two diodes conducting, as shown in the diagram below. Bridge rectifiers are
rated by the maximum current they can pass and the maximum reverse voltage they can
withstand (this must be at least three times the supply RMS voltage so the rectifier can
withstand the peak voltages). Please see the Diodes page for more details, including
pictures of bridge rectifiers.

Page
11
DEPATMENT OF EIE

Bridge rectifier

Output: full-wave varying DC

Alternate pairs of diodes conduct, changing

(using all the AC wave)

over
the connections so the alternating
directions of
AC isconverted to one direction of DC.

Single diode rectifier:


A single diode can be used as a rectifier but this produces half-wave varying DC which
has gaps when the AC is negative. It is hard to smooth this sufficiently well to supply
electronic circuits unless they require a very small current so the smoothing capacitor
does not significantly discharge during the gaps. Please see the Diodes page for some
examples of rectifier diodes.

Output: half-wave varying DC

Single diode rectifier

(using only half the AC wave)

Smoothing:

Page
12
DEPATMENT OF EIE

Smoothing is performed by a large value electrolytic capacitor connected across the DC


supply to act as a reservoir, supplying current to the output when the varying DC voltage
from the rectifier is falling. The diagram shows the unsmoothed varying DC (dotted
line) and the smoothed DC (solid line). The capacitor charges quickly near the peak of
the varying DC, and then discharges as it supplies current to the output.

Note that smoothing significantly increases the average DC voltage to almost the peak
value (1.4 RMS value). For example 6V RMS AC is rectified to full wave DC of about
4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost
the peak value giving 1.4 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges,
giving a small ripple voltage. For many circuits a ripple which is 10% of the supply
voltage is satisfactory and the equation below gives the required value for the smoothing
capacitor. A larger capacitor will give fewer ripples. The capacitor value must be
doubled when smoothing half-wave DC.
There is more information
about smoothing on the
Electronics in Meccano

5 Io
Vs f

website.
Page
13
DEPATMENT OF EIE

Smoothing capacitor for 10% ripple, C =

C = smoothing capacitance in farads (F)


Io = output current from the supply in amps (A)
Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC
f

= frequency of the AC supply in hertz (Hz), 50Hz in the UK

5.POWER SUPPLY CIRCUIT (FIG 5.1)

Page
14
DEPATMENT OF EIE

Voltage Regulator:

Page
15
DEPATMENT OF EIE

Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable
output voltages. They are also rated by the maximum current they can pass. Negative
voltage regulators are available, mainly for use in dual supplies. Most regulators include
some automatic protection from excessive current ('overload protection') and
overheating ('thermal protection').
Many of the fixed voltage regulators ICs have 3 leads and look like power transistors,
such as the 7805 +5V 1A regulator shown on the right. They include a hole for attaching
a heatsink if necessary.
Please see the Electronics in Meccano website for more information about voltage
regulator ICs.

Page
16
DEPATMENT OF EIE

zener diode
a = anode, k = cathode

Zener diode regulator:


For low current power supplies a simple voltage regulator can be made with a resistor
and a zener diode connected in reverse as shown in the diagram. Zener diodes are rated
by their breakdown voltage Vz and maximum power Pz (typically 400mW or 1.3W).
The resistor limits the current (like an LED resistor). The current through the resistor is
constant, so when there is no output current all the current flows through the zener diode
and its power rating Pz must be large enough to withstand this.
Please see the Diodes page for more information about zener diodes.
Choosing a zener diode and resistor:
1. The zener voltage Vz is the output voltage required
2. The input voltage Vs must be a few volts greater than Vz
(this is to allow for small fluctuations in Vs due to ripple)
3. The maximum current Imax is the output current required plus 10%
4. The zener power Pz is determined by the maximum current: Pz > Vz Imax
Page
17
DEPATMENT OF EIE

5. The resistor resistance: R = (Vs - Vz) / Imax


6. The resistor power rating: P > (Vs - Vz) Imax

6.MICRO CONTROLLER
A microcontroller (or MCU) is a computer-on-a-chip used to control electronic
devices. It is a type of microprocessor emphasizing self-sufficiency and costeffectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). A
typical microcontroller contains all the memory and interfaces needed for a simple
application, whereas a general purpose microprocessor requires additional chips to
provide these functions. A microcontroller is a single integrated circuit with the
following key features:
central processing unit - ranging from small and simple 8-bit processors to
sophisticated 32- or 64-bit processors
input/output interfaces such as serial ports
peripherals such as timers and watchdog circuits
RAM for data storage
ROM, EEPROM or Flash memory for program storage
clock generator - often an oscillator for a quartz timing crystal, resonator or RC
circuit
This integration drastically reduces the number of chips and the amount of wiring and
PCB space that would be needed to produce equivalent systems using separate chips.
Microcontrollers are inside many kinds of electronic equipment (see embedded system).
They are the vast majority of all processor chips sold. Over 50% are "simple"
controllers, and another 20% are more specialized digital signal processors (DSPs)
(ref?). A typical home in a developed country is likely to have only one or two generalpurpose microprocessors but somewhere between one and two dozen microcontrollers.
Page
18
DEPATMENT OF EIE

A typical mid range vehicle has as many as 50 or more microcontrollers. They can also
be found in almost any electrical device: washing machines, microwave ovens,
telephones etc
Table 6.1 Some of the commonly used microcontrollers.
4-bit

Texas Instruments TMS 1000

Microcontrollers

National COP420
Hitachi HMCS40
Toshiba TLCS47

8-bit

Intel 8048

Microcontrollers

Intel 8051
Microchip PIC16C56
National COP820
Motorola 68HC11
Texas Instruments TMS7500
Zilog Z8

16-bit

Motorola MC68332

Microntrollers

Intel MCS-96 Family of Microcontrollers (includes


Page
19

DEPATMENT OF EIE

8096BH, 80C196KB, and 80C196KC)


Motorola 68HC16
National HPC16164
Hitachi H8/532
32-bit

Intel 80960CA, KA, KB, MC

Microcontrollers

LR 33000
AMD Am29050
NS 32000

A microcontroller contains a complete central processing unit (CPU) along with a


full complement of interfacing peripherals. The complete range of binary input/output,
both parallel and serial, and synchronous and asynchronous is available on most of the
microcontrollers. The objective is to make the microcontrollers not primarily message
handlers but to allow effective communication with other similar devices. One of the
important features of a microcontroller is the on-chip analog-to-digital converter (ADC).
For example, the Intel 80C196KC microcontroller has an on-chip ADC that has an 8-bit
as well as a 10-bit conversion mode. The ADC systems have a limited resolution
because they are designed to function in noisy environments where signal-to-noise (S/N)
ratios seldom exceed 256.
Page
20
DEPATMENT OF EIE

Another important feature of a microcontroller is the availability of on-chip


timers. Most microcontrollers have versatile timers that can be configured in real time.
These timers can be reprogrammed as to the duration of time that they will measure, the
type of interrupt that they will generate, and whether they will reload and continue to
time the next time period automatically. A second type of timer called a watchdog timer
is also usually available on-chip. This timer is used to restart the microcontroller if it
fails to be reset at regular intervals. The interval between clearing the watchdog timer is
usually programmable and is chosen to fit the type of application.
Microcontrollers are available with different types and amounts of on-chip
memories. For example, Intel 80C196KB has 8 kilobytes of on-chip EPROM and 232
bytes of on-chip RAM while Intel 80C196KC has 16 kilobytes of EPROM and 488
bytes of on-chip RAM. Only a small amount of on-chip RAM is provided because
microcontrollers usually compute transient quantities; they are not meant to be word
processors.
A functioning microcontroller system requires only external RS232 voltage
converters and a crystal oscillator. However, a microcontroller system used for complex
applications may include external memory.

Page
21
DEPATMENT OF EIE

Basic structure of a microcontroller


Figure shows the block diagram of a typical microcontroller. The four basic parts
of a microcontroller are: central processing unit (CPU), internal memory, registers, and
input/output (I/O) subsytem. These parts are connected internally through a bus.
I/O Subsystem
The I/O subsystem, which consists of units called I/O ports, allows the
microcontroller to communicate with its external environment. Each I/O port has I/O
lines to transfer information between the external devices and the ports. The I/O lines
can be input only, output only, or programmable to be either input or output. Each I/O
port has its own registers. They are data register, control register, and status register. The
information stored in control register determines the I/O port direction and the ability of
a port to cause interrupts. The status register provides information regarding the status of
an input/output device at any time. The data register may be a data input or a data output
register. When an external device is ready to provide an I/O port with new data, such
data are stored in the data input register. When an external device is ready to receive data
from an I/O port, the new data are stored in the data output register.

Central Processing Unit (CPU)


Page
22
DEPATMENT OF EIE

The CPU of a microcontroller consists of arithmetic and logic unit (ALU),


registers and accumulators, and control unit. The ALU performs arithmetic and logic
operations on operands. These operations include addition, subtraction, multiplication,
division, arithmetic bit shifts, ones and twos complement, logical AND, OR, EOR, and
logical bit shifts. The width of the ALU is equal to the basic word length of the
microcontroller system. Registers and accumulators serve as temporary memory
locations during CPU operations. The exchange of information among them takes place
through one or more internal buses. The length of each register is equal to the width of
the internal data bus. Registers are categorized as general-purpose registers and specialpurpose registers. A general-purpose register may be used as an accumulator or as a data
register for (arithmetic) and logic operations. An accumulator is a register for storing the
results of an arithmetic operation. A general-purpose register may also be used as an
address register.
A special-purpose register is dedicated to a specific function. Some of these
registers are the program counter (PC), the instruction register (IR), the address register
(AR), the status register, and the stack pointer (SP). The program counter holds the
address of the next instruction to be executed. When the CPU executes a branch
instruction telling it to branch to another part of the program, the new address is loaded
into the program counter and the sequential order resumes. The instruction register
extracts the operation code (op code) from an instruction. An instruction consists of op
Page
23
DEPATMENT OF EIE

code and operand(s). The contents of the instruction register are decoded by the control
unit. The status register or condition code register consists of status or flag bits and
control bits. The flag bits are: carry/borrow (C), overflow (V), negative (N), zero (Z),
and half-carry (H). The logic states of the flag bits are used by the CPUs branch
instructions to make decisions. The program counter sends its contents (address) to the
address register. The address register then sends this address to the address bus. A stack
is a specially reserved area in memory where information is stored or removed in a lastin-first-out (LIFO) fashion. The stack pointer points to the next free location on the
stack. That is, it holds the address of the top of the stack. Each time data is stored in the
stack, the stack pointer is automatically decremented and each time data is retrieved
from the stack, the stack pointer is automatically incremented.
The control unit comprises the microcontroller instruction decoding, timing, and
control circuitry. The control unit generates internal control signals to activate the ALU
and to open and close the data paths between registers. The control unit also generates
external control signals that are sent either as a response to an interrupt or to activate
transfer of data between memory and input/output (I/O)
Memory
The instructions to be executed by the microcontroller CPU and the data to be
operated on by these instructions are stored in memory. When the CPU accesses the
Page
24
DEPATMENT OF EIE

information stored in memory, it is performing a read operation. When the CPU sends
information to be stored in the memory, it is performing a write operation. Memory is
classified as internal and external memory. Internal memory is on-chip memory and is a
semiconductor type with low capacity and high speeds. External memory is outside the
chip and includes the semiconductor type and serial memory such as magnetic disks,
magnetic tapes, and bubble memory. Semiconductor memory may be volatile or
nonvolatile. Volatile memory loses its contents after the power is removed from the
memory chip. Nonvolatile memory does not lose its contents when power is removed.
The nonvolatile memory can store information permanently or at least semi-permanently
(ten years or more). Volatile memory includes RAM while nonvolatile memory includes
PROM, EPROM, EEPROM, and battery-backed RAM.
RAM (random access memory) comprises DRAM (Dynamic RAM) and SRAM
(Static RAM). Each storage cell of DRAM consists of a capacitor and a MOSFET
(Metal Oxide Semi conductor Field Effect Transistor). If the capacitor is charged, a logic
1 is stored in the cell. If the capacitor has no charge, a logic 0 is stored in the cell. The
charge stored in the capacitors dissipates fast because of leakage. Therefore, a DRAM
has to be periodically refreshed otherwise its contents will fade away after some time
even in the presence of the power to memory chip.

Page
25
DEPATMENT OF EIE

The storage cell of a ROM (Read-only memory) consists of a BJT (Bipolar


Junction Transistor). A ROM may be programmed at the manufacturing stage using a
mask process. Such a ROM is called mask-programmed ROM. The contents of a maskprogrammed ROM cannot be changed once it is programmed.
PROM (Programmable Read Only Memory) can be programmed using a PROM burner.
Once programmed, its contents cannot be changed.
EPROM (Erasable Programmable Read Only Memory) can be programmed using a
PROM burner and can be erased when exposed to ultraviolet light for 30 50 minutes.
EEPROM (Electrically Erasable Programmable Read Only Memory) can be
programmed using a PROM burner and can be erased electrically.

Page
26
DEPATMENT OF EIE

7.MICROCONTROLLER AT89S52

Page
27
DEPATMENT OF EIE

Fig7.1 :Architecture of 89S52

FEATURES:

Compatible with MCS-51 Products.


8K Bytes of In-System Reprogrammable Flash Memory.
Endurance: 1,000 Write/Erase Cycles.
`Fully Static Operation: 0 Hz to 24 MHz.
Three-level Program Memory Lock.
256 x 8-Bit Internal RAM.
32 Programmable I/O Lines.
Three 16-bit Timer/Counters.
Eight Interrupt Sources.
Programmable Serial Channel.
Low Power Idle and Power Down Modes

Page
28
DEPATMENT OF EIE

PIN DIAGRAM AND ITS DESCRIPTION:


The microcontroller generic part number actually includes a whole family of
microcontrollers that have numbers ranging from 8031to 8751 and are available in NChannel Metal Oxide Silicon (NMOS) and Complementary Metal Oxide Silicon
(CMOS) construction in a variety of package types.

PIN DIAGRAM

Page
29
DEPATMENT OF EIE

Fig7.2 : Pin Diagram


With 4Kbytes 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 and pin
out. The on-chip Flash allows the program memory to be reprogrammed in-system or by
a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU
Page
30
DEPATMENT OF EIE

with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which
provides a highly flexible and cost effective solution to many embedded control
applications.
The AT89S52 provides the following standard features: 4 Kbytes of Flash, 256
bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt
architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition,
the AT89S52 is designed with static logic for operation 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.
Port 0:
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 may also be configured to be the multiplexed low order
address/data bus during accesses to external program and data memory. In this mode P0
has internal pull-ups. Port 0 also receives the code bytes during Flash programming, and
outputs the code bytes during program verification. External pull-ups are required during
program verification
Page
31
DEPATMENT OF EIE

Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that
are externally being pulled low will source current (IIL) because of the internal pull-ups.
Port 1 also receives the low-order address bytes during Flash programming and program
verification.
Alternate functions of port 1

Port 2:
Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that
are externally being pulled low will source current (IIL) because of the internal
pullups.Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that use 16-bit addresses (MOVX
Page
32
DEPATMENT OF EIE

A,@DPTR). In this application it uses strong internal pull-ups when emitting 1s. During
accesses to external data memory that uses 8-bit addresses (MOVX A,@RI), Port 2
emits the contents of the P2 Special Function Register. Port 2 also receives the highorder address bits and some control signals during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are
pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (IIL) because of the pullups. Port 3
also serves the functions of various special features of the AT89C52 as listed below:
Alternate functions of port 3

Page
33
DEPATMENT OF EIE

RST:
RST means RESET; 89C52 uses an active high reset pin. It must go high for two
machine cycles. The simple RC circuit used here will supply voltage (Vcc) to reset pin
until capacitance begins to charge. At a threshold of about 2.5V, reset input reaches a
low level and system begin to run.

Fig: Reset Connection

ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during
Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during each access to external Data Memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the
bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
Page
34
DEPATMENT OF EIE

weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN:
Program Store Enable is the read strobe to external program memory. When the
AT89C52 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at OOOOH up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched
on reset. EA should be strapped to Vcc for internal program executions. This pin also
receives the 12-volt programming enable voltage (Vpp) during Flash programming, for
parts that require 12-volt Vpp.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit
XTAL2: Output from the inverting oscillator amplifier.
T2: External count input to Timer/Counter 2, Clock out.
Page
35
DEPATMENT OF EIE

T2EX: Counter 2 capture/reload trigger & direction control.

THE ON-CHIP OSCILLATORS


Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form
an oscillator. The crystal frequency is basic internal clock frequency. The maximum and
minimum frequencies are specified from 1to 24MHZ.
Program instructions may require one, two or four machine cycles to be executed
depending on type of instructions. To calculate the time any particular instructions will
take to be executed, the number of cycles C,
T = C*12d / Crystal frequency
Here, we chose frequency as 11.0592MHZ. This is because,
Baud= 2*clock frequency/(32d. 12d[256d-TH1]).The oscillator is chosen to help
generate both standard and nonstandard baud rates. If standard baud rates are desired, an
11.0592MHZ crystal should be selected. From our desired standard rate, TH1 can be
calculated. The internally implemented value of capacitance is 33 pf.

Page
36
DEPATMENT OF EIE

On-Chip Oscillators

Program Memory Lock Bits:


On the chip there are three lock bits which can be left un programmed (U) or can
be programmed (P) to obtain the additional features .When lock bit 1 is programmed, the
logic level at the EA pin is sampled and latched during reset. If the device is powered up
without a reset, the latch initializes to a random value, and holds that value until reset is
activated. It is necessary that the latched value of EA be in agreement with the current
logic level at that pin in order for the device to function properly.
Program Counter and Data Pointer:
The 89C52 contains two 16-bit registers: the program counters (PC) and the data
pointer (DPTR), Each is used to hold the address of a byte in memory. The PC is the
only register that does not have an internal address. The DPTR is under the control of
Page
37
DEPATMENT OF EIE

program instructions and can be specified by its 16-bit name, DPTR, or by each
individual byte name, DPH and DPL. DPTR does not have a single internal address;
DPH and DPL are each assigned an address.
A & B Registers:
The 89C52 contains 34 general-purpose, working, registers. Two of these,
registers A and B, hold results of many instructions, particularly math and logical
operations, of the 89C52 CPU. The other 32 are arranged as part of internal RAM in
four banks, B0-B3, of eight registers. The A register is also used for all data transfers
between the 89C52 and any external memory. The B register is used for with the A
register for multiplication and division operations.
Flags and the Program Status Word (PSW):
Flags may be conveniently addressed, they are grouped inside the program status
word (PSW) and the power control (PCON) registers.
The 89C52 has four math flags that respond automatically to the outcomes of
math operations and three general-purpose user flags that can be set to 1 or cleared to 0
by the programmer as desired. The math flags include Carry (C), Auxiliary Carry (AC),
Overflow (OV), and Parity (P). User flags are named F0,GF0 and GF1, they are generalpurpose flags that may be used by the programmer to record some event in the program.
Page
38
DEPATMENT OF EIE

SPECIAL FUNCTION REGISTERS:


The 89S52 operations that do not use the internal 128-byte RAM addresses from
00h to 7Fh are done by a group of specific internal registers, each called a Special
Function register, which may be addressed much like internal RAM, using addresses
from 80h to FFH. PC is not part of the SFR and has no internal RAM address

Page
39
DEPATMENT OF EIE

TABLE 7.1

8.CIRCUIT DIAGRAM OF TRANSMITTER


Page
40
DEPATMENT OF EIE

Page
41
DEPATMENT OF EIE

FIG 8.1

CIRCUIT DIAGRAM (RECEIVER)

Page
42
DEPATMENT OF EIE

FIG 8.2

9. 2 Pin Component Humidity Sensor


A 2 pin sensor which is designed to measure relative humidity up to 90%.The
operation of the sensor is simple,the impedance across the two terminals decreases as
humidity increases.Typical applications include air conditioners and purifiers,weather
stations and data loggers.
.

SPECIFICATION:
* Rated Voltage: 1V

Page
43
DEPATMENT OF EIE

* Rated Power: 0.2mW


* Operating Frequency Range: 500Hz to
2,000Hz
* Operating Temperature Range: 0C to
+60C
* Operating Humidity Range: Up to 90% RH
* Humidity Accuracy: 5%

FIG 9.1 HUMIDITY SENSOR

Page
44
DEPATMENT OF EIE

10.SOIL MOISTURE SENSOR CIRCUIT(FIG 10.1)

The circuit designed uses a 5V supply, two copper leads as the sensor probes.
It gives a voltage output corresponding to the conductivity of the soil.

The conductivity of soil depends upon the amount of moisture present in


it. It increases with increase in the water content of the soil.

Functional description of Soil moisture sensor:

Page
45
DEPATMENT OF EIE

The two copper leads act as the sensor probes. They are immersed into the
specimen soil whose moisture content is under test. The soil is examined under three
conditions
Case#1: Dry condition: The probes are placed in the soil under dry conditions
and are inserted up to a fair depth of the soil. As there is no conduction path
between the two copper leads the sensor circuit remains open. The voltage output
of the emitter in this case ranges from 0 to 0.5V.
Case#2: Optimum condition- When water is added to the soil, it percolates
through the successive layers of it and spreads across the layers of soil due to
capillary force. This water increases the moisture content of the soil. This leads to
an increase in its conductivity which forms a conductive path between the two
sensor probes leading to a close path for the current flowing from the supply to
the transistor through the sensor probes. The voltage output of the circuit taken at
the emitter of the transistor in the optimum case ranges from 1.9 to 3.4V
approximately.
Case#3: Excess water condition- With the increase in water content beyond the
optimum level, the conductivity of the soil increases drastically and a steady
conduction path is established between the two sensor leads and the voltage
output from the sensor increases no further beyond a certain limit. The maximum
possible value for it is not more than 4.2V.

11.RELAY:
A relay is an electrically operated switch. Current flowing through the coil of the relay
creates a magnetic field which attracts a lever and changes the switch contacts. The coil
current can be on or off so relays have two switch positions and they are double throw
(changeover) switches.

Page
46
DEPATMENT OF EIE

Relays allow one circuit to switch a second circuit which can be completely separate
from the first. For example a low voltage battery circuit can use a relay to switch a 230V
AC mains circuit. There is no electrical connection inside the relay between the two
circuits, the link is magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but
it can be as much as 100mA for relays designed to operate from lower voltages. Most
ICs (chips) cannot provide this current and a transistor is usually used to amplify the
small IC current to the larger value required for the relay coil. The maximum output
current for the popular 555 timer IC is 200mA so these devices can supply relay coils
directly without amplification.
Relays are usuallly SPDT or DPDT but they can have many more sets of switch
contacts, for example relays with 4 sets of changeover contacts are readily available. For
further information about switch contacts and the terms used to describe them please see
the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to the pins
providing you take care to avoid melting the plastic case of the relay.
The supplier's catalogue should show you the relay's connections. The coil will be
obvious and it may be connected either way round. Relay coils produce brief high
voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the
circuit. To prevent damage you must connect a protection diode across the relay coil.
The animated picture shows a working relay with its coil and switch contacts. You can
see a lever on the left being attracted by magnetism when the coil is switched on. This

Page
47
DEPATMENT OF EIE

lever moves the switch contacts. There is one set of contacts (SPDT) in the foreground
and another behind them, making the relay DPDT.

The relay's switch connections are usually labelled COM, NC and NO:
COM = Common, always connect to this, it is the moving part of the switch.
NC = Normally Closed, COM is connected to this when the relay coil is off.
NO = Normally Open, COM is connected to this when the relay coil is on.
Connect to COM and NO if you want the switched circuit to be on when the
relay coil is on.
Connect to COM and NC if you want the switched circuit to be on when the
relay coil is off.
CLASSIFICAION OF PROTECTIVE RELAYS BASED ON TECHNOLOGY
Protective

relays

can

be

broadly

classified

into

the

following

categories

1.Electromagneticrelays
2.Staticrelays
3.Microprocessor-basedrelays

Electromagnetic relays:
It includes attracted armature, moving coil and induction disc and
induction cup type relays. Electromagnetic relays contain an electromagnet (or
permanent magnet) and a moving part. When the actuating quantity exceeds a certain
Page
48
DEPATMENT OF EIE

predetermined value, an operating torque is developed which is applied on the moving


part. This causes the moving part to travel and to finally close a contact to energize the
tripcoilofthebrezaker.
Staticrelays:Static relays contains electronic circuits which may contain
transistors, ICs, diodes and other electronic components. There is a comparator circuit in
the relay, which compares two or more voltages and gives an output, which is applied to
either a slave ready or a thyristor circuit. The slave ready is an electromagnetic relay
which finally ;closes the contact. A static relay containing a slave ready is semi-static
relay. A relay kising thyristor circuit is a wholly static relay. Static relay possess the
advantage of having ilow burden on CT and PT, fast operation, absence of mechanical
inertia and contact trouble, long life and less maintenance. Static relays have proved to
be superior to electromagnetic relays and they are being used for the protection of
important lines, power stations and substations. Yet they have not completely replaced
electromagnetic relays. Static relays are treated as an addition to family of relays.
Electromagnetic relays continue to be in use because of their simplicity and low cost.
Their maintenance can be done by less qualified personal, where as the maintenance and
repair

of

static

relays

requires

personnel's

trained

in

solid-state

Microprocessor-basedprotectiverelays;Microprocessor-based protective relays are the latest


development in this area. With the development in VLSI Technology, Sophisticated and
fast microprocessor are coming up. Their applications to the problems of protective
relaying schemes are of current interests to power engineers. The inherit advantages of
microprocessor-based relays over static relays with or a very limited range of
applications, are attractive, flexibility due to their programmable approach.
Page
49
DEPATMENT OF EIE

Microprocessor-based protective relays can provide protection at low cost and compete
with conventional relays. The present downward trend in the cost of large-scale
integrated circuit will encourage wide applications of microprocessor-based applications
of microprocessor-based relays for the protection modem complex power network.

Fig 11.1(RELAY CIRCUIT)

Advantages of relays:
Page
50
DEPATMENT OF EIE

Relays can switch AC and DC, transistors can only switch DC.
Relays can switch high voltages, transistors cannot.
Relays are a better choice for switching large currents (> 5A).
Relays can switch many contacts at once.
Disadvantages of relays:
Relays are bulkier than transistors for switching small currents.
Relays cannot switch rapidly (except reed relays), transistors can switch many
times per second.
Relays use more power due to the current flowing through their coil.
Relays require more current than many ICs can provide, so a low power
transistor may be needed to switch the current for the relay's coil.

12.ADC 0804

Features
Compatible with 8080 Microprocessors
Easy interface to all microprocessors, or operates 'stand alone'

Page
51
DEPATMENT OF EIE

Differential analog voltage inputs


Logic inputs and outputs meet both MOS and TTL voltage level specifications
Works with 2.5V (LM336) Voltage Reference
On-chip clock generator
0V to 5V analog input voltage range with single 5V supply
No zero adjust required
Operates ratiometrically or with 5 Vdc, 2.5Vdc, or analog span adjusted voltage reference

Pin Description

Pin Layout

Pin Number

Description

CS - Chip Select (Active Low)

RD - Read (Active Low)

WR - Write (Active Low)

CLK IN - Clock IN

INTR - Interrupt (Active Low)

Vin+ - Analog Voltage Input

Vin- - Analog Voltage Input

AGND - Analog Ground

Vref/2 - Voltage Reference / 2

10

DGND - Digital Ground

11

DB7 - Data Bit 7 (MSB)

12

DB6 - Data Bit 6

13

DB5 - Data Bit 5

14

DB4 - Data Bit 4

15

DB3 - Data Bit 3

16

DB2 - Data Bit 2

17

DB1 - Data Bit 1

18

DB0 - Data Bit 0 (LSB)

19

CLKR - Clock Reset

20

Vcc - Positive Supply or Vref

TABLE 12.1
Page
52
DEPATMENT OF EIE

FIG 12.1

FIG 12.2-ADC 0804


13.MAX232
The MAX232 IC is used to convert the TTL/CMOS logic levels to RS232 logic levels during
serial communication of microcontrollers with PC. The controller operates at TTL logic
level (0-5V) whereas the serial communication in PC works on RS232 standards (-25 V to
+ 25V). This makes it difficult to establish a direct link between them to communicate
with each other.
The intermediate link is provided through MAX232. It is a dual driver/receiver that
includes a capacitive voltage generator to supply RS232 voltage levels from a single 5V
supply. Each receiver converts RS232 inputs to 5V TTL/CMOS levels. These receivers (R 1 &
R2) can accept 30V inputs. The drivers (T 1 & T2), also called transmitters, convert the
TTL/CMOS input level into RS232 level.
Page
53
DEPATMENT OF EIE

The transmitters take input from controllers serial transmission pin and send the output
to RS232s receiver. The receivers, on the other hand, take input from transmission pin of
RS232 serial port and give serial output to microcontrollers receiver pin. MAX232 needs
four external capacitors whose value ranges from 1F to 22F.

Microcontroller

MAX232

RS232

Tx

T1/2 In

T1/2 Out

Rx

Rx

R1/2 Out

R1/2 In

Tx

Pin Diagram:

FIG 13.1
Pin Description:
Pin

Function

Name
Page
54

DEPATMENT OF EIE

No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Capacitor connection pins

Output pin; outputs the serially transmitted data at RS232


logic level; connected to receiver pin of PC serial port
Input pin; receives serially transmitted data at RS 232
logic level; connected to transmitter pin of PC serial port
Output pin; outputs the serially transmitted data at TTL
logic level; connected to receiver pin of controller.
Input pins; receive the serial data at TTL logic level;
connected to serial transmitter pin of controller.
Output pin; outputs the serially transmitted data at TTL
logic level; connected to receiver pin of controller.
Input pin; receives serially transmitted data at RS 232
logic level; connected to transmitter pin of PC serial port
Output pin; outputs the serially transmitted data at RS232
logic level; connected to receiver pin of PC serial port
Ground (0V)
Supply voltage; 5V (4.5V 5.5V)

TABLE 13.1

Page
55
DEPATMENT OF EIE

Capacitor
Capacitor
Capacitor
Capacitor
Capacitor
Capacitor
T2 Out
R2 In
R2 Out
T2 In
T1 In
R1 Out
R1 In
T1 Out
Ground
Vcc

1
3
1
2
2
4

+
+
+
-

FIG 13.2

14.INTERFACING LCD TO THE MICROCONTROLLER

This is the first interfacing example for the parallel port. We will star with something
simple. This example does not use the Bi-directional feature found on newer ports, thus it should work
with most, if no all Parallel Ports. It however does not show the use of the status port as an input. So
what are we interfacing? A 16 Character X 2 Line LCD Module to the parallel port. These LCD
Modules are very common these days, and are quite simple to work with, as all the logic required
running them is on board.

Features:
Interface with either 4-bit or 8-bit microprocessor.
Page
56
DEPATMENT OF EIE

Display data RAM


8 bits (80 characters).80
Character generator ROM
7 dot-matrix character patterns.160 different 5
Character generator RAM
7 dot-matrix patterns.8 different users programmed 5
Display data RAM and character generator RAM may be
Accessed by the microprocessor.
Numerous instructions
Clear Display, Cursor Home, Display ON/OFF, Cursor
ON/OFF, Blink Character, Cursor Shift, Display Shift.
Built-in reset circuit is triggered at power ON.

A general purpose alphanumeric LCD, with two lines of 16 characters.

FIG 14.1

Page
57
DEPATMENT OF EIE

Pin diagram:(FIG-14.2)

Page
58
DEPATMENT OF EIE

TABLE 14.1
In the above table Vcc and Vss are supply pins and VEE (Pin no.3) is used for controlling LCD
contrast. Pin No.4 is Rs pin for selecting the register, there are two very important registers are there
in side the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction command
code register is selected, allowing the user to send data to be displayed on the LCD. R/W is a read or
writes Pin, which allows the user to write information to the LCD or read information from it. R/W=1
when reading R/W=0 when writing. The LCD to latch information presented to its data pins uses the
enable (E) pin. The 8-bit data pins, D0-D7, are used to send information to the LCD or read the
contents of the LCDs internal registers. To display letters and numbers, we must send ASCII codes for
the letters A-Z, and number 0 -9 to these pins while making RS=1.

ABSOLUTE MAXIMUM RATINGS:


1. ELECTRICAL ABSOLUTE MAXIMUM RATINGS:

Page
59
DEPATMENT OF EIE

Quality control:
Some LCD panels have defective transistors, causing permanently lit or unlit pixels
which are commonly referred to as stuck pixels or dead pixels respectively. Unlike integrated circuits
(ICs), LCD panels with a few defective pixels are usually still usable. It is also economically prohibitive
to discard a panel with just a few defective pixels because LCD panels are much larger than ICs.

Color displays:
In color LCDs each individual pixel is divided into three cells, or sub pixels, which are
colored red, green, and blue, respectively, by additional filters (pigment filters, dye filters and metal
oxide filters). Each sub pixel can be controlled independently to yield thousands or millions of possible
colors for each pixel. CRT monitors employ a similar 'sub pixel' structures via phosphors, although the
analog electron beam employed in CRTs do not hit exact 'sub pixels'.
Color components may be arrayed in various pixel geometries, depending on the
monitor's usage. If software knows which type of geometry is being used in a given LCD, this can be
used to increase the apparent resolution of the monitor through sub pixel rendering. This technique is
especially useful for text anti-aliasing.
To reduce smudging in a moving picture when pixels do not respond quickly enough to
color changes, so-called pixel overdrive may be used.

Page
60
DEPATMENT OF EIE

15. COMPONENT DESCRIPTION


TRANSISTOR: A transistor consists of two junctions formed by sandwiching either p-type or ntype semiconductor between a pair of opposite types. Accordingly, there are two types of
transistors namely: -

(1) n-p-n transistor

(2) p-n-p transistor

(NPN)

(PNP)

An n-p-n transistor is composed of two n-type semiconductors separated by a thin


section of p type. However a p-n-p transistor is formed by two p sections separated by a
thin section of n-type. In each type of transistor the following points may be noted.

1.

There are two p-n junctions, therefore a transistor may be regarded as


combination of two diodes connected back to back.

2.

There are three terminals taken from each type of semiconductor.


Page
61

DEPATMENT OF EIE

3.

The middle section is a very thin layer, which is the most important factor in the
functioning of a transistor.

4.

Transistor can be used as an Amplifier also.


A transistor raises the strength of a weak signal and thus acts as an amplifier. The

weak signal is applied between emitter base junction and output is taken across the load
Rc connected in the collector circuit (in common emitter configuration). In order to
achieve faithful amplification, the input circuit should always remain forward biased. To
do so, a dc voltage is applied in the input in addition to the signal. This dc Voltage is
known as biasing voltage and its magnitude and polarity should be such that it always
keeps the input circuit forward biased regardless of the polarity to the signal to be
amplified.
As the input circuit has low resistance a small change in signal voltage causes an
appreciable change in emitter current. This causes change in collector current (by a
factor called current gain of transistor) due to transistor action. The collector current
flowing through a high load resistance Rc produces a large voltage across it. Thus a
weak signal applied to the input circuit appears in the amplified form in the collector
circuit. This is how a transistor acts as an amplifier.
Transistor may be used in different configuration like CB (common base) & CC
(common collector) according to requirements of amplifier (impedance matching, buffer
amplifier etc.).
TRANSFORMER
Definition: The transformer is a static electro-magnetic device that transforms one alternating
voltage (current) into another voltage (current). However, power remains the some
Page
62
DEPATMENT OF EIE

during the transformation. Transformers play a major role in the transmission and
distribution of ac power.
Principle: Transformer works on the principle of mutual induction. A transformer consists of
laminated magnetic core forming the magnetic frame. Primary and secondary coils are
wound upon the two cores of the magnetic frame, linked by the common magnetic flux.
When an alternating voltage is applied across the primary coil, a current flows in the
primary coil producing magnetic flux in the transformer core. This flux induces voltage
in secondary coil.
Transformers are classified as: (a)

(b)

(a)

Based on position of the windings with respect to core i.e.


(1)

Core type transformer

(2)

Shell type transformer

Transformation ratio:
(1)

Step up transformer

(2)

Step down transformer

Core & shell types: Transformer is simplest electrical machine, which consists of
windings on the laminated magnetic core. There are two possibilities of putting
up the windings on the core.

(1)

Winding encircle the core in the case of core type transformer

(2)

Cores encircle the windings on shell type transformer.


Page
63

DEPATMENT OF EIE

(b)

Step up and Step down: In these Voltage transformation takes place according to
whether the
Primary is high voltage coil or a low voltage coil.

(1)

Lower to higher-> Step up

(2)

Higher to lower-> Step down

Page
64
DEPATMENT OF EIE

15.P.C.B. MANUFACTURING PROCESS


It is an important process in the fabrication of electronic equipment. The design of PCBs
(Printed Circuit Boards) depends on circuit requirements like noise immunity, working
frequency and voltage levels etc. High power PCBs require a special design strategy.
The fabrication process to the printed circuit board will determine to a large extent
the price and reliability of the equipment. A common target aimed is the fabrication of
small series of highly reliable professional quality PCBs with low investment. The target
becomes especially important for customer tailored equipments in the area of industrial
electronics.
The layout of a PCB has to incorporate all the information of the board before one can
go on the artwork preparation. This means that a concept which clearly defines all the
details of the circuit and partly defines the final equipment, is prerequisite before the
actual lay out can start. The detailed circuit diagram is very important for the layout
designer but he must also be familiar with the design concept and with the philosophy
behind the equipment.
BOARD TYPES:
The two most popular PCB types are:
Single Sided Boards
The single sided PCBs are mostly used in entertainment electronics where
manufacturing costs have to be kept at a minimum. However in industrial electronics
cost factors cannot be neglected and single sided boards should be used wherever a
particular circuit can be accommodated on such boards.
Double Sided Boards
Page
65
DEPATMENT OF EIE

Double-sided PCBs can be made with or without plated through holes. The production
of boards with plated through holes is fairly expensive. Therefore plated through hole
boards are only chosen where the circuit complexities and density of components does
not leave any other choice.
DESIGN SPECIFICATION
STEPS TAKEN WHILE PREPARING CIRCUIT
(A)

PCB DESIGNING
The main purpose of printed circuit is in the routing of electric currents and signal

through a thin copper layer that is bounded firmly to an insulating base material
sometimes called the substrate. This base is manufactured with an integrally bounded
layers of thin copper foil which has to be partly etched or removed to arrive at a predesigned pattern to suit the circuit connections or other applications as required.
The term printed circuit board is derived from the original method where a printed
pattern is used as the mask over wanted areas of copper. The PCB provides an ideal
baseboard upon which to assemble and hold firmly most of the small components.
From the constructors point of view, the main attraction of using PCB is its role as the
mechanical support for small components. There is less need for complicated and time
consuming metal work of chassis contraception except perhaps in providing the final
enclosure. Most straight forward circuit designs can be easily converted in to printed
wiring layer the thought required to carry out the inversion cab footed high light an
possible error that would otherwise be missed in conventional point to point wiring .The
finished project is usually neater and truly a work of art.
Actual size PCB layout for the circuit shown is drawn on the copper board. The board is
then immersed in FeCl3 solution for 12 hours. In this process only the exposed copper
portion is etched out by the solution.
Page
66
DEPATMENT OF EIE

Now the petrol washes out the paint and the copper layout on PCB is rubbed with a
smooth sand paper slowly and lightly such that only the oxide layers over the Cu are
removed. Now the holes are drilled at the respective places according to component
layout as shown in figure.
(B) LAYOUT DESIGN:
When designing the layout one should observe the minimum size (component body
length and weight). Before starting to design the layout we need all the required
components in hand so that an accurate assessment of space can be made. Other space
considerations might also be included from case to case of mounted components over
the printed circuit board or to access path of present components.
It might be necessary to turn some components around to a different angular position so
that terminals are closer to the connections of the components. The scale can be checked
by positioning the components on the squared paper. If any connection crosses, then one
can reroute to avoid such condition.

All common or earth lines should ideally be connected to a common line routed around
the perimeter of the layout. This will act as the ground plane. If possible try to route the
outer supply line to the ground plane. If possible try to route the other supply lines
around the opposite edge of the layout through the center. The first set is tearing the
circuit to eliminate the crossover without altering the circuit detail in any way.
Plan the layout looking at the topside to this board. First this should be translated
inversely, later for the etching pattern large areas are recommended to maintain good
copper adhesion. It is important to bear in mind always that copper track width must be
according to the recommended minimum dimensions and allowance must be made for
Page
67
DEPATMENT OF EIE

increased width where termination holes are needed. From this aspect, it can become
little tricky to negotiate the route to connect small transistors.

There are basically two ways of copper interconnection patterns under side the
board. The first is the removal of only the amount of copper necessary to isolate the
junctions of the components to oneanother. The second is to make the interconnection
pattern looking more like conventional point wiring by routing uniform width of copper
from component to component.
(C)ETCHING PROCESS:
Etching process requires the use of chemicals. acid resistant dishes and running water
supply. Ferric chloride is mostly used solution but other etching materials such as
ammonium per sulphate can be used. Nitric acid can be used but in general it is not used
due to poisonous fumes.

The pattern prepared is glued to the copper surface of the board using a latex type
of adhesive that can be cubed after use. The pattern is laid firmly on the copper using a
very sharp knife to cut round the pattern carefully to remove the paper corresponding to
the required copper pattern areas. Then apply the resistant solution, which can be a kind
of ink solution for the purpose of maintaining smooth clean outlines as far as possible.
While the board is drying, test all the components.
(D) COMPONENT ASSEMBLY: -

Page
68
DEPATMENT OF EIE

From the greatest variety of electronic components available, which runs into thousands
of different types it is often a perplexing task to know which is right for a given job.
There could be damage such as hairline crack on PCB. If there are, then they can be
repaired by soldering a short link of bare copper wire over the affected part.
The most popular method of holding all the items is to bring the wires far apart after
they have been inserted in the appropriate holes. This will hold the component in
position ready for soldering.
Some components will be considerably larger .So it is best to start mounting the smallest
first and progressing through to the largest. Before starting, be certain that no further
drilling is likely to be necessary because access may be impossible later.

Next will probably be the resistor, small signal diodes or other similar size
components. Some capacitors are also very small but it would be best to fit these
afterwards. When fitting each group of components mark off each one on the circuit as it
is fitted so that if we have to leave the job we know where to recommence.
Although transistors and integrated circuits are small items there are good reasons for
leaving the soldering of these until the last step. The main point is that these components
are very sensitive to heat and if subjected to prolonged application of the soldering iron,
they could be internally damaged.
All the components before mounting are rubbed with sand paper so that oxide layer is
removed from the tips. Now they are mounted according to the component layout.

Page
69
DEPATMENT OF EIE

(E) SOLDERING: This is the operation of joining the components with PCB after this operation the circuit
will be ready to use to avoid any damage or fault during this operation following care
must be taken.
1. A longer duration contact between soldering iron bit & components lead can exceed
the temperature rating of device & cause partial or total damage of the device. Hence
before soldering we must carefully read the maximum soldering temperature &
soldering time for device.
2. The wattage of soldering iron should be selected as minimum as permissible for that
soldering place.
3. To protect the devices by leakage current of iron its bit should be earthed properly.
4.We should select the soldering wire with proper ratio of Pb & Tn to provide the
suitable melting temperature.
5.Proper amount of good quality flux must be applied on the soldering point to avoid dry
soldering.

Page
70
DEPATMENT OF EIE

17.Basic Concept-KEIL
Introduction
This tutorial will assist you in writing your first 8051 Assembly language program using
the popular Keil
Compiler. Keil offers an evaluation package that will allow the assembly and debugging
of files 2K or less. This
package is freely available at their web site. Keils website address is www.keil.com.
The sample program included in the tutorial toggles Ports 1 and 2 on the 8051. The
compiled program
has been tested using the 8051 board from MicroDigitalEd.com. The program also
works with other systems that
have Port 1 and 2 available.

Basic Keil Tutorial


1. Open Keil from the Start menu
2. The Figure below shows the basic names of the windows referred in this document

Page
71
DEPATMENT OF EIE

Starting a new Assembler Project


1. Select New Project from the Project Menu.

Page
72
DEPATMENT OF EIE

2. Name the project Toggle.a51

3. Click on the Save Button.

4. The device window will be displayed.


5. Select the part you will be using to test with.

Page
73
DEPATMENT OF EIE

6. Double Click on the Dallas Semiconductor.


Page
74
DEPATMENT OF EIE

7. Scroll down and select the DS89C420 Part


8. Click OK

Creating Source File


1. Click File Menu and select New.

Page
75
DEPATMENT OF EIE

2. A new window will open up in the Keil IDE.

Page
76
DEPATMENT OF EIE

3. Copy the example to the Right into the new window. This file will toggle Ports 1 and
2 with a delay.
4. Click on File menu and select Save As

ORG 0H
MOV A, #55H
AGAIN:
MOV P1, A
MOV P2, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY:
MOV R3, #200
OUTER: MOV R2, #0255
INNER: DJNZ R2, INNER
DJNZ R3, OUTER
RET
END

Page
77
DEPATMENT OF EIE

5. Name the file Toggle.a51


6. Click the Save Button

Adding File to the Project


1. Expand Target 1 in the Tree Menu

Page
78
DEPATMENT OF EIE

2. Click on Project and select Targets, Groups, Files

Page
79
DEPATMENT OF EIE

3. Click on Groups/Add Files tab


4. Under Available Groups select Source Group 1
5. Click Add Files to Group button

6. Change file type to Asm Source file(*.a*;


*.src)
7. Click on toggle.a51
8. Click Add button
9. Click Close Button
10. Click OK button when you return to Target, Groups, Files dialog box

Page
80
DEPATMENT OF EIE

11. Expand the Source Group 1 in the Tree menu to ensure that the file
was added to the project.

Creating HEX for the Part


1. Click on Target 1 in Tree menu

Page
81
DEPATMENT OF EIE

2. Click on Project Menu and select Options for Target 1


3. Select Target Tab

4. Change Xtal (Mhz) from 50.0 to 11.0592


5. Select Output Tab
6. Click on Create Hex File check box
7. Click OK Button

Page
82
DEPATMENT OF EIE

8. Click on Project Menu and select Rebuild all Target Files


9. In the Build Window it should report 0 Errors (s), 0 Warnings
10. You are now ready to Program your Part

Page
83
DEPATMENT OF EIE

Testing Program in Debugger


1. Comment out line ACALL DELAY by placing a Semicolon
at the beginning. This will allow you to see the port change immediately.
2. Click on the File Menu and select Save

Page
84
DEPATMENT OF EIE

3. Click on Project Menu and select Rebuild all Target Files


4. In the Build Window it should report 0 Errors (s), 0 Warnings

Page
85
DEPATMENT OF EIE

5.

Click on Debug Menu and Select Start/Stop Debug Session

Page
86
DEPATMENT OF EIE

Running the Keil Debugger


1. The Keil Debugger should be now be Running.

Page
87
DEPATMENT OF EIE

2. Click on Peripherals. Select I/O Ports, Select Port 1

3. A new window should port will pop up. This represent the Port and Pins

Page
88
DEPATMENT OF EIE

4. Step through the code by pressing F11 on the Keyboard. The Parallel Port 1 Box
should change you completely step through the code

6.

To exit out, Click on Debug Menu and Select Start/Stop Debug Session

18.ZIGBEE MODULE

Features and Benefits:


Point to point, point to multi point, Mesh and peer-to-peer topologies on proprietary stack.
Direct Sequence Spread Spectrum technology.
Each direct sequence channel has 64K unique network addresses
Transmit Power: 22 dBm.
RF data rate: 250 kbps.
Acknowledgement mode communication with retries.
Power saving modes.
Source / destination addressing.

Page
89
DEPATMENT OF EIE

Unicast and broadcast communication.


Analog to digital conversion and digital I/O line support.
Default configuration for ready to use.

Specifications:
Supply Voltage
Transmit Current
Idle/Receive Current
Power-down Current

Power
3.3 to 3.6V
155mA at 20dBm
70Ma
<10 A

Rating Frequency
Maximum Transmit Power Output
RF Data rate
Receiver Sensitivity
Serial Interface Data Rate
Operating Temperature
Antenna Options
Antenna Connector

General
ISM 2.4 - 2.4835GHz
166mA at 22dBm
250 kbps
-103 dBm
Upto 115200 configurable
-40 to 85 C
Chip Antenna, Wire Antenna
MMCX

Number Of channels
Addressing Options

Network
Point-to-point, point-to-multipoint &
Mesh
16 direct sequence channels
PAN ID, Channel and addresses

Dimensions

Mechanical
38mm x 26mm.

Interface Connector

20 pin receptacles, 2.00mm pitch.

Supported Network Topologies

TABLE 18.1

Page
90
DEPATMENT OF EIE

Fig 18.1
19.CODING
TRANSMITTER :
#include<reg51.h>
sbit rd=P3^5;
sbit wr=P3^4;
sbit intr=P3^3;
sbit rs=P3^7;
sbit e=P3^6;
sbit watersensor=P2^0;
sbit motor=P0^1;

//connect

pull up 10k

unsigned convert(unsigned int);


void delay(unsigned int t)
{
Page
91
DEPATMENT OF EIE

unsigned int i,j;


for(i=0;i<t;i++)
for(j=0;j<1275;j++);
}
void sertx(unsigned char tx)
{
SBUF=tx;
while(TI == 0);
TI=0;
}
void main()
{
unsigned int a;
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
P1=0xFF;
P0=0x00;
P2=0x00;
intr=1;
rd=1;
Page
92
DEPATMENT OF EIE

wr=1;
while(1)
{
wr=0;
wr=1;
while(intr==1);
rd=0;
a=P1;
convert(a);
rd=1;
if(watersensor == 1)
{
motor=0;
sertx('o');
sertx('f');
sertx('f ');
sertx('w');
sertx('e');
sertx(' t);

Page
93
DEPATMENT OF EIE

}
if(watersensor == 0)
{
motor=1;
sertx('o');
sertx('n');
sertx(' );
sertx('d');
sertx('r');
sertx(' y);

}
delay(100);
}
}
unsigned convert(unsigned int value)
{
unsigned char a,b,c,d;
a=value/100;
b=value%100;
c=b/10;
Page
94
DEPATMENT OF EIE

d=b%10;
a=a|0x30;
c=c|0x30;
d=d|0x30;
sertx('*');
sertx(a);
sertx(c);
sertx(d);
}
RECEIVER:
#include<reg51.h>
sbit rs=P3^7;
sbit e=P3^6;
unsigned convert(unsigned int);
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<1275;j++);
}
void lcd_cmd(unsigned char p)
{
Page
95
DEPATMENT OF EIE

P2=p;
rs=0;
e=1;
delay(5);
e=0;
}
void lcd_dat(unsigned char p)
{
P2=p;
rs=1;
e=1;
delay(5);
e=0;
}
void sertx(unsigned char tx)
{
SBUF=tx;
while(TI == 0);
TI=0;
}
unsigned char receive()
{
Page
96
DEPATMENT OF EIE

unsigned char rx;


while(RI == 0);
rx=SBUF;
RI=0;
return rx;
}
void main()
{
unsigned char a=0,a1,a2,a3,a4,a5;
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
lcd_cmd(0x38);
lcd_cmd(0x0E);
lcd_cmd(0x06);
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_dat('H');
lcd_dat('u');
lcd_dat('m');
lcd_dat('t');
Page
97
DEPATMENT OF EIE

lcd_dat(':');
lcd_cmd(0x89);
lcd_dat('s');
lcd_dat('o');
lcd_dat('i');
lcd_dat('l');
lcd_dat(':');

lcd_cmd(0xc0);
lcd_dat('M');
lcd_dat('t');
lcd_dat('r');
lcd_dat(' ');
lcd_dat(':');
while(1)
{
do
{
a=receive();
}
while(a != '*');
a=receive();
Page
98
DEPATMENT OF EIE

a1=receive();
a2=receive();
a3=receive();
a4=receive();
a5=receive();
lcd_cmd(0x85);
lcd_dat(a);
lcd_dat(a1);
lcd_dat(a2);
lcd_cmd(0xc5);
lcd_dat(a3);
lcd_dat(a4);
lcd_dat(a5);
}
}

Page
99
DEPATMENT OF EIE

SCOPE FOR FURTHER DEVELOPMENT


1) The performance of the system can be further improved in terms of the operating
speed, memory capacity, instruction cycle period of the microcontroller.The number
of channels can be increased to interface more number of sensors which is possible
by using advanced versions of
microcontrollers.
2) The system can be modified with the use of a datalogger and a graphical LCD
panel showing the measured sensor data over a period of time.
3) This system can be connected to communication devices such as modems, cellular
phones or satellite terminal to enable the remote collection of recorded data or
alarming of certain parameters.
4) The device can be made to perform better by providing the power supply with the
help of battery source which can be rechargeable or non-rechargeable, to reduce the
requirement of main AC power.
Page
100
DEPATMENT OF EIE

5) Time bound administration of fertilizers, insecticides and pesticides can be


introduced.
6) A multi-controller system can be developed that will enable a master
controller along with its slave controllers to automate multiple greenhouses
simultaneously.

CONCLUSION
A
system

step-by-step

approach

in

designing

the

microcontroller

based

for measurement and control of the four essential parameters for plant

growth, i.e. temperature, humidity, soil moisture, and light intensity, has been
followed. The results obtained from the measurement have shown that the system
performance is quite reliable and accurate.
The system has successfully overcome quite a few shortcomings of the
existing systems by reducing the power consumption, maintenance and complexity, at
the same time providing a flexible and precise form of maintaining the environment.
The continuously decreasing costs of hardware and software, the wider
acceptance of electronic systems in agriculture, and an emerging agricultural control
Page
101
DEPATMENT OF EIE

system industry in several areas of agricultural production, will result in reliable


control

systems

that

will address several aspects of quality and quantity of

production. Further improvements will be made as less expensive and more reliable
sensors are developed for use in agricultural production.
Although the enhancements mentioned in the previous chapter may seem far in
the future, the required technology and components are available, many such systems
have been independently developed, or are at least tested at a prototype level. Also,
integration of all
these technologies is not a daunting task and can be successfully carried out.

REFERENCES
[1] Dr. R. Jayanthi, Prof. of Horticulture, UAS, GKVK, Bangalore.

IEEE Papers:
[1] Stipanicev D., Marasovic J., Networked embedded greenhouse monitoring and
control,
Proceedings of 2003 IEEE Conference on Control Applications, June 2003.
[2] Turnell, D.J. de Fatima, Q.V., Turnell, M., Deep, G.S., Freire, R.C.S.,
FarmWeb-an integrated, modular farm automation system, Proceedings of
Page
102
DEPATMENT OF EIE

IEEE International Conference on Systems, Man, and Cybernetics, Vol. 2,


Oct. 1998.
Books:
[1] Rebecca Tyson Northen, Orchids As House Plants, Dover Publications, New
York, 2nd
Edition, 1985.
[2] Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. Mc Kinlay , The 8051
Microcontroller & Embedded Systems, Pearson Education Inc. 2nd Edition, 2008.
[3] Myke Predko, Programming and Customising the 8051 Microcontroller, TMH,
1999.
[4] Kenneth J Ayala, The 8051 Microcontroller Architecture, Programming &
Applications,
Penram International, 2nd Edition, 1996.
[5] Ramakant Gayakwad, Operational Amplifiers Linear Integrated Circuits, Prentice
Hall of
India, 3rd Edition.
[6] National Semiconductors, CMOS Logic Databook
[7] SENSORS- The Journal of Applied Sensing Technology, Advanstar
Communications Inc

Web Resources
[1]

http://freewebs.com/maheshwankede

[2]

http://www.faludi.com

[3]

http://www.electro-tech-online.com

[4]

http://www.8052.com

[5]

http://www.8051projects.net/forum

[6]

http://www.datasheetdirect.com
Page
103

DEPATMENT OF EIE

[7]

http://www.keil.com/appnotes

[8]

http://www.google.com

Page
104
DEPATMENT OF EIE

You might also like