Académique Documents
Professionnel Documents
Culture Documents
Greenhouse
CONTENTS
1. INTRODUCTION………………………………………
2. SYSTEM REQUIREMENTS……………………………
3. HARDWARE IMPLEMENTATION……………………
3.1 BLOCK DIAGRAM
3.2 CIRCUIT DIAGRAM
4. SYSTEM SPECIFICATION……………………………
4.1 MICROCONTROLLER AT89C51
4.2ADC
4.3 555 TIMER
4.4 LM35 TEMPERATURE SENSOR
4.5 LCD 16*2
4.6 LDR SENSOR
4.7 HUMIDITY SENSOR
4.8 ULN WITH RELAY
4.9 KIEL TOOL WITH EMBEDDED C
5. SYSTEM WORKING………….…………….…………
5.1 WORKING
5.2 FLOW CHART
FUTURE ENHANCEMENTS……………………………
LIMITATIONS …………………………………….………
CONCLUSION……………………………………….……
BIBLIOGRAPHY………….………………………….…..
APPENDIX……………………………………………………….
CHAPTER 1
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.
CHAPTER 2
SYSTEM REQUIREMENTS
2.2.4 LCD:
We are using Hitachi LCD with dot matrix type which supports 16x2= 32
characters.
2.2.5 LM35
. The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35
thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the
user is not required to subtract a large constant voltage from its output to obtain
convenient Centigrade scaling.
CHAPTER 3
HARDWARE IMPLEMENTATION
3.1 BLOCK DIAGRAM
3.2 CIRCUIT DIAGRAM
Vcc vss
15 16 7
P1.0
LCD
Microcontroller
1 2 3 4 5 6 14
P1.7
P2.0
P2.1
P2.2
LCD PINS
1. ground
2. supply(5 volt)
3. pot(contrast)
4. RS
5. R/W
6. E
7. DB0
8. DB1
9. DB2
10. DB3
11. DB4
12. DB5
13. DB6
Dept. of Electrical & Electronics Engg.
CEC Page 9
Auto Controlled Irrigation Unit In
Greenhouse
14. DB7
15. LCD-( Backlight)
16. LCD+(Backlight)
5v
ADC
LM35
17 26
14 27
Microcontroller 15
8 Gnd
P0.0 18
P0.1 19 HUMIDITY
P0.2 20
P0.3 21
P0.4 28
P0.5 25(A0) LDR
P0.6 24(A1)
P0.7 23(A2)
22(ALE)
P2.7 9(OE) 5v
P2.6
P2.5 6(START)
P2.4 7(EOC)
P2.3
11
P3.7 12
P3.6
13
16
Vcc
10 MF 10
Gnd Clock
8
R1 18k
7 4
R2 10k
6 555 timer 3
2
C 1nF
3.2.4 555 TIMER AS A CLOCK SOURCE
5 1
0.01MF
ULN 2003
1 16 Relay1
2 15
Microcontroller
3 14
8 Relay3
P2.3
P2.4
P2.5
12V
CHAPTER 4
SYSTEM SPECIFICATION
4.1 MICROCONTROLLER-ATMEL89C51
4.1.1General description:
This device is a Single-Chip 8-Bit Microcontroller manufactured in an
advanced CMOS process and is a derivative of the 8051 microcontroller family. The
instruction set is 100% compatible with the 8051 instruction set.
Port 0:
Port 0 is an 8-bit open drain bi-directional 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 high-
impedance inputs.
Port 0 can also be configured to be the multiplexed low-order address/data bus during
accesses to external programmed 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.
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 wilt source current (IIL) because of the internal pull-ups. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. 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 pull-ups. Port 2
emits the high-order address byte during fetches from external program memory and during
accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this
application, Port 2 uses strong internal pull-ups when emitting 1s. During
accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the
contents of the P2 Special Function Register.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. 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 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 AT89C51.
Port 3 also receives some control signals for Flash programming and programming
verification. RST Reset input. A high on this pin for two machine cycles while the oscillator
is running resets the device.
ALE/PROG:
Address Latch Enable is an 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 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: A must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H 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 when 12-volt programming is
selected.
XTAL1:
Input to the inverting oscillator amplifier and input to the Internal clock operating
circuit.
XTAL2:
Output from the inverting oscillator amplifier.
The heart of the 89C52 is the circuitry that generates the clock pulses. Pins XTAL1
and XTAL2 are provided for connecting a resonant network to form an oscillator. Typically,
a quartz crystal and capacitors are employed as shown in figure. The crystal frequency is the
basic internal clock frequency of the micro controller.
To calculate the time ‘Tinst’ any particular instruction will take to be executed, find
the number of cycles ‘C’,
T inst = (C*12d)/(crystal frequency)
An 11.0592 MHz crystal is connected to XTAL1 and XTAL2 to yield a cycle
frequency of 921.6 KHz.
Microcontroller interacts with LCD to display data on it. Port 0 pins are used to
interact with the LCD.
P 2.0: is connected to Register Select (RS) pin i.e. Pin 4 of LCD.
If P 3.5 = 0, instruction commands code register is selected, allowing the user to
send a command such as clear display, cursor at home etc.
If P 3.5 = 1, the data register is selected, allowing the user to send data to be
displayed on to the LCD.
the LCD to latch in the data present at the data pins. This pulse must be a minimum of
450ns wide.
To communicate serially, the baud rate has to be set. Configuring the special function
registers (SCON and TMOD) of the microcontroller can set this.
SCON: Serial Port Control Register (Bit –Addressable)
One cost effective way to communicate is to send and receive bits serially.
Asynchronous serial communication is widely used for character-oriented transmission. In
Asynchronous serial communication, the data is placed in between a start bit and one or two
stop bits. This is called Framing. During serial data communication, register SUBF is used to
hold data to be transmitted / received. SCON register controls data communication, PCON
controls data rates.
SBUF is physically two registers. One is writing only and is used to hold data to be
transmitted out of 89C52 via TXD. The other is read only and holds received data from
external sources via RXD. A register called SCON at address 98H controls the serial port of
microcontroller.
The device eliminates the need for external zero and full-scale adjustments. Easy
interfacing to microprocessors is provided by the latched and decoded multiplexer address
inputs and latched TTL TRI-STATEÉ outputs. The design of the ADC0808, ADC0809 has
been optimized by incorporating the most desirable aspects of several A/D conversion
techniques. The ADC0808, ADC0809 offers high speed, high accuracy, minimal temperature
dependence, excellent long-term accuracy and repeatability, and consumes minimal power.
These features make this device ideally suited to applications from process and machine
control to consumer and automotive applications.
Because the Analog-to-Digital Converter (A/D Converter or ADC) has both analog
and digital functions, it is a mixed-signal device. Many of us consider the ADC to be a
mysterious device. It can, however, be considered very simply to be the instrument that it is:
a device that provides an output that digitally represents the input voltage or current level.
Notice I said voltage or current. Most ADCs convert an input voltage to a digital word, but
the true definition of an ADC does include the possibility of an input current.
An ADC has an analog reference voltage or current against which the analog input is
Compared. The digital output word tells us what fraction of the reference voltage or current
is the input voltage or current. So, basically, the ADC is a divider.
The Input/Output transfer function is given by the formula indicated here. If you have seen
this formula before, you probably did not see the “G” term (gain factor). This is because we
generally consider this to be unity.
However, National Semiconductor has introduced ADCs with other gain factors, so it is
important to understand that this factor is present.
Features
Easy interface to all microprocessors
Operates ratiometrically or with 5 VDC or analog span adjusted voltage reference
No zero or full-scale adjust required
8-channel multiplexer with address logic
0V to 5V input range with single 5V power supply
Outputs meet TTL voltage level specifications
Standard hermetic or molded 28-pin DIP package
28-pin molded chip carrier package
ADC0808 equivalent to MM74C949
ADC0809 equivalent to MM74C949-1
Key Specifications
Resolution 8 Bits
Total Unadjusted Error g(/2 LSB and g1 LSB
Single Supply 5 VDC
Low Power 15 mW
Conversion Time 100 ms
The digital output drivers of the ADC provide fairly fast edge rates (rise and fall
times). This causes the output drivers to draw varying amounts of dynamic supply current
with fast rise times to charge whatever capacitance is on the outputs when the output data
must go from a logic low to logic high. The noise thus introduced on the output driver supply
can upset any analog circuitry if that supply is not decoupled from the ADC output drivers.
Features
Direct replacement for SE555/NE555
Timing from microseconds through hours
Operates in both astable and monostable modes
Adjustable duty cycle
Output can source or sink 200 mA
Output and supply TTL compatible
Temperature stability better than 0.005% per °C
Normally on and normally off output
Available in 8-pin MSOP package
Applications:
Precision timing
Pulse generation
Sequential timing
Time delay generation
Pulse width modulation
ASTABLE OPERATION
If the circuit is connected as shown in Figure 4 (pins 2 and 6 connected) it will trigger
itself and free run as a multivibrator. The external capacitor charges through RA + RB and
discharges through RB. Thus the duty cycle may be precisely set by the ratio of these two
resistors.
In this mode of operation, the capacitor charges and discharges between 1/3 VCC and
2/3 VCC. As in the triggered mode, the charge and discharge times, and therefore the
frequency are independent of the supply voltage.
Applications Information
The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has
an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not
required to subtract a large constant voltage from its output to obtain convenient Centigrade
scaling. The LM35 does not require any external calibration or trimming to provide typical
accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature
range. Low cost is assured by trimming and calibration at the wafer level.
The LM35’s low output impedance, linear output, and precise inherent calibration
make interfacing to readout or control circuitry especially easy. It can be used with single
power supplies, or with plus and minus supplies. As it draws only 60 μA from its supply, it
has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over a
−55° to +150°C temperature range, while the LM35C is rated for a −40° to +110°C range
(−10° with improved accuracy). The LM35 series is available packaged in hermetic TO-46
transistor packages, while the LM35C, LM35CA, and LM35D are also available in the
plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount
small outline package and a plastic TO-220 package
Features
The LM35 can be applied easily in the same way as other integrated-circuit
temperature sensors. It can be glued or cemented to a surface and its temperature will be
within about 0.01°C of the surface temperature. This presumes that the ambient air
temperature is almost the same as the surface temperature; if the air temperature were much
higher or lower than the surface temperature, the actual temperature of the LM35 die would
be at an intermediate temperature between the surface temperature and the air temperature.
This is especially true for the TO-92 plastic package, where the copper leads are the principal
thermal path to carry heat into the device, so its temperature might be closer to the air
temperature than to the surface temperature. To minimize this problem, be sure that the
wiring to the LM35, as it leaves the device, is held at the same temperature as the surface of
interest.
The easiest way to do this is to cover up these wires with a bead of epoxy which will
insure that the leads and wires are all at the same temperature as the surface, and that the
LM35 die’s temperature will not be affected by the air temperature. The TO-46 metal
Dept. of Electrical & Electronics Engg.
CEC Page 33
Auto Controlled Irrigation Unit In
Greenhouse
package can also be soldered to a metal surface or pipe without damage. Of course, in that
case the V− terminal of the circuit will be grounded to that metal.
Alternatively, the LM35 can be mounted inside a sealed-end metal tube, and can then be
dipped into a bath or screwed into a threaded hole in a tank. As with any IC, the LM35 and
accompanying wiring and circuits must be kept insulated and dry, to avoid leakage
and corrosion. This is especially true if the circuit may operate at cold temperatures where
condensation can occur. Printed-circuit coatings and varnishes such as Humiseal and epoxy
paints or dips are often used to insure that moisture cannot corrode the LM35 or its
connections. These devices are sometimes soldered to a small light-weight heat fin, to
decrease the thermal time constant and speed up the response in slowly-moving air. On the
other hand, a small thermal mass may be added to the sensor, to give the steadiest reading
despite small deviations in the air temperature.
Like most micro power circuits, the LM35 has a limited ability to drive heavy
capacitive loads. The LM35 by itself is able to drive 50 pf without special precautions. If
heavier loads are anticipated, it is easy to isolate or decouple the load with a resistor; see
Figure 3. Or you can improve the tolerance of capacitance with a series R-C damper from
output to ground;
Liquid crystal displays (LCD’s) offer several advantages over traditional cathode-ray
tube displays that make them ideal for several applications. Of course, LCDs are flat and they
use only a fraction of the power required by cathode-ray tubes. They are easier to read and
more pleasant to work with for long periods of time than most ordinary video monitors.
There are several tradeoffs as well, such as limited view angle, brightness, and contrast, not
to mention high manufacturing cost.
16x2 LCD is used in this project to display data to user. There are two rows and 16
columns. It is possible to display 16 characters on each of the 2 rows. It has two registers,
command register and data register.
EN (Enable):
The LCD to latch information presented to its data pins uses the enable pin. When
data is supplied to data pins, a high-to-low pulse must be applied to this pin in order for the
LCD to latch in the data present at the data pins. This pulse must be a minimum of 450ns
wide.
R / W: (Read/Write)
This pin is connected to ground, as LCD is used only to display data.
Vcc :
This pin is connected to +5v power supply.
Vss:
This pin is connected to ground
Features:
• High accuracy
• Chemically resistant
4.7 LDR 2
The Light Dependant Resistor which can also be known as a Photo Resistor or Photo
Conductor is an electronic component made of high resistance semiconductor material whose
resistance reduces as the amount of light shining on it increases. The device we will be
looking at in this exercise is a low cost Cadmium Sulphide (CdS) device readily available
from most electronic suppliers.
The LDR is manufactured by adding impurities and a fusing agent to very pure CdS
crystal powder and then mixing with water. The resulting paste is screened over the ceramic
substrate to provide an even coating. The coated substrate is then sintered at a high
temperature to grow the CdS crystals; this will give a thick photo sensitive layer. Lead
terminals and connecting wires are then added to the surface; the whole device is then
protected in a clear plastic coating.
CdS Coating
Lead Terminals
Connecting Wires
Light-dependent resistances (LDR) are cheap light sensors. The light dependent resistor
(LDR) is a sensor whose resistance decreases when light impinges on it. This kind of sensor
is commonly used in light sensor circuits in open areas, to control street lamps for example.
Another possible use is in spectroscopic apparatus. In this kind of apparatus, continuous light
or pulsed light can be used. Continuous light is used in common spectroscopic apparatus. The
use of lock-in amplifiers made the use of pulsed light in spectroscopy easier, as is commonly
used in photo acoustic spectroscopy. LDR’s are made of semiconductors as light sensitive
materials, on an isolating base. The most common semiconductors used in this system are
cadmium sulphide, lead sulphide, germanium, silicon and gallium arsenide
4.8 ULN
ULN 2003 IC is used as a relay driver. It is an inverting buffer. The output current of digital
devices is very low. Therefore ULN2003 is used, which gives sufficient current to drive the
relay. ULN2003AG is an 18-pin IC out of which 8 pins are input and 8 pins are output pins
and other two are Ground and Vcc. It works as a switching device. It is high voltage, high
current Darlington driver. These versatile devices are useful for driving a wide range of
loads, relays, DC motors, LED displays, lamps. Pin Diagram is shown below
Features:
• Seven Darlington’s per package.
• Output current 500mA per driver (600ma peak).
• Output voltage 50V.
• Outputs can be pearled for higher currents.
• TTL/CMOS/PMOS/DTL compatible input.
• Inputs pinned opposite outputs to simplify layout.
• Outputs can be paralleled for higher current
ULN 2003 is used to provide sufficient current to drive relay. Relay is an electromechanical
device, which is used to couple C with AC.
The C programming language was designed for computers, though, and not
embedded systems. It does not support direct access to registers, nor does it allow for the
reading and setting of single bits, two very important requirements for 8051 software. In
addition, most software developers are accustomed to writing programs that will by executed
by an operating system, which provides system calls the program may use to access the
hardware. However, much code for the 8051 is written for direct use on the processor,
without an operating system. To support this, the Kiel compiler has added several extensions
to the C language to replace what might have normally been implemented in a system call,
such as the connecting of interrupt handlers.
The purpose of this manual is to further explain the limitations of the Keil compiler, the
modifications it has made to the C language, and how to account for these in developing
software for the 8051 micro controller
Sample code
1) basic program to toggle bit Port0.5 10 times
Ans. #include<reg51.h>
Sbit ssss=P0^5;
Main ()
{
Unsigned char a;
P0=0X00;// Make P0 as output port
For (a=0; a<10; a++)
{
ssss=0; //toggling the bit
ssss=1;
}
Kiel Tool
CHAPTER 5
SYSTEM WORKING
5.1 WORKING
5.2 FLOW CHART
5.1 WORKING:
The proposed system is an embedded system which will closely monitor and
control the microclimatic parameters of a greenhouse on a regular basis round the
clock for cultivation of crops or specific plant species which could maximize their production
over the whole crop growth season and to eliminate the difficulties involved in the system by
reducing human intervention to the best possible extent. The system comprises of sensors,
Analog to Digital Converter, microcontroller and actuators.
When any of the above mentioned climatic parameters cross a safety threshold which
has to be maintained to protect the crops, the sensors sense the change and the
microcontroller reads this from the data at its input ports after being converted to a digital
form by the ADC. The microcontroller then performs the needed actions by employing relays
until the strayed-out parameter has been brought back to its optimum level. Since a
microcontroller is used as the heart of the system, it makes the set-up low-cost and effective
nevertheless. As the system also employs an LCD display for continuously alerting the user
about the condition inside the greenhouse, the entire set-up becomes user friendly.
Thus, this system eliminates the drawbacks of the existing set-ups mentioned in the
previous section and is designed as an easy to maintain, flexible and low cost solution.
START
B
INITIALISE THE ADC
IS MODE
YES
BUTTON
PRESSED
NO
YES NO
SENSOR
THRESHOLD
CROSSED?
START
C
C
D
D
STOP
START
NO
IS YES
EOC =0? A
A
STOP
Auto Controlled
Irrigation Unit In Greenhouse
FUTURE ENHANCEMENT
1) The performance of the system can be further improved in terms of the
operating speed, memory capacity, instruction cycle period of the microcontroller by
using other controllers such as AVRs and PICs. 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) A speaking voice alarm could be used instead of the normal buzzer.
CONCLUSION
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.
BIBLIOGRAPHY
Literature references:
“The 8051 Microcontroller and embedded systems” by Muhammad Ali Mazidi and
Janice Gillispie Mazidi., Sixth edition, Pearson Education
“The 8051 Microcontroller architecture, programming and applications” by
Kenneth J Ayala, second edition, Penram International Publishing.
“Programming and Customizing The 8051 Micro controller” by Myke Predko.
Web sites:
www.atmel/89c51/tutorials/architecture.com
www.keil.com
www.philips.com
www.howstuffworks.com
Tutorials on 8051, www.8051.com
www.datasheetcatalog.com
APPENDIX
ATMEL DATA SHEET